# HG changeset patch # User paulb # Date 1076264148 0 # Node ID 88fe8cca77bdb16d6c7274a3be7cab9589fa8527 # Parent 282d1e3ef2a6731308efbd7607241bc86f407d42 [project @ 2004-02-08 18:15:48 by paulb] Added some user support (renaming the associated method). Changed the BaseHTTPRequestHandler transaction to use a special stream object which understands part of the HTTP specification, and fixed the default response code. diff -r 282d1e3ef2a6 -r 88fe8cca77bd WebStack/BaseHTTPRequestHandler.py --- a/WebStack/BaseHTTPRequestHandler.py Sun Feb 08 16:35:13 2004 +0000 +++ b/WebStack/BaseHTTPRequestHandler.py Sun Feb 08 18:15:48 2004 +0000 @@ -5,6 +5,7 @@ """ import Generic +from Helpers.Request import MessageBodyStream from cgi import FieldStorage from StringIO import StringIO @@ -26,7 +27,7 @@ # Other attributes of interest in instances of this class. self.content_type = None - self.response_code = 100 + self.response_code = 200 self.content = StringIO() def commit(self): @@ -37,7 +38,8 @@ """ self.trans.send_response(self.response_code) - self.trans.send_header("Content-Type", self.format_content_type(self.content_type)) + if self.content_type is not None: + self.trans.send_header("Content-Type", self.format_content_type(self.content_type)) self.trans.end_headers() self.content.seek(0) self.trans.wfile.write(self.content.read()) @@ -51,7 +53,7 @@ the transaction. """ - return self.trans.rfile + return MessageBodyStream(self.trans.rfile, self.get_headers()) def get_request_method(self): @@ -128,13 +130,15 @@ return FieldStorage(self.trans.rfile, keep_blank_values=1) - def get_agent_information(self): + def get_user(self): """ - A framework-specific method which extracts agent information from - the transaction. + A framework-specific method which extracts user information from the + transaction. """ + # NOTE: Not implemented yet, but just pretend that there are no users. + return None # Response-related methods. diff -r 282d1e3ef2a6 -r 88fe8cca77bd WebStack/Generic.py --- a/WebStack/Generic.py Sun Feb 08 16:35:13 2004 +0000 +++ b/WebStack/Generic.py Sun Feb 08 18:15:48 2004 +0000 @@ -174,14 +174,14 @@ raise NotImplementedError, "get_fields" - def get_agent_information(self): + def get_user(self): """ - A framework-specific method which extracts agent information from - the transaction. + A framework-specific method which extracts user information from the + transaction. """ - raise NotImplementedError, "get_agent_information" + raise NotImplementedError, "get_user" # Response-related methods. diff -r 282d1e3ef2a6 -r 88fe8cca77bd WebStack/ModPython.py --- a/WebStack/ModPython.py Sun Feb 08 16:35:13 2004 +0000 +++ b/WebStack/ModPython.py Sun Feb 08 18:15:48 2004 +0000 @@ -104,14 +104,14 @@ return FieldStorage(self.trans, keep_blank_values=1) - def get_agent_information(self): + def get_user(self): """ - A framework-specific method which extracts agent information from - the transaction. + A framework-specific method which extracts user information from the + transaction. """ - return None + return self.trans.user # Response-related methods. diff -r 282d1e3ef2a6 -r 88fe8cca77bd WebStack/Twisted.py --- a/WebStack/Twisted.py Sun Feb 08 16:35:13 2004 +0000 +++ b/WebStack/Twisted.py Sun Feb 08 18:15:48 2004 +0000 @@ -107,13 +107,15 @@ return dict([(key, value[0]) for (key, value) in self.trans.args.items()]) - def get_agent_information(self): + def get_user(self): """ - A framework-specific method which extracts agent information from - the transaction. + A framework-specific method which extracts user information from the + transaction. """ + # NOTE: Not implemented yet, but just pretend that there are no users. + return None # Response-related methods. diff -r 282d1e3ef2a6 -r 88fe8cca77bd WebStack/Webware.py --- a/WebStack/Webware.py Sun Feb 08 16:35:13 2004 +0000 +++ b/WebStack/Webware.py Sun Feb 08 18:15:48 2004 +0000 @@ -112,14 +112,14 @@ return self.trans.request().fields() - def get_agent_information(self): + def get_user(self): """ - A framework-specific method which extracts agent information from - the transaction. + A framework-specific method which extracts user information from the + transaction. """ - return None + return self.trans.request().remoteUser() # Response-related methods.