From 8cfa026d44cadf07971b787955352cd6607a04e5 Mon Sep 17 00:00:00 2001 From: Sjoerd Langkemper Date: Wed, 20 Jul 2016 12:22:56 +0200 Subject: [PATCH] Don't check Content-Length header anymore Because it is not present in Flask 0.11. We keep merging the headers from the `headers` variable with the headers from the `response.headers`, because changing the response may change the headers, especially the `Content-Length` header. In Flask 0.11 this `Content-Length` header is no longer present in the `response.headers`, so we check whether the `response.data` has changed. Fixes #290 --- httpbin/core.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/httpbin/core.py b/httpbin/core.py index cf3fd6c..7582e0a 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -315,7 +315,7 @@ def response_headers(): response = jsonify(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) @@ -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