Providing a public API for creating and parsing HTTP messages

Hello all, If this is not the appropriate place for this type of proposal please let me know. 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 [1] simply states that it extends from email.message.Message in order to parse the messages. [1]: https://docs.python.org/3/library/http.client.html#httpmessage-objects 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:
Hello world! 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.

On Mon, Apr 16, 2018 at 11:21 PM, Derek Maciel <derekamaciel@gmail.com> wrote:
The way http.client/http.server are written, the code for creating and parsing messages is very tangled up with the code for sending and receiving data, so this wouldn't be easy to do without rewriting them from scratch. But would you accept a third-party package? https://h11.readthedocs.io -n -- Nathaniel J. Smith -- https://vorpus.org

On Mon, Apr 16, 2018 at 11:21 PM, Derek Maciel <derekamaciel@gmail.com> wrote:
The way http.client/http.server are written, the code for creating and parsing messages is very tangled up with the code for sending and receiving data, so this wouldn't be easy to do without rewriting them from scratch. But would you accept a third-party package? https://h11.readthedocs.io -n -- Nathaniel J. Smith -- https://vorpus.org
participants (2)
-
Derek Maciel
-
Nathaniel Smith