httplib (now http.client) and friends all have conn.getresponse() and an HTTPResponse class, but the server-side operations of conn.getrequest() and an HTTPRequest class seem to be lacking.
I understand that BaseHTTPServer and BaseHTTPRequestHandler can perform this functionality, but they don't expose these methods for use outside of the module.
Essentially what I want is BaseHTTPRequestHandler#parse_request to be a static method that returns an HTTPRequest object rather than populating member variables.
For server-side processing you want to look at something like wsgiref.
The WSGI standard parses the request into a simple dictionary with all of the relevant headers and elements.
Jeff, to enable parsing I create a small nine-line subclass of the base HTTP request handler:
You can now take a string with the text of an HTTP request inside and parse it by instantiating this class:
You would probably find WebOb useful. Frameworks like Pylons, Turbogears, and Bfg use it as part of their api. It does operate under the assumption that you are working under WSGI though.