[Python-ideas] Providing a public API for creating and parsing HTTP messages
derekamaciel at gmail.com
Tue Apr 17 02:21:08 EDT 2018
If this is not the appropriate place for this type of proposal please let
The modules http.client and http.server both do a wonderful job when
implementing HTTP clients and servers, respectively. However, occasionally
there may be a need to create and parse HTTP messages themselves without
needing to implement a client or server. While http.client and http.server
clearly have solved this problem for its own uses, there is little to no
public API exposed to a user wishing to do the same. For instance, the
documentation for http.client.HTTPMessage  simply states that it extends
from email.message.Message in order to parse the messages.
While this need may admittedly be a niche one, it is a shame that one
cannot simply use the functionality already implemented for http.client and
http.server for this purpose. Therefore, I am proposing this module be
improved such that the creation and parsing of HTTP messages be "pulled out
of" the existing code into HTTPRequest and HTTPResponse classes with a
public API for this purpose. The exact API is subject to change of course,
but it could work like:
>>> r = http.client.HTTPRequest("POST", "/foo", "Hello world!")
POST /foo HTTP/1.1
If this idea is not completely a bad one, I am very interested in
discussing in further detail how I (or perhaps someone else) could begin to
implement these changes.
Thank you for reading.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas