1.1 --- a/WebStack/BaseHTTPRequestHandler.py Wed Aug 24 16:07:04 2005 +0000
1.2 +++ b/WebStack/BaseHTTPRequestHandler.py Wed Aug 24 18:50:10 2005 +0000
1.3 @@ -189,32 +189,56 @@
1.4
1.5 return self.parse_content_preferences(self.trans.headers.get("accept-language"))
1.6
1.7 - def get_path(self):
1.8 + def get_path(self, encoding=None):
1.9
1.10 """
1.11 - Returns the entire path from the request.
1.12 + Returns the entire path from the request as a Unicode object. Any "URL
1.13 + encoded" character values in the part of the path before the query
1.14 + string will be decoded and presented as genuine characters; the query
1.15 + string will remain "URL encoded", however.
1.16 +
1.17 + If the optional 'encoding' is set, use that in preference to the default
1.18 + encoding to convert the path into a form not containing "URL encoded"
1.19 + character values.
1.20 """
1.21
1.22 - return self.trans.path
1.23 + path = self.get_path_without_query(encoding)
1.24 + qs = self.get_query_string()
1.25 + if qs:
1.26 + return path + "?" + qs
1.27 + else:
1.28 + return path
1.29
1.30 - def get_path_without_query(self):
1.31 + def get_path_without_query(self, encoding=None):
1.32
1.33 """
1.34 - Returns the entire path from the request minus the query string.
1.35 + Returns the entire path from the request minus the query string as a
1.36 + Unicode object containing genuine characters (as opposed to "URL
1.37 + encoded" character values).
1.38 +
1.39 + If the optional 'encoding' is set, use that in preference to the default
1.40 + encoding to convert the path into a form not containing "URL encoded"
1.41 + character values.
1.42 """
1.43
1.44 # Remove the query string from the end of the path.
1.45
1.46 - return self.trans.path.split("?")[0]
1.47 + return self.decode_path(self.trans.path.split("?")[0], encoding)
1.48
1.49 - def get_path_info(self):
1.50 + def get_path_info(self, encoding=None):
1.51
1.52 """
1.53 Returns the "path info" (the part of the URL after the resource name
1.54 - handling the current request) from the request.
1.55 + handling the current request) from the request as a Unicode object
1.56 + containing genuine characters (as opposed to "URL encoded" character
1.57 + values).
1.58 +
1.59 + If the optional 'encoding' is set, use that in preference to the default
1.60 + encoding to convert the path into a form not containing "URL encoded"
1.61 + character values.
1.62 """
1.63
1.64 - return self.get_path_without_query()
1.65 + return self.get_path_without_query(encoding)
1.66
1.67 def get_query_string(self):
1.68