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 max_headers.
(fp, max_headers)
| 215 | return lst |
| 216 | |
| 217 | def _read_headers(fp, max_headers): |
| 218 | """Reads potential header lines into a list from a file pointer. |
| 219 | |
| 220 | Length of line is limited by _MAXLINE, and number of |
| 221 | headers is limited by max_headers. |
| 222 | """ |
| 223 | headers = [] |
| 224 | if max_headers is None: |
| 225 | max_headers = _MAXHEADERS |
| 226 | while True: |
| 227 | line = fp.readline(_MAXLINE + 1) |
| 228 | if len(line) > _MAXLINE: |
| 229 | raise LineTooLong("header line") |
| 230 | if line in (b'\r\n', b'\n', b''): |
| 231 | break |
| 232 | headers.append(line) |
| 233 | if len(headers) > max_headers: |
| 234 | raise HTTPException(f"got more than {max_headers} headers") |
| 235 | return headers |
| 236 | |
| 237 | def _parse_header_lines(header_lines, _class=HTTPMessage): |
| 238 | """ |
no test coverage detected
searching dependent graphs…