Commits

Mariano Mara  committed 0b80e08 Merge

Pulling mkl changesets 5531a94aa9dc and 1230a14a499d

  • Participants
  • Parent commits 0394201, 5531a94

Comments (0)

Files changed (6)

File docs/index.txt

 Discussion should happen on the `Paste mailing lists
 <http://pythonpaste.org/community/>`_, and bugs can go on the `Paste
 trac instance <http://trac.pythonpaste.org/>`_.  It was originally
-written by Ian Bicking, and the primary maintainer is now Sergey
-Schetnin.
+written by `Ian Bicking <http://ianbicking.org/>`, and the primary
+maintainer is now `Sergey Schetinin <http://self.maluke.com/>`.
 
 WebOb is released under an `MIT-style license <license.html>`_.
 

File tests/test_request.py

     assert 'content-length' not in Request({}, content_length=None).headers
     assert 'content-type' not in Request({}, content_type=None).headers
 
+def test_env_keys():
+    req = Request.blank('/')
+    # SCRIPT_NAME can be missing
+    del req.environ['SCRIPT_NAME']
+    eq_(req.script_name, '')
+    eq_(req.uscript_name, u'')
+
 def test_repr_nodefault():
     nd = NoDefault
     eq_(repr(nd), '(No Default)')

File tests/test_response.txt

     >>> tuple(result.content_range)
     (5, 10, 10)
 
+    >>> req_head = req.copy()
+    >>> req_head.method = 'HEAD'
+    >>> print req_head.get_response(res)
+    206 Partial Content
+    Content-Length: 5
+    Content-Range: bytes 5-9/10
+    Content-Type: text/html; charset=UTF-8
+
 And an invalid requested range:
 
     >>> req.range = (10, 20)
     >>> str(result.content_range)
     'bytes */10'
 
+    >>> req_head = req.copy()
+    >>> req_head.method = 'HEAD'
+    >>> print req_head.get_response(res)
+    416 Requested Range Not Satisfiable
+    Content-Length: 44
+    Content-Range: bytes */10
+    Content-Type: text/plain
+
     >>> Request.blank('/', range=(1,2)).get_response(
     ...     Response('0123456789', conditional_response=True)).content_length
     1

File webob/descriptors.py

 
 def upath_property(key):
     def fget(req):
-        return req.environ[key].decode('UTF8', req.unicode_errors)
+        return req.environ.get(key, '').decode('UTF8', req.unicode_errors)
     def fset(req, val):
         req.environ[key] = val.encode('UTF8', req.unicode_errors)
     return property(fget, fset, doc='upath_property(%r)' % key)

File webob/request.py

 
     scheme = environ_getter('wsgi.url_scheme')
     method = environ_getter('REQUEST_METHOD')
-    script_name = environ_getter('SCRIPT_NAME')
+    script_name = environ_getter('SCRIPT_NAME', '')
     path_info = environ_getter('PATH_INFO')
     content_length = converter(
         environ_getter('CONTENT_LENGTH', None, '14.13'),

File webob/response.py

         params = []
         for k, v in sorted(value_dict.items()):
             if not _OK_PARAM_RE.search(v):
-                ## FIXME: I'm not sure what to do with "'s in the parameter value
-                ## I think it might be simply illegal
                 v = '"%s"' % v.replace('"', '\\"')
             params.append('; %s=%s' % (k, v))
         ct = self.headers.pop('Content-Type', '').split(';', 1)[0]
         if status304:
             start_response('304 Not Modified', filter_headers(headerlist))
             return EmptyResponse(self.app_iter)
-        if req.method == 'HEAD':
-            start_response(self.status, headerlist)
-            return EmptyResponse(self.app_iter)
-        # FIXME: we should handle HEAD requests with Range
         if (req.range and req.if_range.match_response(self)
             and self.content_range is None
-            and req.method == 'GET'
+            and req.method in ('HEAD', 'GET')
             and self.status_int == 200
             and self.content_length is not None
         ):
                     ('Content-Type', 'text/plain'),
                 ] + filter_headers(headerlist)
                 start_response('416 Requested Range Not Satisfiable', headerlist)
+                if req.method == 'HEAD':
+                    return ()
                 return [body]
             else:
                 app_iter = self.app_iter_range(content_range.start, content_range.stop)
                         ('Content-Range', str(content_range)),
                     ] + filter_headers(headerlist, ('content-length',))
                     start_response('206 Partial Content', headerlist)
+                    if req.method == 'HEAD':
+                        return EmptyResponse(app_iter)
                     return app_iter
 
         start_response(self.status, headerlist)
+        if req.method == 'HEAD':
+            return EmptyResponse(self.app_iter)
         return self.app_iter
 
     def app_iter_range(self, start, stop):