Parses only RFC 5322 headers from header lines. email Parser wants to see strings rather than bytes. But a TextIOWrapper around self.rfile would buffer too many bytes from the stream, bytes which we later need to read as bytes. So we read the correct bytes here, as bytes, for e
(header_lines, _class=HTTPMessage)
| 235 | return headers |
| 236 | |
| 237 | def _parse_header_lines(header_lines, _class=HTTPMessage): |
| 238 | """ |
| 239 | Parses only RFC 5322 headers from header lines. |
| 240 | |
| 241 | email Parser wants to see strings rather than bytes. |
| 242 | But a TextIOWrapper around self.rfile would buffer too many bytes |
| 243 | from the stream, bytes which we later need to read as bytes. |
| 244 | So we read the correct bytes here, as bytes, for email Parser |
| 245 | to parse. |
| 246 | |
| 247 | """ |
| 248 | hstring = b''.join(header_lines).decode('iso-8859-1') |
| 249 | return email.parser.Parser(_class=_class).parsestr(hstring) |
| 250 | |
| 251 | def parse_headers(fp, _class=HTTPMessage, *, _max_headers=None): |
| 252 | """Parses only RFC 5322 headers from a file pointer.""" |
no test coverage detected
searching dependent graphs…