[Zope-Checkins] CVS: Zope/ZServer - FTPRequest.py:1.12.26.1 HTTPServer.py:1.35.26.1

Andreas Jung andreas@zope.com
Tue, 6 Nov 2001 11:04:24 -0500


Update of /cvs-repository/Zope/ZServer
In directory cvs.zope.org:/tmp/cvs-serv19863/ZServer

Modified Files:
      Tag: ajung-webdav-debug
	FTPRequest.py HTTPServer.py 
Log Message:
added support for WebDAV clients trying to GET a document on the 
standard HTTP port. 



=== Zope/ZServer/FTPRequest.py 1.12 => 1.12.26.1 ===
             env['PATH_INFO']=self._join_paths(channel.path, 
                                               path, 'manage_addFolder')
+
+#            if self.meta_type=='Portal Folder':
+#                env['PATH_INFO']=self._join_paths(channel.path, 
+#                                                  path, 'MKCOL_handler')
+#            else:
+#                env['PATH_INFO']=self._join_paths(channel.path, 
+#                                                 path, 'manage_addFolder')
             env['QUERY_STRING']='id=%s' % args[0]
 
         elif command=='RNTO':


=== Zope/ZServer/HTTPServer.py 1.35 => 1.35.26.1 ===
 from medusa import logger
 
+
 register_subsystem('ZServer HTTPServer')
 
 CONTENT_LENGTH  = re.compile('Content-Length: ([0-9]+)',re.I)
 CONNECTION      = re.compile('Connection: (.*)', re.I)
+USER_AGENT      = re.compile('User-Agent: (.*)', re.I)
 
 # maps request some headers to environment variables.
 # (those that don't start with 'HTTP_')
@@ -250,6 +252,8 @@
         env['SERVER_SOFTWARE']=server.SERVER_IDENT
         env['SERVER_PROTOCOL']="HTTP/"+request.version
         env['channel.creation_time']=request.channel.creation_time
+
+
         if self.uri_base=='/':
             env['SCRIPT_NAME']=''
             env['PATH_INFO']='/' + path
@@ -266,6 +270,34 @@
             env['QUERY_STRING'] = query
         env['GATEWAY_INTERFACE']='CGI/1.1'
         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
+        # machinery is enabled and if the client is recognized
+        # as WebDAV client. If yes, we fake the environment
+        # to pretend the ZPublisher to have a WebDAV request.
+        # This sucks but it works pretty fine.
+
+        if env['REQUEST_METHOD']=='GET':
+            # Fixme:: This should be imported at startup 
+            from webdav import Resource,webdav_magic
+        
+            if Resource.webdav_magic_enabled==1:
+
+                agent = get_header(USER_AGENT,request.header)
+                
+                if webdav_magic.webdav_agents(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 we're using a resolving logger, try to get the
         # remote host from the resolver's cache.