Commit b9535272 authored by Toby Dickenson's avatar Toby Dickenson

Collector #266: persistent proxy connections

parent 8bdf0ba0
...@@ -297,15 +297,25 @@ class ChannelPipe: ...@@ -297,15 +297,25 @@ class ChannelPipe:
self._request.reply_code=response.status self._request.reply_code=response.status
is_proxying_match = re.compile(r'[^ ]* [^ \\]*:').match
proxying_connection_re = re.compile ('Proxy-Connection: (.*)', re.IGNORECASE)
def make_response(request, headers): def make_response(request, headers):
"Simple http response factory" "Simple http response factory"
# should this be integrated into the HTTPResponse constructor? # should this be integrated into the HTTPResponse constructor?
response=ZServerHTTPResponse(stdout=ChannelPipe(request), stderr=StringIO()) response=ZServerHTTPResponse(stdout=ChannelPipe(request), stderr=StringIO())
response._http_version=request.version response._http_version=request.version
response._http_connection=( if request.version=='1.0' and is_proxying_match(request.request):
http_server.get_header(http_server.CONNECTION, request.header)).lower() # a request that was made as if this zope was an http 1.0 proxy.
# that means we have to use some slightly different http
# headers to manage persistent connections.
connection_re = proxying_connection_re
else:
# a normal http request
connection_re = http_server.CONNECTION
response._http_connection = http_server.get_header(connection_re,
request.header).lower()
response._server_version=request.channel.server.SERVER_IDENT response._server_version=request.channel.server.SERVER_IDENT
return response return response
...@@ -297,15 +297,25 @@ class ChannelPipe: ...@@ -297,15 +297,25 @@ class ChannelPipe:
self._request.reply_code=response.status self._request.reply_code=response.status
is_proxying_match = re.compile(r'[^ ]* [^ \\]*:').match
proxying_connection_re = re.compile ('Proxy-Connection: (.*)', re.IGNORECASE)
def make_response(request, headers): def make_response(request, headers):
"Simple http response factory" "Simple http response factory"
# should this be integrated into the HTTPResponse constructor? # should this be integrated into the HTTPResponse constructor?
response=ZServerHTTPResponse(stdout=ChannelPipe(request), stderr=StringIO()) response=ZServerHTTPResponse(stdout=ChannelPipe(request), stderr=StringIO())
response._http_version=request.version response._http_version=request.version
response._http_connection=( if request.version=='1.0' and is_proxying_match(request.request):
http_server.get_header(http_server.CONNECTION, request.header)).lower() # a request that was made as if this zope was an http 1.0 proxy.
# that means we have to use some slightly different http
# headers to manage persistent connections.
connection_re = proxying_connection_re
else:
# a normal http request
connection_re = http_server.CONNECTION
response._http_connection = http_server.get_header(connection_re,
request.header).lower()
response._server_version=request.channel.server.SERVER_IDENT response._server_version=request.channel.server.SERVER_IDENT
return response return response
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