1.1 --- a/WebStack/BaseHTTPRequestHandler.py Wed Feb 25 22:29:56 2004 +0000
1.2 +++ b/WebStack/BaseHTTPRequestHandler.py Wed Feb 25 22:30:23 2004 +0000
1.3 @@ -132,16 +132,66 @@
1.4
1.5 return self.trans.path
1.6
1.7 + def get_query_string(self):
1.8 +
1.9 + """
1.10 + A framework-specific method which gets the query string from the path in
1.11 + the request.
1.12 + """
1.13 +
1.14 + t = self.trans.path.split("?")
1.15 + if len(t) == 1:
1.16 + return ""
1.17 + else:
1.18 +
1.19 + # NOTE: Overlook erroneous usage of "?" characters in the path.
1.20 +
1.21 + return "?".join(t[1:])
1.22 +
1.23 # Higher level request-related methods.
1.24
1.25 + def get_fields_from_path(self):
1.26 +
1.27 + """
1.28 + A framework-specific method which extracts the form fields from the
1.29 + path specified in the transaction. The underlying framework may refuse
1.30 + to supply fields from the path if handling a POST transaction.
1.31 +
1.32 + The returned object should employ the cgi.FieldStorage interface.
1.33 + """
1.34 +
1.35 + # NOTE: Since the cgi.FieldStorage class employed in this implementation
1.36 + # NOTE: will only provide fields from the path for GET transactions, the
1.37 + # NOTE: environment is adjusted to persuade it to give the desired
1.38 + # NOTE: output.
1.39 +
1.40 + return FieldStorage(headers=self.get_headers(), environ={"REQUEST_METHOD" : "GET",
1.41 + "QUERY_STRING" : self.get_query_string()}, keep_blank_values=1)
1.42 +
1.43 + def get_fields_from_body(self):
1.44 +
1.45 + """
1.46 + A framework-specific method which extracts the form fields from the
1.47 + message body in the transaction.
1.48 +
1.49 + The returned object should employ the cgi.FieldStorage interface.
1.50 + """
1.51 +
1.52 + return FieldStorage(fp=self.get_request_stream(), headers=self.get_headers(),
1.53 + environ={"REQUEST_METHOD" : "POST"}, keep_blank_values=1)
1.54 +
1.55 def get_fields(self):
1.56
1.57 """
1.58 A framework-specific method which extracts the form fields from the
1.59 - transaction.
1.60 + transaction. Typically, the origin of the form fields will be affected
1.61 + by the method specified in the transaction.
1.62 +
1.63 + The returned object should employ the cgi.FieldStorage interface.
1.64 """
1.65
1.66 - return FieldStorage(self.get_request_stream(), keep_blank_values=1)
1.67 + return FieldStorage(fp=self.get_request_stream(), headers=self.get_headers(),
1.68 + environ={"REQUEST_METHOD" : self.get_request_method()}, keep_blank_values=1)
1.69
1.70 def get_user(self):
1.71