diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2013-06-03 05:00:51 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2013-06-03 05:00:51 (GMT) |
commit | 719d5e0204531ba9fe6b71da08a26ba96e068d1a (patch) | |
tree | 67f285ee5725302b8b3a8967da2ff762832f7cd6 | |
parent | 02961336fa73b981ac3b79335d784cb1895e5832 (diff) |
Pass extra HTTP headers via local proxy
-rw-r--r-- | sugar_network/toolkit/http.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/sugar_network/toolkit/http.py b/sugar_network/toolkit/http.py index 8dbc26e..1f4ece1 100644 --- a/sugar_network/toolkit/http.py +++ b/sugar_network/toolkit/http.py @@ -244,9 +244,15 @@ class Client(object): else: request.content = request.content_stream.read() headers['content-length'] = str(len(request.content)) - if request.accept_language: headers['accept-language'] = request.accept_language[0] + if hasattr(request, 'environ'): + for env_key, key in ( + ('HTTP_IF_MODIFIED_SINCE', 'if-modified-since'), + ): + value = request.environ.get(env_key) + if value: + headers[key] = value reply = self.request(method, path, data=request.content, params=params, headers=headers, allowed=[303], @@ -260,15 +266,6 @@ class Client(object): # `requests` library handles encoding on its own del reply.headers['transfer-encoding'] response.update(reply.headers) - """ - if 'Content-Disposition' in reply.headers: - response['Content-Disposition'] = \ - reply.headers['Content-Disposition'] - if 'Content-Type' in reply.headers: - response.content_type = reply.headers['Content-Type'] - if 'Content-Length' in reply.headers: - response.content_length = int(reply.headers['Content-Length']) - """ if reply.headers.get('Content-Type') == 'application/json': return json.loads(reply.content) |