module documentation
Tools for pedantically processing the HTTP protocol.
| Function | _decint |
Parse a decimal integer of the form 1*DIGIT, i.e. consisting only of decimal digits. The integer may be embedded in whitespace (space and horizontal tab). This differs from the built-in int() function by disallowing a leading ... |
| Function | _hexint |
Decode a hexadecimal integer. |
| Function | _ishexdigits |
Is the string case-insensitively hexidecimal? |
| Function | _istoken |
Is the string a token per RFC 9110 section 5.6.2? |
Parse a decimal integer of the form 1*DIGIT, i.e. consisting only of decimal digits. The integer may be embedded in whitespace (space and horizontal tab). This differs from the built-in int() function by disallowing a leading + character and various forms of whitespace (note that we sanitize linear whitespace in header values in twisted.web.http_headers.Headers).
| Parameters | |
data:bytes | Value to parse. |
| Returns | |
int | A non-negative integer. |
| Raises | |
ValueError | When value contains non-decimal characters. |
Decode a hexadecimal integer.
Unlike int(b, 16), this raises ValueError when the integer has a prefix like b'0x', b'+', or b'-', which is desirable when parsing network protocols.