[Python-checkins] bpo-21257: document http.client.parse_headers (GH-11443)

Brian Curtin webhook-mailer at python.org
Fri Jan 18 10:49:21 EST 2019


https://github.com/python/cpython/commit/478f8291327a3e3ab17b5857699565df43a9e952
commit: 478f8291327a3e3ab17b5857699565df43a9e952
branch: master
author: Ashwin Ramaswami <aramaswamis at gmail.com>
committer: Brian Curtin <brian at python.org>
date: 2019-01-18T08:49:16-07:00
summary:

bpo-21257: document http.client.parse_headers (GH-11443)

Document http.client.parse_headers

files:
A Misc/NEWS.d/next/Documentation/2019-01-15-21-45-27.bpo-21257.U9LKkx.rst
M Doc/library/http.client.rst

diff --git a/Doc/library/http.client.rst b/Doc/library/http.client.rst
index 3408c103e2f3..beaa720d732b 100644
--- a/Doc/library/http.client.rst
+++ b/Doc/library/http.client.rst
@@ -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:
 
diff --git a/Misc/NEWS.d/next/Documentation/2019-01-15-21-45-27.bpo-21257.U9LKkx.rst b/Misc/NEWS.d/next/Documentation/2019-01-15-21-45-27.bpo-21257.U9LKkx.rst
new file mode 100644
index 000000000000..ad035e95b51c
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2019-01-15-21-45-27.bpo-21257.U9LKkx.rst
@@ -0,0 +1 @@
+Document :func:`http.client.parse_headers`.



More information about the Python-checkins mailing list