]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Merge branch 'master' into merge
authorBen Darnell <ben@bendarnell.com>
Mon, 24 Sep 2012 03:26:24 +0000 (23:26 -0400)
committerBen Darnell <ben@bendarnell.com>
Mon, 24 Sep 2012 03:26:24 +0000 (23:26 -0400)
Conflicts:
tornado/simple_httpclient.py
tornado/test/web_test.py

1  2 
tornado/simple_httpclient.py
tornado/test/web_test.py
tornado/web.py
tornado/wsgi.py

index ab70b519e63b06f92fff7df58de9cf160a5eba07,6bd10c17ce718126d1ced1034e6e5250955ce560..ae298842493ce976a7b7ca4b95d5ac8469e4692c
@@@ -333,10 -334,15 +334,15 @@@ class _HTTPConnection(object)
      def _on_headers(self, data):
          data = native_str(data.decode("latin1"))
          first_line, _, header_data = data.partition("\n")
 -        match = re.match("HTTP/1.[01] ([0-9]+)", first_line)
 +        match = re.match("HTTP/1.[01] ([0-9]+) ([^\r]*)", first_line)
          assert match
-         self.code = int(match.group(1))
-         self.reason = match.group(2)
+         code = int(match.group(1))
+         if 100 <= code < 200:
+             self.stream.read_until_regex(b("\r?\n\r?\n"), self._on_headers)
+             return
+         else:
+             self.code = code
 -
++            self.reason = match.group(2)
          self.headers = HTTPHeaders.parse(header_data)
  
          if "Content-Length" in self.headers:
index acca76654562d01b006182528a6451ec531d9ab8,4ce5b616bbc1d27dee923e54a5570305acb4a4f3..8cb6af2ad3159b72f57807125b086d388af07df1
@@@ -1,10 -1,11 +1,12 @@@
  from __future__ import absolute_import, division, with_statement
  from tornado import gen
- from tornado.escape import json_decode, utf8, to_unicode, recursive_unicode, native_str
+ from tornado.escape import json_decode, utf8, to_unicode, recursive_unicode, native_str, to_basestring
  from tornado.iostream import IOStream
+ from tornado.log import app_log, gen_log
 +from tornado.simple_httpclient import SimpleAsyncHTTPClient
  from tornado.template import DictLoader
- from tornado.testing import LogTrapTestCase, AsyncHTTPTestCase
+ from tornado.testing import AsyncHTTPTestCase, ExpectLog
+ from tornado.test.util import unittest
  from tornado.util import b, bytes_type, ObjectDict
  from tornado.web import RequestHandler, authenticated, Application, asynchronous, url, HTTPError, StaticFileHandler, _create_signature, create_signed_value
  
@@@ -850,28 -890,17 +891,45 @@@ class Header304Test(SimpleHandlerTestCa
          self.assertTrue("Content-Language" not in response2.headers)
          # Not an entity header, but should not be added to 304s by chunking
          self.assertTrue("Transfer-Encoding" not in response2.headers)
+ wsgi_safe.append(Header304Test)
  
- class StatusReasonTest(SimpleHandlerTestCase, LogTrapTestCase):
++
++class StatusReasonTest(SimpleHandlerTestCase):
 +    class Handler(RequestHandler):
 +        def get(self):
 +            reason = self.request.arguments.get('reason', [])
 +            self.set_status(int(self.get_argument('code')),
 +                            reason=reason[0] if reason else None)
 +
 +    def get_http_client(self):
 +        # simple_httpclient only: curl doesn't expose the reason string
 +        return SimpleAsyncHTTPClient(io_loop=self.io_loop)
 +
 +    def test_status(self):
 +        response = self.fetch("/?code=304")
 +        self.assertEqual(response.code, 304)
 +        self.assertEqual(response.reason, "Not Modified")
 +        response = self.fetch("/?code=304&reason=Foo")
 +        self.assertEqual(response.code, 304)
 +        self.assertEqual(response.reason, "Foo")
 +        response = self.fetch("/?code=682&reason=Bar")
 +        self.assertEqual(response.code, 682)
 +        self.assertEqual(response.reason, "Bar")
-         response = self.fetch("/?code=682")
++        with ExpectLog(app_log, 'Uncaught exception'):
++            response = self.fetch("/?code=682")
 +        self.assertEqual(response.code, 500)
++wsgi_safe.append(StatusReasonTest)
++
++
+ class DateHeaderTest(SimpleHandlerTestCase):
+     class Handler(RequestHandler):
+         def get(self):
+             self.write("hello")
  
+     def test_date_header(self):
+         response = self.fetch('/')
+         header_date = datetime.datetime.strptime(response.headers['Date'],
+                                                  "%a, %d %b %Y %H:%M:%S GMT")
+         self.assertTrue(header_date - datetime.datetime.utcnow() <
+                         datetime.timedelta(seconds=2))
+ wsgi_safe.append(DateHeaderTest)
diff --cc tornado/web.py
Simple merge
diff --cc tornado/wsgi.py
Simple merge