Parse PROXY protocol header if enabled. Returns True if parsing is complete (or not applicable), False if more data is needed.
(self)
| 260 | self._on_message_complete() |
| 261 | |
| 262 | def _parse_proxy_protocol(self): |
| 263 | """Parse PROXY protocol header if enabled. |
| 264 | |
| 265 | Returns True if parsing is complete (or not applicable), |
| 266 | False if more data is needed. |
| 267 | """ |
| 268 | # Need at least 12 bytes to detect v2 signature or check for v1 prefix |
| 269 | if len(self._buffer) < 12: |
| 270 | return False |
| 271 | |
| 272 | mode = self._proxy_protocol |
| 273 | |
| 274 | # Check for v2 signature first |
| 275 | if mode in ('v2', 'auto') and self._buffer[:12] == PP_V2_SIGNATURE: |
| 276 | return self._parse_proxy_protocol_v2() |
| 277 | |
| 278 | # Check for v1 prefix |
| 279 | if mode in ('v1', 'auto') and self._buffer[:6] == b'PROXY ': |
| 280 | return self._parse_proxy_protocol_v1() |
| 281 | |
| 282 | # Not proxy protocol - continue with normal parsing |
| 283 | self._proxy_protocol_done = True |
| 284 | self._state = 'request_line' |
| 285 | return True |
| 286 | |
| 287 | def _parse_proxy_protocol_v1(self): |
| 288 | """Parse PROXY protocol v1 (text format). |
no test coverage detected