Skip to content

Commit

Permalink
Merge pull request #298 from Sjord/response-headers-without-content-l…
Browse files Browse the repository at this point in the history
…ength

Don't check Content-Length header anymore
  • Loading branch information
sigmavirus24 committed Aug 10, 2016
2 parents 9b8de5d + f4a937e commit fc19ce3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions httpbin/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,10 @@ def view_status_code(codes):
def response_headers():
"""Returns a set of response headers from the query string """
headers = MultiDict(request.args.items(multi=True))
response = jsonify(headers.lists())
response = jsonify(list(headers.lists()))

while True:
content_len_shown = response.headers['Content-Length']
original_data = response.data
d = {}
for key in response.headers.keys():
value = response.headers.get_all(key)
Expand All @@ -325,7 +325,8 @@ def response_headers():
response = jsonify(d)
for key, value in headers.items(multi=True):
response.headers.add(key, value)
if response.headers['Content-Length'] == content_len_shown:
response_has_changed = response.data != original_data
if not response_has_changed:
break
return response

Expand Down

0 comments on commit fc19ce3

Please sign in to comment.