1.1 --- a/WebStack/BaseHTTPRequestHandler.py Thu Aug 26 20:37:56 2004 +0000
1.2 +++ b/WebStack/BaseHTTPRequestHandler.py Thu Aug 26 21:07:45 2004 +0000
1.3 @@ -81,8 +81,7 @@
1.4 def get_request_stream(self):
1.5
1.6 """
1.7 - A framework-specific method which returns the request stream for
1.8 - the transaction.
1.9 + Returns the request stream for the transaction.
1.10 """
1.11
1.12 return MessageBodyStream(self.trans.rfile, self.get_headers())
1.13 @@ -90,7 +89,7 @@
1.14 def get_request_method(self):
1.15
1.16 """
1.17 - A framework-specific method which gets the request method.
1.18 + Returns the request method.
1.19 """
1.20
1.21 return self.trans.command
1.22 @@ -98,8 +97,9 @@
1.23 def get_headers(self):
1.24
1.25 """
1.26 - A framework-specific method which returns all request headers as a
1.27 - dictionary-like object mapping header names to values.
1.28 + Returns all request headers as a dictionary-like object mapping header
1.29 + names to values.
1.30 +
1.31 NOTE: If duplicate header names are permitted, then this interface will
1.32 NOTE: need to change.
1.33 """
1.34 @@ -109,9 +109,9 @@
1.35 def get_header_values(self, key):
1.36
1.37 """
1.38 - A framework-specific method which returns a list of all request header
1.39 - values associated with the given 'key'. Note that according to RFC 2616,
1.40 - 'key' is treated as a case-insensitive string.
1.41 + Returns a list of all request header values associated with the given
1.42 + 'key'. Note that according to RFC 2616, 'key' is treated as a
1.43 + case-insensitive string.
1.44 """
1.45
1.46 return self.convert_to_list(self.trans.headers.get(key))
1.47 @@ -119,8 +119,8 @@
1.48 def get_content_type(self):
1.49
1.50 """
1.51 - A framework-specific method which gets the content type specified on the
1.52 - request, along with the charset employed.
1.53 + Returns the content type specified on the request, along with the
1.54 + charset employed.
1.55 """
1.56
1.57 return self.parse_content_type(self.trans.headers.get("content-type"))
1.58 @@ -136,8 +136,7 @@
1.59 def get_content_languages(self):
1.60
1.61 """
1.62 - A framework-specific method which extracts language information from
1.63 - the transaction.
1.64 + Returns extracted language information from the transaction.
1.65 """
1.66
1.67 return self.parse_content_preferences(self.trans.headers.get("accept-language"))
1.68 @@ -145,7 +144,7 @@
1.69 def get_path(self):
1.70
1.71 """
1.72 - A framework-specific method which gets the entire path from the request.
1.73 + Returns the entire path from the request.
1.74 """
1.75
1.76 return self.trans.path
1.77 @@ -153,8 +152,7 @@
1.78 def get_path_without_query(self):
1.79
1.80 """
1.81 - A framework-specific method which gets the entire path from the request
1.82 - minus the query string.
1.83 + Returns the entire path from the request minus the query string.
1.84 """
1.85
1.86 # Remove the query string from the end of the path.
1.87 @@ -164,9 +162,8 @@
1.88 def get_path_info(self):
1.89
1.90 """
1.91 - A framework-specific method which gets the "path info" (the part of the
1.92 - URL after the resource name handling the current request) from the
1.93 - request.
1.94 + Returns the "path info" (the part of the URL after the resource name
1.95 + handling the current request) from the request.
1.96 """
1.97
1.98 return self.get_path_without_query()
1.99 @@ -174,8 +171,7 @@
1.100 def get_query_string(self):
1.101
1.102 """
1.103 - A framework-specific method which gets the query string from the path in
1.104 - the request.
1.105 + Returns the query string from the path in the request.
1.106 """
1.107
1.108 t = self.trans.path.split("?")
1.109 @@ -192,9 +188,9 @@
1.110 def get_fields_from_path(self):
1.111
1.112 """
1.113 - A framework-specific method which extracts the form fields from the
1.114 - path specified in the transaction. The underlying framework may refuse
1.115 - to supply fields from the path if handling a POST transaction.
1.116 + Extracts the form fields from the path specified in the transaction. The
1.117 + underlying framework may refuse to supply fields from the path if
1.118 + handling a POST transaction.
1.119
1.120 Returns a dictionary mapping field names to lists of values (even if a
1.121 single value is associated with any given field name).
1.122 @@ -205,11 +201,10 @@
1.123 def get_fields_from_body(self, encoding=None):
1.124
1.125 """
1.126 - A framework-specific method which extracts the form fields from the
1.127 - message body in the transaction. The optional 'encoding' parameter
1.128 - specifies the character encoding of the message body for cases where no
1.129 - such information is available, but where the default encoding is to be
1.130 - overridden.
1.131 + Extracts the form fields from the message body in the transaction. The
1.132 + optional 'encoding' parameter specifies the character encoding of the
1.133 + message body for cases where no such information is available, but where
1.134 + the default encoding is to be overridden.
1.135
1.136 Returns a dictionary mapping field names to lists of values (even if a
1.137 single value is associated with any given field name).
1.138 @@ -238,8 +233,7 @@
1.139 def get_user(self):
1.140
1.141 """
1.142 - A framework-specific method which extracts user information from the
1.143 - transaction.
1.144 + Extracts user information from the transaction.
1.145
1.146 Returns a username as a string or None if no user is defined.
1.147 """
1.148 @@ -256,8 +250,7 @@
1.149 def get_cookies(self):
1.150
1.151 """
1.152 - A framework-specific method which obtains cookie information from the
1.153 - request.
1.154 + Obtains cookie information from the request.
1.155
1.156 Returns a dictionary mapping cookie names to cookie objects.
1.157 """
1.158 @@ -267,8 +260,7 @@
1.159 def get_cookie(self, cookie_name):
1.160
1.161 """
1.162 - A framework-specific method which obtains cookie information from the
1.163 - request.
1.164 + Obtains cookie information from the request.
1.165
1.166 Returns a cookie object for the given 'cookie_name' or None if no such
1.167 cookie exists.
1.168 @@ -281,8 +273,7 @@
1.169 def get_response_stream(self):
1.170
1.171 """
1.172 - A framework-specific method which returns the response stream for
1.173 - the transaction.
1.174 + Returns the response stream for the transaction.
1.175 """
1.176
1.177 # Return a stream which is later emptied into the real stream.
1.178 @@ -325,8 +316,7 @@
1.179 def set_content_type(self, content_type):
1.180
1.181 """
1.182 - A framework-specific method which sets the 'content_type' for the
1.183 - response.
1.184 + Sets the 'content_type' for the response.
1.185 """
1.186
1.187 # The content type has to be written as a header, before actual content,
1.188 @@ -335,11 +325,12 @@
1.189
1.190 self.content_type = content_type
1.191
1.192 + # Higher level response-related methods.
1.193 +
1.194 def set_cookie(self, cookie):
1.195
1.196 """
1.197 - A framework-specific method which stores the given 'cookie' object in
1.198 - the response.
1.199 + Stores the given 'cookie' object in the response.
1.200 """
1.201
1.202 # NOTE: If multiple cookies of the same name could be specified, this
1.203 @@ -350,8 +341,7 @@
1.204 def set_cookie_value(self, name, value, path=None, expires=None):
1.205
1.206 """
1.207 - A framework-specific method which stores a cookie with the given 'name'
1.208 - and 'value' in the response.
1.209 + Stores a cookie with the given 'name' and 'value' in the response.
1.210
1.211 The optional 'path' is a string which specifies the scope of the cookie,
1.212 and the optional 'expires' parameter is a value compatible with the
1.213 @@ -367,9 +357,8 @@
1.214 def delete_cookie(self, cookie_name):
1.215
1.216 """
1.217 - A framework-specific method which adds to the response a request that
1.218 - the cookie with the given 'cookie_name' be deleted/discarded by the
1.219 - client.
1.220 + Adds to the response a request that the cookie with the given
1.221 + 'cookie_name' be deleted/discarded by the client.
1.222 """
1.223
1.224 # Create a special cookie, given that we do not know whether the browser