Commit e1143ed4 authored by Łukasz Nowak's avatar Łukasz Nowak

caddy-frontend: Improve header management in test backend

Accessing headers.dict results with dropping headers sent in more then one
line, which is accepted by RFC.

So in case if many lines for given header arrived, expose them as a list,
otherwise simply show exactly arrived header.
parent 3b28d015
......@@ -572,9 +572,18 @@ class TestHandler(BaseHTTPRequestHandler):
header_dict[header] = value.strip()
if response is None:
if 'x-reply-body' not in self.headers.dict:
headers_dict = dict()
for header in self.headers.keys():
content = self.headers.getheaders(header)
if len(content) == 0:
headers_dict[header] = None
elif len(content) == 1:
headers_dict[header] = content[0]
else:
headers_dict[header] = content
response = {
'Path': self.path,
'Incoming Headers': self.headers.dict
'Incoming Headers': headers_dict
}
response = json.dumps(response, indent=2)
else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment