/response-headers

#25
This commit is contained in:
Kenneth Reitz
2012-02-20 13:12:52 -05:00
parent d949539027
commit ded5123437
+16
View File
@@ -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."""