diff options
-rw-r--r-- | ryu/app/wsgi.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/ryu/app/wsgi.py b/ryu/app/wsgi.py index 7d7f1306..fc4c71ac 100644 --- a/ryu/app/wsgi.py +++ b/ryu/app/wsgi.py @@ -28,7 +28,8 @@ from tinyrpc.transports import ServerTransport, ClientTransport from tinyrpc.client import RPCClient import webob.dec import webob.exc -from webob.response import Response +from webob.request import Request as webob_Request +from webob.response import Response as webob_Response from ryu import cfg from ryu.lib import hub @@ -56,6 +57,33 @@ def route(name, path, methods=None, requirements=None): return _route +class Request(webob_Request): + """ + Wrapper class for webob.request.Request. + + The behavior of this class is the same as webob.request.Request + except for setting "charset" to "UTF-8" automatically. + """ + DEFAULT_CHARSET = "UTF-8" + + def __init__(self, environ, charset=DEFAULT_CHARSET, *args, **kwargs): + super(Request, self).__init__( + environ, charset=charset, *args, **kwargs) + + +class Response(webob_Response): + """ + Wrapper class for webob.response.Response. + + The behavior of this class is the same as webob.response.Response + except for setting "charset" to "UTF-8" automatically. + """ + DEFAULT_CHARSET = "UTF-8" + + def __init__(self, charset=DEFAULT_CHARSET, *args, **kwargs): + super(Response, self).__init__(charset=charset, *args, **kwargs) + + class WebSocketRegistrationWrapper(object): def __init__(self, func, controller): |