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

recurls: Switch response headers to HTTPMessage

CaseInsensitiveDict resulted with risky situations.
parent c41d4ef1
......@@ -2,7 +2,6 @@ import json
import urllib.parse
import tempfile
import subprocess
from requests.structures import CaseInsensitiveDict
import gzip
import os
import http.client
......@@ -136,17 +135,14 @@ class Recurls(object):
raise
with open(response_header_file) as fh:
response.header_text = fh.read()
response.headers = CaseInsensitiveDict()
response.headers = http.client.HTTPMessage()
for line in response.header_text.splitlines()[1:]:
if line.strip():
if ':' not in line:
continue
header, value = line.split(':', 1)
value = value.strip()
response.headers.setdefault(header, [])
response.headers[header].append(value)
for header in response.headers.keys():
response.headers[header] = ', '.join(response.headers[header])
response.headers.add_header(header, value)
if response.headers.get('content-encoding') == 'gzip':
with gzip.GzipFile(response_file) as fh:
response.text = fh.read().decode()
......
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