Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 478f829

Browse files
epicfaacebriancurtin
authored andcommitted
bpo-21257: document http.client.parse_headers (GH-11443)
Document http.client.parse_headers
1 parent 34de2d3 commit 478f829

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

Doc/library/http.client.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,25 @@ The module provides the following classes:
115115
The *strict* parameter was removed. HTTP 0.9 style "Simple Responses" are
116116
no longer supported.
117117

118+
This module provides the following function:
119+
120+
.. function:: parse_headers(fp)
121+
122+
Parse the headers from a file pointer *fp* representing a HTTP
123+
request/response. The file has to be a :class:`BufferedIOBase` reader
124+
(i.e. not text) and must provide a valid :rfc:`2822` style header.
125+
126+
This function returns an instance of :class:`http.client.HTTPMessage`
127+
that holds the header fields, but no payload
128+
(the same as :attr:`HTTPResponse.msg`
129+
and :attr:`http.server.BaseHTTPRequestHandler.headers`).
130+
After returning, the file pointer *fp* is ready to read the HTTP body.
131+
132+
.. note::
133+
:meth:`parse_headers` does not parse the start-line of a HTTP message;
134+
it only parses the ``Name: value`` lines. The file has to be ready to
135+
read these field lines, so the first line should already be consumed
136+
before calling the function.
118137

119138
The following exceptions are raised as appropriate:
120139

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Document :func:`http.client.parse_headers`.

0 commit comments

Comments
 (0)