Commit 4157a0fe authored by matt@zope.com's avatar matt@zope.com

Change crack_request to handle absoluteURIs instead of just absolute paths;

e.g. GET http://www.zope.org:8080/ is legal, but medusa was not cleaning this
up to a URI of /.

The REQUEST regex was converted to a re format to accomplish this
parent 902acae4
...@@ -6,11 +6,12 @@ ...@@ -6,11 +6,12 @@
# All Rights Reserved. # All Rights Reserved.
# #
RCS_ID = '$Id: http_server.py,v 1.16 2000/06/02 14:22:48 brian Exp $' RCS_ID = '$Id: http_server.py,v 1.17 2000/06/22 20:11:16 matt Exp $'
# python modules # python modules
import os import os
import regex import regex
import re
import socket import socket
import stat import stat
import string import string
...@@ -675,17 +676,14 @@ def get_header (head_reg, lines, group=1): ...@@ -675,17 +676,14 @@ def get_header (head_reg, lines, group=1):
return head_reg.group(group) return head_reg.group(group)
return '' return ''
REQUEST = regex.compile ('\([^ ]+\) \([^ ]+\)\(\( HTTP/\([0-9.]+\)\)$\|$\)') REQUEST = re.compile ('([^ ]+) (?:[^ :]+://[^ /]*)?([^ ]+)(( HTTP/([0-9.]+))$|$)')
def crack_request (r): def crack_request (r):
if REQUEST.match (r) == len(r): m = REQUEST.match(r)
if REQUEST.group(3): if m is not None:
version = REQUEST.group(5) return string.lower (m.group (1)), m.group(2), m.group(5)
else: else:
version = None return None, None, None
return string.lower (REQUEST.group (1)), REQUEST.group(2), version
else:
return None, None, None
class fifo: class fifo:
def __init__ (self, list=None): def __init__ (self, list=None):
......
...@@ -6,11 +6,12 @@ ...@@ -6,11 +6,12 @@
# All Rights Reserved. # All Rights Reserved.
# #
RCS_ID = '$Id: http_server.py,v 1.16 2000/06/02 14:22:48 brian Exp $' RCS_ID = '$Id: http_server.py,v 1.17 2000/06/22 20:11:16 matt Exp $'
# python modules # python modules
import os import os
import regex import regex
import re
import socket import socket
import stat import stat
import string import string
...@@ -675,17 +676,14 @@ def get_header (head_reg, lines, group=1): ...@@ -675,17 +676,14 @@ def get_header (head_reg, lines, group=1):
return head_reg.group(group) return head_reg.group(group)
return '' return ''
REQUEST = regex.compile ('\([^ ]+\) \([^ ]+\)\(\( HTTP/\([0-9.]+\)\)$\|$\)') REQUEST = re.compile ('([^ ]+) (?:[^ :]+://[^ /]*)?([^ ]+)(( HTTP/([0-9.]+))$|$)')
def crack_request (r): def crack_request (r):
if REQUEST.match (r) == len(r): m = REQUEST.match(r)
if REQUEST.group(3): if m is not None:
version = REQUEST.group(5) return string.lower (m.group (1)), m.group(2), m.group(5)
else: else:
version = None return None, None, None
return string.lower (REQUEST.group (1)), REQUEST.group(2), version
else:
return None, None, None
class fifo: class fifo:
def __init__ (self, list=None): def __init__ (self, list=None):
......
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