diff options
author | Tim Burke <tim.burke@gmail.com> | 2018-06-27 15:54:01 -0700 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2018-06-28 10:31:16 -0700 |
commit | 8bfb97a3a8bfe1a1db66560a9dba21277b0c006e (patch) | |
tree | 28abe6eea494761276f5626acdcff3d541aa57bf /swift/common/middleware/catch_errors.py | |
parent | 4a0afa9fea60bf2d1943b59a1f4ab49cb89e682a (diff) | |
download | swift-8bfb97a3a8bfe1a1db66560a9dba21277b0c006e.tar.gz |
Content-Length enforcement fixups
Change-Id: Ice8144700cf447ecf5c6175dc64aa7662013fba5
Related-Change: I74d8c13eba2a4917b5a116875b51a781b33a7abf
Diffstat (limited to 'swift/common/middleware/catch_errors.py')
-rw-r--r-- | swift/common/middleware/catch_errors.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/swift/common/middleware/catch_errors.py b/swift/common/middleware/catch_errors.py index 106238daa..35303358a 100644 --- a/swift/common/middleware/catch_errors.py +++ b/swift/common/middleware/catch_errors.py @@ -69,7 +69,6 @@ class CatchErrorsContext(WSGIContext): trans_id = generate_trans_id(trans_id_suffix) env['swift.trans_id'] = trans_id - method = env['REQUEST_METHOD'] self.logger.txn_id = trans_id try: # catch any errors in the pipeline @@ -101,7 +100,10 @@ class CatchErrorsContext(WSGIContext): # the socket. In that case, we truncate the response body at N bytes # and raise an exception to stop any more bytes from being # generated and also to kill the TCP connection. - if self._response_headers: + if env['REQUEST_METHOD'] == 'HEAD': + resp = enforce_byte_count(resp, 0) + + elif self._response_headers: content_lengths = [val for header, val in self._response_headers if header.lower() == "content-length"] if len(content_lengths) == 1: @@ -110,9 +112,7 @@ class CatchErrorsContext(WSGIContext): except ValueError: pass else: - resp = enforce_byte_count( - resp, - 0 if method == 'HEAD' else content_length) + resp = enforce_byte_count(resp, content_length) # make sure the response has the trans_id if self._response_headers is None: |