32 self.path = environ['PATH_INFO'] |
32 self.path = environ['PATH_INFO'] |
33 self.method = environ['REQUEST_METHOD'].upper() |
33 self.method = environ['REQUEST_METHOD'].upper() |
34 self._headers = dict([(normalize_header(k[5:]), v) for k, v in self.environ.items() |
34 self._headers = dict([(normalize_header(k[5:]), v) for k, v in self.environ.items() |
35 if k.startswith('HTTP_')]) |
35 if k.startswith('HTTP_')]) |
36 https = environ.get("HTTPS") in ('yes', 'on', '1') |
36 https = environ.get("HTTPS") in ('yes', 'on', '1') |
37 self._base_url = base_url or self.application_uri() |
37 self._base_url = base_url or self.instance_uri() |
38 post, files = self.get_posted_data() |
38 post, files = self.get_posted_data() |
39 super(CubicWebWsgiRequest, self).__init__(vreg, https, post) |
39 super(CubicWebWsgiRequest, self).__init__(vreg, https, post) |
40 if files is not None: |
40 if files is not None: |
41 for fdef in files.itervalues(): |
41 for fdef in files.itervalues(): |
42 fdef[0] = unicode(fdef[0], self.encoding) |
42 fdef[0] = unicode(fdef[0], self.encoding) |
61 """returns 'POST', 'GET', 'HEAD', etc.""" |
61 """returns 'POST', 'GET', 'HEAD', etc.""" |
62 return self.method |
62 return self.method |
63 |
63 |
64 def relative_path(self, includeparams=True): |
64 def relative_path(self, includeparams=True): |
65 """return the normalized path of the request (ie at least relative |
65 """return the normalized path of the request (ie at least relative |
66 to the application's root, but some other normalization may be needed |
66 to the instance's root, but some other normalization may be needed |
67 so that the returned path may be used to compare to generated urls |
67 so that the returned path may be used to compare to generated urls |
68 |
68 |
69 :param includeparams: |
69 :param includeparams: |
70 boolean indicating if GET form parameters should be kept in the path |
70 boolean indicating if GET form parameters should be kept in the path |
71 """ |
71 """ |
103 """ |
103 """ |
104 return None |
104 return None |
105 |
105 |
106 ## wsgi request helpers ################################################### |
106 ## wsgi request helpers ################################################### |
107 |
107 |
108 def application_uri(self): |
108 def instance_uri(self): |
109 """Return the application's base URI (no PATH_INFO or QUERY_STRING) |
109 """Return the instance's base URI (no PATH_INFO or QUERY_STRING) |
110 |
110 |
111 see python2.5's wsgiref.util.application_uri code |
111 see python2.5's wsgiref.util.instance_uri code |
112 """ |
112 """ |
113 environ = self.environ |
113 environ = self.environ |
114 url = environ['wsgi.url_scheme'] + '://' |
114 url = environ['wsgi.url_scheme'] + '://' |
115 if environ.get('HTTP_HOST'): |
115 if environ.get('HTTP_HOST'): |
116 url += environ['HTTP_HOST'] |
116 url += environ['HTTP_HOST'] |