Commit ca42c469 authored by Andreas Jung's avatar Andreas Jung

- new option --force-http-connection-close for z2.py to prevent

        clients from maintaing pipelined connections to the Zope server
        (Collector #412)
parent 7e0c4c50
...@@ -103,6 +103,8 @@ class zhttp_collector: ...@@ -103,6 +103,8 @@ class zhttp_collector:
class zhttp_handler: class zhttp_handler:
"A medusa style handler for zhttp_server" "A medusa style handler for zhttp_server"
_force_connection_close = 0
def __init__ (self, module, uri_base=None, env=None): def __init__ (self, module, uri_base=None, env=None):
"""Creates a zope_handler """Creates a zope_handler
...@@ -258,6 +260,8 @@ class zhttp_handler: ...@@ -258,6 +260,8 @@ class zhttp_handler:
env=self.get_environment(request) env=self.get_environment(request)
zresponse=make_response(request,env) zresponse=make_response(request,env)
if self._force_connection_close:
zresponse._http_connection = 'close'
zrequest=HTTPRequest(sin, env, zresponse) zrequest=HTTPRequest(sin, env, zresponse)
request.channel.current_request=None request.channel.current_request=None
request.channel.queue.append((self.module_name, zrequest, zresponse)) request.channel.queue.append((self.module_name, zrequest, zresponse))
......
...@@ -90,6 +90,10 @@ Zope Changes ...@@ -90,6 +90,10 @@ Zope Changes
by using the HTMLWithImages class (has been disabled prior by using the HTMLWithImages class (has been disabled prior
to Zope 2.6) to Zope 2.6)
- new option --force-http-connection-close for z2.py to prevent
clients from maintaing pipelined connections to the Zope server
(Collector #412)
Bugs: Bugs:
- External methods didn't properly setup func_defaults and func_code - External methods didn't properly setup func_defaults and func_code
......
...@@ -103,6 +103,8 @@ class zhttp_collector: ...@@ -103,6 +103,8 @@ class zhttp_collector:
class zhttp_handler: class zhttp_handler:
"A medusa style handler for zhttp_server" "A medusa style handler for zhttp_server"
_force_connection_close = 0
def __init__ (self, module, uri_base=None, env=None): def __init__ (self, module, uri_base=None, env=None):
"""Creates a zope_handler """Creates a zope_handler
...@@ -258,6 +260,8 @@ class zhttp_handler: ...@@ -258,6 +260,8 @@ class zhttp_handler:
env=self.get_environment(request) env=self.get_environment(request)
zresponse=make_response(request,env) zresponse=make_response(request,env)
if self._force_connection_close:
zresponse._http_connection = 'close'
zrequest=HTTPRequest(sin, env, zresponse) zrequest=HTTPRequest(sin, env, zresponse)
request.channel.current_request=None request.channel.current_request=None
request.channel.queue.append((self.module_name, zrequest, zresponse)) request.channel.queue.append((self.module_name, zrequest, zresponse))
......
...@@ -114,6 +114,13 @@ Options: ...@@ -114,6 +114,13 @@ Options:
Multiple -W options can be provided to run multiple servers. Multiple -W options can be provided to run multiple servers.
-C
--force-http-connection-close
If present, this option causes Zope to close all HTTP connections,
regardless of the 'Connection:' header (or lack of one) sent by
the client.
-f port -f port
The FTP port. If this is a dash (e.g. -f -), then FTP The FTP port. If this is a dash (e.g. -f -), then FTP
...@@ -357,8 +364,8 @@ try: ...@@ -357,8 +364,8 @@ try:
raise 'Invalid python version', sys.version.split()[0] raise 'Invalid python version', sys.version.split()[0]
opts, args = getopt.getopt(sys.argv[1:], opts, args = getopt.getopt(sys.argv[1:],
'hz:Z:t:i:a:d:u:w:W:f:p:m:Sl:2DP:rF:L:XM:', 'hz:Z:t:i:a:d:u:w:W:f:p:m:Sl:2DP:rF:L:XM:C',
['icp=', ['icp=', 'force-http-connection-close'
]) ])
DEBUG=0 DEBUG=0
...@@ -408,6 +415,8 @@ try: ...@@ -408,6 +415,8 @@ try:
MONITOR_PORT=server_info(MONITOR_PORT, v) MONITOR_PORT=server_info(MONITOR_PORT, v)
elif o=='-w': elif o=='-w':
HTTP_PORT=server_info(HTTP_PORT, v) HTTP_PORT=server_info(HTTP_PORT, v)
elif o=='-C' or o=='--force-http-connection-close':
FORCE_HTTP_CONNECTION_CLOSE=1
elif o=='-W': elif o=='-W':
WEBDAV_SOURCE_PORT=server_info(WEBDAV_SOURCE_PORT, v) WEBDAV_SOURCE_PORT=server_info(WEBDAV_SOURCE_PORT, v)
elif o=='-f': elif o=='-f':
...@@ -596,6 +605,8 @@ try: ...@@ -596,6 +605,8 @@ try:
# environment to reflect the CGI environment of the other web # environment to reflect the CGI environment of the other web
# server. # server.
zh = zhttp_handler(MODULE, '', HTTP_ENV) zh = zhttp_handler(MODULE, '', HTTP_ENV)
if FORCE_HTTP_CONNECTION_CLOSE:
zh._force_connection_close = 1
hs.install_handler(zh) hs.install_handler(zh)
# WebDAV source Server (runs HTTP, but munges request to return # WebDAV source Server (runs HTTP, but munges request to return
......
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