[Zope-Checkins] CVS: Zope2 - HTTPServer.py:1.31

Andreas Jung andreas@dhcp165.digicool.com
Tue, 24 Apr 2001 11:01:25 -0400


Update of /cvs-repository/Zope2/ZServer
In directory yetix:/work/sandboxes/Zope2/ZServer

Modified Files:
	HTTPServer.py 
Log Message:
regex, ready for Medusa migration



--- Updated File HTTPServer.py in package Zope2 --
--- HTTPServer.py	2001/04/05 23:49:13	1.30
+++ HTTPServer.py	2001/04/24 15:00:42	1.31
@@ -104,7 +104,7 @@
     
 """ 
 import sys
-import regex
+import re
 import string
 import os
 import types
@@ -131,8 +131,8 @@
 
 register_subsystem('ZServer HTTPServer')
 
-CONTENT_LENGTH = regex.compile('Content-Length: \([0-9]+\)',regex.casefold)
-CONNECTION = regex.compile ('Connection: \(.*\)', regex.casefold)
+CONTENT_LENGTH  = re.compile('Content-Length: ([0-9]+)',re.I)
+CONNECTION      = re.compile('Connection: (.*)', re.I)
 
 # maps request some headers to environment variables.
 # (those that don't start with 'HTTP_')
@@ -141,6 +141,14 @@
             'connection'        : 'CONNECTION_TYPE',
             }
 
+
+# stolen from Medusa
+def get_header (head_reg, lines, group=1):
+    for line in lines:
+        if head_reg.match (line):
+            return head_reg.group(group)
+    return ''
+
 class zhttp_collector:
     def __init__(self, handler, request, size):
         self.handler = handler
@@ -201,11 +209,11 @@
               uri_base=uri_base[:-1]
         self.uri_base=uri_base
         uri_regex='%s.*' % self.uri_base
-        self.uri_regex = regex.compile(uri_regex)
+        self.uri_regex = re.compile(uri_regex)
 
     def match(self, request):
         uri = request.uri
-        if self.uri_regex.match(uri) == len(uri):
+        if self.uri_regex.match(uri):
             return 1
         else:
             return 0