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)
| 211 | return lst |
| 212 | |
| 213 | def _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 | |
| 231 | def parse_headers(fp, _class=HTTPMessage): |
| 232 | """Parses only RFC2822 headers from a file pointer. |
no test coverage detected