MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _read_headers

Function _read_headers

tools/python-3.11.9-amd64/Lib/http/client.py:213–229  ·  view source on GitHub ↗

Reads potential header lines into a list from a file pointer. Length of line is limited by _MAXLINE, and number of headers is limited by _MAXHEADERS.

(fp)

Source from the content-addressed store, hash-verified

211 return lst
212
213def _read_headers(fp):
214 """Reads potential header lines into a list from a file pointer.
215
216 Length of line is limited by _MAXLINE, and number of
217 headers is limited by _MAXHEADERS.
218 """
219 headers = []
220 while True:
221 line = fp.readline(_MAXLINE + 1)
222 if len(line) > _MAXLINE:
223 raise LineTooLong("header line")
224 headers.append(line)
225 if len(headers) > _MAXHEADERS:
226 raise HTTPException("got more than %d headers" % _MAXHEADERS)
227 if line in (b'\r\n', b'\n', b''):
228 break
229 return headers
230
231def parse_headers(fp, _class=HTTPMessage):
232 """Parses only RFC2822 headers from a file pointer.

Callers 2

parse_headersFunction · 0.85
beginMethod · 0.85

Calls 4

LineTooLongClass · 0.85
HTTPExceptionClass · 0.85
readlineMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected