]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-21257: document http.client.parse_headers (GH-11443)
authorAshwin Ramaswami <aramaswamis@gmail.com>
Fri, 18 Jan 2019 15:49:16 +0000 (07:49 -0800)
committerBrian Curtin <brian@python.org>
Fri, 18 Jan 2019 15:49:16 +0000 (08:49 -0700)
Document http.client.parse_headers

Doc/library/http.client.rst
Misc/NEWS.d/next/Documentation/2019-01-15-21-45-27.bpo-21257.U9LKkx.rst [new file with mode: 0644]

index 3408c103e2f328e06183fa2ed0666f3e1c7b768a..beaa720d732b4cc1cad99123d8b9f3b11618ae4f 100644 (file)
@@ -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 (file)
index 0000000..ad035e9
--- /dev/null
@@ -0,0 +1 @@
+Document :func:`http.client.parse_headers`.