File tree Expand file tree Collapse file tree
Misc/NEWS.d/next/Documentation Expand file tree Collapse file tree Original file line number Diff line number Diff 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
119138The following exceptions are raised as appropriate:
120139
Original file line number Diff line number Diff line change 1+ Document :func: `http.client.parse_headers `.
You can’t perform that action at this time.
0 commit comments