Skip to content

Commit

Permalink
bpo-21257: document http.client.parse_headers (pythonGH-11443)
Browse files Browse the repository at this point in the history
Document http.client.parse_headers
  • Loading branch information
epicfaace authored and briancurtin committed Jan 18, 2019
1 parent 34de2d3 commit 478f829
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Doc/library/http.client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ The module provides the following classes:
The *strict* parameter was removed. HTTP 0.9 style "Simple Responses" are
no longer supported.

This module provides the following function:

.. function:: parse_headers(fp)

Parse the headers from a file pointer *fp* representing a HTTP
request/response. The file has to be a :class:`BufferedIOBase` reader
(i.e. not text) and must provide a valid :rfc:`2822` style header.

This function returns an instance of :class:`http.client.HTTPMessage`
that holds the header fields, but no payload
(the same as :attr:`HTTPResponse.msg`
and :attr:`http.server.BaseHTTPRequestHandler.headers`).
After returning, the file pointer *fp* is ready to read the HTTP body.

.. note::
:meth:`parse_headers` does not parse the start-line of a HTTP message;
it only parses the ``Name: value`` lines. The file has to be ready to
read these field lines, so the first line should already be consumed
before calling the function.

The following exceptions are raised as appropriate:

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document :func:`http.client.parse_headers`.

0 comments on commit 478f829

Please sign in to comment.