[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/HTTP - HTTPRequest.py:1.1.2.12
Martijn Pieters
mj@zope.com
Wed, 28 Nov 2001 16:34:41 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/HTTP
In directory cvs.zope.org:/tmp/cvs-serv16796/lib/python/Zope/Publisher/HTTP
Modified Files:
Tag: Zope-3x-branch
HTTPRequest.py
Log Message:
- Remove thread lock from cookie parse code; re is thread safe
- Add Cookie: header tests
=== Zope3/lib/python/Zope/Publisher/HTTP/HTTPRequest.py 1.1.2.11 => 1.1.2.12 ===
-from Zope.Publisher.maybe_lock import allocate_lock
-
-
-parse_cookie_lock=allocate_lock()
def parse_cookie(
text,
result=None,
@@ -494,39 +490,32 @@
'([\x00- ]*([^\x00- ;,="]+)="([^"]*)"([\x00- ]*[;,])?[\x00- ]*)'),
parmre=re.compile(
'([\x00- ]*([^\x00- ;,="]+)=([^\x00- ;,"]*)([\x00- ]*[;,])?[\x00- ]*)'),
- acquire=parse_cookie_lock.acquire,
- release=parse_cookie_lock.release,
):
if result is None: result={}
already_have=result.has_key
- acquire()
- try:
-
- mo_q = qparmre.match(text)
-
- if mo_q:
- # Match quoted correct cookies
+ mo_q = qparmre.match(text)
- l = len(mo_q.group(1))
- name = mo_q.group(2)
- value = mo_q.group(3)
+ if mo_q:
+ # Match quoted correct cookies
- else:
- # Match evil MSIE cookies ;)
+ l = len(mo_q.group(1))
+ name = mo_q.group(2)
+ value = mo_q.group(3)
- mo_p = parmre.match(text)
+ else:
+ # Match evil MSIE cookies ;)
- if mo_p:
- l = len(mo_p.group(1))
- name = mo_p.group(2)
- value = mo_p.group(3)
+ mo_p = parmre.match(text)
- else:
- return result
+ if mo_p:
+ l = len(mo_p.group(1))
+ name = mo_p.group(2)
+ value = mo_p.group(3)
- finally: release()
+ else:
+ return result
if not already_have(name): result[name]=value