Skip to content

Commit

Permalink
wsgi: environ[headers_raw] tuple of unmodified name: value pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
temoto committed Mar 1, 2016
1 parent 52472ac commit 2ab31f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions eventlet/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,9 @@ def get_environ(self):
else:
headers = [h.split(':', 1) for h in headers]

for k, v in headers:
env['headers_raw'] = headers_raw = tuple((k, v.strip()) for k, v in headers)
for k, v in headers_raw:
k = k.replace('-', '_').upper()
v = v.strip()
if k in env:
continue
envk = 'HTTP_' + k
Expand Down
12 changes: 12 additions & 0 deletions tests/wsgi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,18 @@ def test_log_unix_address(self):
finally:
shutil.rmtree(tempdir)

def test_headers_raw(self):
def app(environ, start_response):
start_response('200 OK', [])
return [b'\n'.join('{0}: {1}'.format(*kv).encode() for kv in environ['headers_raw'])]

self.spawn_server(site=app)
sock = eventlet.connect(self.server_addr)
sock.sendall(b'GET / HTTP/1.1\r\nHost: localhost\r\nx-ANY_k: one\r\nx-ANY_k: two\r\n\r\n')
result = read_http(sock)
sock.close()
assert result.status == 'HTTP/1.1 200 OK'
assert result.body == b'Host: localhost\nx-ANY_k: one\nx-ANY_k: two'

def read_headers(sock):
fd = sock.makefile('rb')
Expand Down

0 comments on commit 2ab31f0

Please sign in to comment.