]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Remove the has_body flag from write_headers.
authorBen Darnell <ben@bendarnell.com>
Sun, 27 Apr 2014 16:25:12 +0000 (12:25 -0400)
committerBen Darnell <ben@bendarnell.com>
Sun, 27 Apr 2014 16:25:12 +0000 (12:25 -0400)
It was only used client-side and we can infer whether we need to add
a framing mechanism from the method instead.

tornado/http1connection.py
tornado/httputil.py
tornado/simple_httpclient.py
tornado/wsgi.py

index 22485f1460799296b8fbb960a6ecab475ad3a3df..f23c767422c5dbfddaaffcac1d58c7987607b639 100644 (file)
@@ -267,21 +267,19 @@ class HTTP1Connection(httputil.HTTPConnection):
         """
         self._max_body_size = max_body_size
 
-    def write_headers(self, start_line, headers, chunk=None, callback=None,
-                      has_body=True):
+    def write_headers(self, start_line, headers, chunk=None, callback=None):
         """Implements `.HTTPConnection.write_headers`."""
         if self.is_client:
             self._request_start_line = start_line
             # Client requests with a non-empty body must have either a
             # Content-Length or a Transfer-Encoding.
             self._chunking_output = (
-                has_body and
+                start_line.method in ('POST', 'PUT', 'PATCH') and
                 'Content-Length' not in headers and
                 'Transfer-Encoding' not in headers)
         else:
             self._response_start_line = start_line
             self._chunking_output = (
-                has_body and
                 # TODO: should this use
                 # self._request_start_line.version or
                 # start_line.version?
index 23ef84b3eadcf436d2b25be4ba43f50a0f68cf9f..17d6f1bb64d4592f921763b10ace7b4efaf15277 100644 (file)
@@ -532,8 +532,7 @@ class HTTPConnection(object):
 
     .. versionadded:: 3.3
     """
-    def write_headers(self, start_line, headers, chunk=None, callback=None,
-                      has_body=True):
+    def write_headers(self, start_line, headers, chunk=None, callback=None):
         """Write an HTTP header block.
 
         :arg start_line: a `.RequestStartLine` or `.ResponseStartLine`.
@@ -542,9 +541,6 @@ class HTTPConnection(object):
             so that small responses can be written in the same call as their
             headers.
         :arg callback: a callback to be run when the write is complete.
-        :arg bool has_body: may be false to indicate that this message
-            has no body (and so does not need either a Content-Length
-            or Transfer-Encoding)
 
         Returns a `.Future` if no callback is given.
         """
index 74580699fbb86f380a74d23dd4554a7b639ad66c..ebab202b1d92ba8cd046f19fb8a582586ce82eba 100644 (file)
@@ -345,10 +345,7 @@ class _HTTPConnection(httputil.HTTPMessageDelegate):
             self._sockaddr)
         start_line = httputil.RequestStartLine(self.request.method,
                                                req_path, 'HTTP/1.1')
-        self.connection.write_headers(
-            start_line, self.request.headers,
-            has_body=(self.request.body is not None or
-                      self.request.body_producer is not None))
+        self.connection.write_headers(start_line, self.request.headers)
         if self.request.expect_100_continue:
             self._read_response()
         else:
index e5bc9f96be6d1fbbee2ead9822f36ba08a10f086..b9f8519a3ecda1fa37d607d70cf0481b3e5961e4 100644 (file)
@@ -99,8 +99,7 @@ class _WSGIConnection(httputil.HTTPConnection):
         # so we can simply ignore the callback.
         pass
 
-    def write_headers(self, start_line, headers, chunk=None, callback=None,
-                      has_body=True):
+    def write_headers(self, start_line, headers, chunk=None, callback=None):
         if self.method == 'HEAD':
             self._expected_content_remaining = 0
         elif 'Content-Length' in headers: