[Zope-Checkins] CVS: Zope/lib/python/ZServer - HTTPServer.py:1.43.22.1 component.xml:1.1.2.2 datatypes.py:1.1.2.2
Fred L. Drake, Jr.
fred@zope.com
Thu, 6 Feb 2003 16:34:00 -0500
Update of /cvs-repository/Zope/lib/python/ZServer
In directory cvs.zope.org:/tmp/cvs-serv15870
Modified Files:
Tag: new-install-branch
HTTPServer.py component.xml datatypes.py
Log Message:
Move the configuration of the WebDAV source client magic so that it does
not require any magical attributes poked into global state elsewhere.
=== Zope/lib/python/ZServer/HTTPServer.py 1.43 => 1.43.22.1 ===
--- Zope/lib/python/ZServer/HTTPServer.py:1.43 Mon Nov 4 08:33:46 2002
+++ Zope/lib/python/ZServer/HTTPServer.py Thu Feb 6 16:33:48 2003
@@ -34,6 +34,7 @@
import sys
import re
import os
+import posixpath
import types
import thread
import time
@@ -201,7 +202,6 @@
env['REMOTE_ADDR']=request.channel.addr[0]
-
# This is a really bad hack to support WebDAV
# clients accessing documents through GET
# on the HTTP port. We check if your WebDAV magic
@@ -210,19 +210,8 @@
# to pretend the ZPublisher to have a WebDAV request.
# This sucks like hell but it works pretty fine ;-)
- if env['REQUEST_METHOD']=='GET':
- wdav_client_reg = getattr(sys,'WEBDAV_SOURCE_PORT_CLIENTS',None)
-
- if wdav_client_reg:
- agent = get_header(USER_AGENT,request.header)
- if wdav_client_reg(agent):
-
- env['WEBDAV_SOURCE_PORT'] = 1
- path_info = env['PATH_INFO']
- path_info = os.path.join(path_info,'manage_FTPget')
- path_info = os.path.normpath(path_info)
- if os.sep != '/': path_info = path_info.replace(os.sep,'/')
- env['PATH_INFO'] = path_info
+ if env['REQUEST_METHOD']=='GET' and self._wdav_client_reg:
+ self._munge_webdav_source_port(request, env)
# If we're using a resolving logger, try to get the
@@ -247,6 +236,20 @@
env[key]=value
env.update(self.env_override)
return env
+
+ _wdav_client_reg = None
+
+ def _munge_webdav_source_port(self, request, env):
+ agent = get_header(USER_AGENT, request.header)
+ if self._wdav_client_reg(agent):
+ env['WEBDAV_SOURCE_PORT'] = 1
+ path_info = env['PATH_INFO']
+ path_info = posixpath.join(path_info, 'manage_FTPget')
+ path_info = posixpath.normpath(path_info)
+ env['PATH_INFO'] = path_info
+
+ def set_webdav_source_clients(self, regex):
+ self._wdav_client_reg = re.compile(regex).search
def continue_request(self, sin, request):
"continue handling request now that we have the stdin"
=== Zope/lib/python/ZServer/component.xml 1.1.2.1 => 1.1.2.2 ===
--- Zope/lib/python/ZServer/component.xml:1.1.2.1 Wed Feb 5 18:25:38 2003
+++ Zope/lib/python/ZServer/component.xml Thu Feb 6 16:33:48 2003
@@ -13,6 +13,12 @@
implements="server">
<key name="address" datatype="inet-address"/>
<key name="force-connection-close" datatype="boolean" default="off"/>
+ <key name="webdav-source-clients">
+ <description>
+ Regular expression used to identify clients who should
+ receive WebDAV source responses to GET requests.
+ </description>
+ </key>
</sectiontype>
<sectiontype name="webdav-source-server"
=== Zope/lib/python/ZServer/datatypes.py 1.1.2.1 => 1.1.2.2 ===
--- Zope/lib/python/ZServer/datatypes.py:1.1.2.1 Wed Feb 5 18:25:38 2003
+++ Zope/lib/python/ZServer/datatypes.py Thu Feb 6 16:33:48 2003
@@ -52,11 +52,16 @@
def __init__(self, section):
ServerFactory.__init__(self, section.address)
self.force_connection_close = section.force_connection_close
+ # webdav-source-server sections won't have webdav_source_clients:
+ webdav_clients = getattr(section, "webdav_source_clients", None)
+ self.webdav_source_clients = webdav_clients
def create(self):
from ZServer import HTTPServer
handler = self.createHandler()
handler._force_connection_close = self.force_connection_close
+ if self.webdav_source_clients:
+ handler.set_webdav_source_clients(self.webdav_source_clients)
server = HTTPServer.zhttp_server(ip=self.host, port=self.port,
resolver=self.dnsresolver,
logger_object=self.logger)