# HG changeset patch # User paulb # Date 1078013093 0 # Node ID 3cbc736c09a2fd9dfc8be0fd281a50d4fb30e164 # Parent 2310cb863fe8a479f679b7e4584fe8e547f331df [project @ 2004-02-29 00:04:53 by paulb] Fixed the get_fields_from_body method in BaseHTTPRequestHandler so that empty message bodies are handled gracefully. Added authenticator support. diff -r 2310cb863fe8 -r 3cbc736c09a2 WebStack/BaseHTTPRequestHandler.py --- a/WebStack/BaseHTTPRequestHandler.py Sat Feb 28 20:55:36 2004 +0000 +++ b/WebStack/BaseHTTPRequestHandler.py Sun Feb 29 00:04:53 2004 +0000 @@ -176,11 +176,16 @@ storage = FieldStorage(fp=self.get_request_stream(), headers=self.get_headers(), environ={"REQUEST_METHOD" : self.get_request_method()}, keep_blank_values=1) - # Traverse the storage, finding each field value. + # Avoid strange design issues with FieldStorage by checking the internal + # field list directly. fields = {} - for field_name in storage.keys(): - fields[field_name] = storage.getlist(field_name) + if storage.list is not None: + + # Traverse the storage, finding each field value. + + for field_name in storage.keys(): + fields[field_name] = storage.getlist(field_name) return fields def get_user(self): diff -r 2310cb863fe8 -r 3cbc736c09a2 WebStack/Generic.py --- a/WebStack/Generic.py Sat Feb 28 20:55:36 2004 +0000 +++ b/WebStack/Generic.py Sun Feb 29 00:04:53 2004 +0000 @@ -305,4 +305,42 @@ raise NotImplementedError, "respond" +class Authenticator: + + "A generic authentication component." + + def authenticate(self, trans): + + """ + An application-specific method which authenticates the sender of the + request described by the transaction object 'trans'. This method should + consider 'trans' to be read-only and not attempt to change the state of + the transaction. + + If the sender of the request is authenticated successfully, the result + of this method evaluates to true; otherwise the result of this method + evaluates to false. + """ + + raise NotImplementedError, "authenticate" + + def get_auth_type(self): + + """ + An application-specific method which returns the authentication type to + be used. An example value is 'Basic' which specifies HTTP basic + authentication. + """ + + raise NotImplementedError, "get_auth_type" + + def get_realm(self): + + """ + An application-specific method which returns the name of the realm for + which authentication is taking place. + """ + + raise NotImplementedError, "get_realm" + # vim: tabstop=4 expandtab shiftwidth=4