From: Ben Darnell Date: Sat, 14 Mar 2015 14:15:57 +0000 (-0400) Subject: Mark some tests as requiring HTTP/1.x X-Git-Tag: v4.2.0b1~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9189e8a0eb7fc19c89a6b9cbce8a7430dc448837;p=thirdparty%2Ftornado.git Mark some tests as requiring HTTP/1.x --- diff --git a/tornado/httputil.py b/tornado/httputil.py index 871ffaa7f..a4b1bb661 100644 --- a/tornado/httputil.py +++ b/tornado/httputil.py @@ -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): diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index f62cb5ca1..7077a326c 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -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): diff --git a/tornado/test/httpserver_test.py b/tornado/test/httpserver_test.py index c1ba831cf..fed008f2e 100644 --- a/tornado/test/httpserver_test.py +++ b/tornado/test/httpserver_test.py @@ -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") diff --git a/tornado/test/simple_httpclient_test.py b/tornado/test/simple_httpclient_test.py index 088010586..a5ca4afdc 100644 --- a/tornado/test/simple_httpclient_test.py +++ b/tornado/test/simple_httpclient_test.py @@ -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'')