diff --git a/httpbin/core.py b/httpbin/core.py index aa9cd75..f793d5d 100644 --- a/httpbin/core.py +++ b/httpbin/core.py @@ -18,6 +18,7 @@ from werkzeug.datastructures import WWWAuthenticate from . import filters from .helpers import get_headers, status_code, get_dict, check_basic_auth, check_digest_auth, H from .utils import weighted_choice +from .structures import CaseInsensitiveDict ENV_COOKIES = ( '_gauges_unique', @@ -187,6 +188,21 @@ def view_status_code(codes): return status_code(code) +@app.route('/response-headers') +def response_headers(): + """ Returns a set of response headers from the query string """ + headers = CaseInsensitiveDict(request.args.items()) + response = jsonify(headers.items()) + while True: + content_len_shown = response.headers['Content-Length'] + response = jsonify(response.headers.items()) + for key, value in headers.items(): + response.headers[key] = value + if response.headers['Content-Length'] == content_len_shown: + break + return response + + @app.route('/cookies') def view_cookies(hide_env=True): """Returns cookie data."""