Create a message structure from a byte string. Returns the root of the message structure. Optional headersonly is a flag specifying whether to stop parsing after reading the headers or not. The default is False, meaning it parses the entire contents of the file.
(self, text, headersonly=False)
| 108 | |
| 109 | |
| 110 | def parsebytes(self, text, headersonly=False): |
| 111 | """Create a message structure from a byte string. |
| 112 | |
| 113 | Returns the root of the message structure. Optional headersonly is a |
| 114 | flag specifying whether to stop parsing after reading the headers or |
| 115 | not. The default is False, meaning it parses the entire contents of |
| 116 | the file. |
| 117 | """ |
| 118 | text = text.decode('ASCII', errors='surrogateescape') |
| 119 | return self.parser.parsestr(text, headersonly) |
| 120 | |
| 121 | |
| 122 | class BytesHeaderParser(BytesParser): |