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