]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Merge pull request #1864 from leynos/master
authorBen Darnell <ben@bendarnell.com>
Sun, 26 Mar 2017 16:17:12 +0000 (12:17 -0400)
committerGitHub <noreply@github.com>
Sun, 26 Mar 2017 16:17:12 +0000 (12:17 -0400)
Allow specificion of trusted downstream proxies for xheaders

1  2 
tornado/httpserver.py
tornado/test/httpserver_test.py

index e76342f9dbe08a0ac8d1387930a6a475dd4a11ff,76edef2f96cfaa937f0002a6d96db97964a350c6..cde37d5d3482e14698464ddae2dc077adf434f44
@@@ -194,33 -195,8 +204,33 @@@ class HTTPServer(TCPServer, Configurabl
          self._connections.remove(server_conn)
  
  
 +class _CallableAdapter(httputil.HTTPMessageDelegate):
 +    def __init__(self, request_callback, request_conn):
 +        self.connection = request_conn
 +        self.request_callback = request_callback
 +        self.request = None
 +        self.delegate = None
 +        self._chunks = []
 +
 +    def headers_received(self, start_line, headers):
 +        self.request = httputil.HTTPServerRequest(
 +            connection=self.connection, start_line=start_line,
 +            headers=headers)
 +
 +    def data_received(self, chunk):
 +        self._chunks.append(chunk)
 +
 +    def finish(self):
 +        self.request.body = b''.join(self._chunks)
 +        self.request._parse_body()
 +        self.request_callback(self.request)
 +
 +    def on_connection_close(self):
 +        self._chunks = None
 +
 +
  class _HTTPRequestContext(object):
-     def __init__(self, stream, address, protocol):
+     def __init__(self, stream, address, protocol, trusted_downstream=None):
          self.address = address
          # Save the socket's address family now so we know how to
          # interpret self.address even after the stream is closed
Simple merge