Parse a token from ``header`` at the given position. Return the token value and the new position. Raises: InvalidHeaderFormat: On invalid inputs.
(header: str, pos: int, header_name: str)
| 104 | |
| 105 | |
| 106 | def parse_token(header: str, pos: int, header_name: str) -> tuple[str, int]: |
| 107 | """ |
| 108 | Parse a token from ``header`` at the given position. |
| 109 | |
| 110 | Return the token value and the new position. |
| 111 | |
| 112 | Raises: |
| 113 | InvalidHeaderFormat: On invalid inputs. |
| 114 | |
| 115 | """ |
| 116 | match = _token_re.match(header, pos) |
| 117 | if match is None: |
| 118 | raise InvalidHeaderFormat(header_name, "expected token", header, pos) |
| 119 | return match.group(), match.end() |
| 120 | |
| 121 | |
| 122 | _quoted_string_re = re.compile( |
no test coverage detected
searching dependent graphs…