1.1 --- a/WebStack/BaseHTTPRequestHandler.py Thu Sep 16 22:18:33 2004 +0000
1.2 +++ b/WebStack/BaseHTTPRequestHandler.py Thu Sep 16 22:19:45 2004 +0000
1.3 @@ -5,12 +5,12 @@
1.4 """
1.5
1.6 import Generic
1.7 -from Helpers.Request import MessageBodyStream, get_body_fields, get_storage_items
1.8 +from Helpers.Request import MessageBodyStream, get_body_fields, get_storage_items, Cookie
1.9 from Helpers.Response import ConvertingStream
1.10 from Helpers.Auth import UserInfo
1.11 from Helpers.Session import SessionStore
1.12 from cgi import parse_qs, FieldStorage
1.13 -import Cookie
1.14 +from Cookie import SimpleCookie
1.15 from StringIO import StringIO
1.16
1.17 class Transaction(Generic.Transaction):
1.18 @@ -34,12 +34,12 @@
1.19 self.response_code = 200
1.20 self.content = StringIO()
1.21 self.headers_out = {}
1.22 - self.cookies_out = Cookie.SimpleCookie()
1.23 + self.cookies_out = SimpleCookie()
1.24 self.user = None
1.25
1.26 # Define the incoming cookies.
1.27
1.28 - self.cookies_in = Cookie.SimpleCookie(self.get_headers().get("cookie"))
1.29 + self.cookies_in = SimpleCookie(self.get_headers().get("cookie"))
1.30
1.31 # Cached information.
1.32
1.33 @@ -304,7 +304,7 @@
1.34 Returns a dictionary mapping cookie names to cookie objects.
1.35 """
1.36
1.37 - return self.cookies_in
1.38 + return self.process_cookies(self.cookies_in)
1.39
1.40 def get_cookie(self, cookie_name):
1.41
1.42 @@ -315,7 +315,11 @@
1.43 cookie exists.
1.44 """
1.45
1.46 - return self.cookies_in.get(cookie_name)
1.47 + cookie = self.cookies_in.get(self.encode_cookie_value(cookie_name))
1.48 + if cookie is not None:
1.49 + return Cookie(cookie_name, self.decode_cookie_value(cookie.value))
1.50 + else:
1.51 + return None
1.52
1.53 # Response-related methods.
1.54
1.55 @@ -395,7 +399,7 @@
1.56 # NOTE: If multiple cookies of the same name could be specified, this
1.57 # NOTE: could need changing.
1.58
1.59 - self.cookies_out[cookie.name] = cookie.value
1.60 + self.set_cookie_value(cookie.name, cookie.value)
1.61
1.62 def set_cookie_value(self, name, value, path=None, expires=None):
1.63
1.64 @@ -407,7 +411,8 @@
1.65 time.time function, and indicates the expiry date/time of the cookie.
1.66 """
1.67
1.68 - self.cookies_out[name] = value
1.69 + name = self.encode_cookie_value(name)
1.70 + self.cookies_out[name] = self.encode_cookie_value(value)
1.71 if path is not None:
1.72 self.cookies_out[name]["path"] = path
1.73 if expires is not None:
1.74 @@ -424,10 +429,11 @@
1.75 # has been sent the cookie or not.
1.76 # NOTE: Magic discovered in Webware.
1.77
1.78 - self.cookies_out[cookie_name] = ""
1.79 - self.cookies_out[cookie_name]["path"] = "/"
1.80 - self.cookies_out[cookie_name]["expires"] = 0
1.81 - self.cookies_out[cookie_name]["max-age"] = 0
1.82 + name = self.encode_cookie_value(cookie_name)
1.83 + self.cookies_out[name] = ""
1.84 + self.cookies_out[name]["path"] = "/"
1.85 + self.cookies_out[name]["expires"] = 0
1.86 + self.cookies_out[name]["max-age"] = 0
1.87
1.88 # Session-related methods.
1.89