]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add 307 too and update release notes.
authorBen Darnell <ben@bendarnell.com>
Wed, 18 Jan 2012 09:17:30 +0000 (01:17 -0800)
committerBen Darnell <ben@bendarnell.com>
Wed, 18 Jan 2012 09:17:30 +0000 (01:17 -0800)
tornado/simple_httpclient.py
tornado/test/simple_httpclient_test.py
website/sphinx/releases/next.rst

index 5e4d14555920d46dd8a3502427cfa898529d4348..ad5b7e0987cd1287aa4d41de0bfe350ab92d988c 100644 (file)
@@ -53,7 +53,7 @@ class SimpleAsyncHTTPClient(AsyncHTTPClient):
 
     Some features found in the curl-based AsyncHTTPClient are not yet
     supported.  In particular, proxies are not supported, connections
-    are not reused, and callers cannot select the network interface to be 
+    are not reused, and callers cannot select the network interface to be
     used.
 
     Python 2.6 or higher is required for HTTPS support.  Users of Python 2.5
@@ -310,7 +310,7 @@ class _HTTPConnection(object):
             yield
         except Exception, e:
             logging.warning("uncaught exception", exc_info=True)
-            self._run_callback(HTTPResponse(self.request, 599, error=e, 
+            self._run_callback(HTTPResponse(self.request, 599, error=e,
                                 request_time=time.time() - self.start_time,
                                 ))
 
@@ -335,7 +335,7 @@ class _HTTPConnection(object):
                 # use them but if they differ it's an error.
                 pieces = re.split(r',\s*', self.headers["Content-Length"])
                 if any(i != pieces[0] for i in pieces):
-                    raise ValueError("Multiple unequal Content-Lengths: %r" % 
+                    raise ValueError("Multiple unequal Content-Lengths: %r" %
                                      self.headers["Content-Length"])
                 self.headers["Content-Length"] = pieces[0]
             content_length = int(self.headers["Content-Length"])
@@ -380,7 +380,7 @@ class _HTTPConnection(object):
                                    self.request)
         if (self.request.follow_redirects and
             self.request.max_redirects > 0 and
-            self.code in (301, 302, 303)):
+            self.code in (301, 302, 303, 307)):
             new_request = copy.copy(self.request)
             new_request.url = urlparse.urljoin(self.request.url,
                                                self.headers["Location"])
@@ -391,8 +391,8 @@ class _HTTPConnection(object):
             if self.code == 303:
                 new_request.method = "GET"
                 new_request.body = None
-                for h in ["Content-Length", "Content-Type", 
-                    "Content-Encoding", "Transfer-Encoding"]:
+                for h in ["Content-Length", "Content-Type",
+                          "Content-Encoding", "Transfer-Encoding"]:
                     try:
                         del self.request.headers[h]
                     except KeyError:
index f0f9be0fb166ccb3dd7fc5824937c757aebb6a99..ebb265b916b9943d20203b0af89f56686e2ccb70 100644 (file)
@@ -56,14 +56,16 @@ class NoContentHandler(RequestHandler):
 
 class SeeOther303PostHandler(RequestHandler):
     def post(self):
+        assert self.request.body == b("blah")
         self.set_header("Location", "/303_get")
         self.set_status(303)
 
-class SeeOther303GetHandler(RequestHandler):    
+class SeeOther303GetHandler(RequestHandler):
     def get(self):
+        assert not self.request.body
         self.write("ok")
-        
-        
+
+
 class SimpleHTTPClientTestCase(AsyncHTTPTestCase, LogTrapTestCase):
     def setUp(self):
         super(SimpleHTTPClientTestCase, self).setUp()
@@ -163,13 +165,13 @@ class SimpleHTTPClientTestCase(AsyncHTTPTestCase, LogTrapTestCase):
         self.assertTrue(response.headers["Location"].endswith("/countdown/1"))
 
     def test_303_redirect(self):
-       response = self.fetch("/303_post", method="POST", body="")
+       response = self.fetch("/303_post", method="POST", body="blah")
        self.assertEqual(200, response.code)
        self.assertTrue(response.request.url.endswith("/303_post"))
        self.assertTrue(response.effective_url.endswith("/303_get"))
        #request is the original request, is a POST still
        self.assertEqual("POST", response.request.method)
-        
+
     def test_request_timeout(self):
         response = self.fetch('/hang', request_timeout=0.1)
         self.assertEqual(response.code, 599)
index 1fd9e82fcefdad9377c2099c65bd6b9318158073..907be793efe15e82469b8fc638bda770f6bf810f 100644 (file)
@@ -74,6 +74,7 @@ Other modules
 
 * `SimpleAsyncHTTPClient` no longer hangs on ``HEAD`` requests,
   responses with no content, or empty ``POST``/``PUT`` response bodies.
+* `SimpleAsyncHTTPClient` now supports 303 and 307 redirect codes.
 * `tornado.platform.twisted` compatibility has been significantly improved.
   Twisted version 11.1.0 is now supported in addition to 11.0.0.
 * `tornado.testing.main` supports a new flag ``--exception_on_interrupt``,