]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Mark some tests as requiring HTTP/1.x
authorBen Darnell <ben@bendarnell.com>
Sat, 14 Mar 2015 14:15:57 +0000 (10:15 -0400)
committerBen Darnell <ben@bendarnell.com>
Sat, 14 Mar 2015 14:15:57 +0000 (10:15 -0400)
tornado/httputil.py
tornado/test/httpclient_test.py
tornado/test/httpserver_test.py
tornado/test/simple_httpclient_test.py

index 871ffaa7faaae329ffa4e7e9b343ad92021cbbd9..a4b1bb661138d7a5b71b4ef84c2b39541ef0062b 100644 (file)
@@ -385,6 +385,8 @@ class HTTPServerRequest(object):
            to write the response.
         """
         assert isinstance(chunk, bytes)
+        assert self.version.startswith("HTTP/1."), \
+            "deprecated interface ony supported in HTTP/1.x"
         self.connection.write(chunk, callback=callback)
 
     def finish(self):
index f62cb5ca1906e725c69e4b46d7b19df7a20f90dc..7077a326cf156bd592cbcc4635144138187f2515 100644 (file)
@@ -178,6 +178,8 @@ class HTTPClientCommonTestCase(AsyncHTTPTestCase):
         sock, port = bind_unused_port()
         with closing(sock):
             def write_response(stream, request_data):
+                if b"HTTP/1." not in request_data:
+                    self.skipTest("requires HTTP/1.x")
                 stream.write(b"""\
 HTTP/1.1 200 OK
 Transfer-Encoding: chunked
@@ -316,7 +318,7 @@ Transfer-Encoding: chunked
         self.fetch('/chunk', header_callback=header_callback,
                    streaming_callback=streaming_callback)
         self.assertEqual(len(first_line), 1)
-        self.assertRegexpMatches(first_line[0], 'HTTP/1.[01] 200 OK\r\n')
+        self.assertRegexpMatches(first_line[0], 'HTTP/[0-9]\\.[0-9] 200 OK\r\n')
         self.assertEqual(chunks, [b'asdf', b'qwer'])
 
     def test_header_callback_stack_context(self):
index c1ba831cf1e343b961eab5edbae48b0ee8b3da6d..fed008f2e9cd42a660a0b92e24b00e656f133ed5 100644 (file)
@@ -1058,6 +1058,7 @@ class LegacyInterfaceTest(AsyncHTTPTestCase):
         # delegate interface, and writes its response via request.write
         # instead of request.connection.write_headers.
         def handle_request(request):
+            self.http1 = request.version.startswith("HTTP/1.")
             message = b"Hello world"
             request.write(utf8("HTTP/1.1 200 OK\r\n"
                                "Content-Length: %d\r\n\r\n" % len(message)))
@@ -1067,4 +1068,6 @@ class LegacyInterfaceTest(AsyncHTTPTestCase):
 
     def test_legacy_interface(self):
         response = self.fetch('/')
+        if not self.http1:
+            self.skipTest("requires HTTP/1.x")
         self.assertEqual(response.body, b"Hello world")
index 088010586026bf8346147782a495c2ab3b52361c..a5ca4afdc1ce4a4b0b9c2cbe1c37745ce53d632a 100644 (file)
@@ -492,6 +492,7 @@ class CreateAsyncHTTPClientTestCase(AsyncTestCase):
 
 class HTTP100ContinueTestCase(AsyncHTTPTestCase):
     def respond_100(self, request):
+        self.http1 = request.version.startswith('HTTP/1.')
         self.request = request
         self.request.connection.stream.write(
             b"HTTP/1.1 100 CONTINUE\r\n\r\n",
@@ -508,11 +509,14 @@ class HTTP100ContinueTestCase(AsyncHTTPTestCase):
 
     def test_100_continue(self):
         res = self.fetch('/')
+        if not self.http1:
+            self.skipTest("requires HTTP/1.x")
         self.assertEqual(res.body, b'A')
 
 
 class HTTP204NoContentTestCase(AsyncHTTPTestCase):
     def respond_204(self, request):
+        self.http1 = request.version.startswith('HTTP/1.')
         # A 204 response never has a body, even if doesn't have a content-length
         # (which would otherwise mean read-until-close).  Tornado always
         # sends a content-length, so we simulate here a server that sends
@@ -528,6 +532,8 @@ class HTTP204NoContentTestCase(AsyncHTTPTestCase):
 
     def test_204_no_content(self):
         resp = self.fetch('/')
+        if not self.http1:
+            self.skipTest("requires HTTP/1.x")
         self.assertEqual(resp.code, 204)
         self.assertEqual(resp.body, b'')