Get appropriate parser based on protocol config. Args: cfg: Gunicorn config object source: Socket or iterable source source_addr: Source address tuple or None http2_connection: If True, create HTTP/2 connection handler Returns: Parser instance (Reque
(cfg, source, source_addr, http2_connection=False)
| 7 | |
| 8 | |
| 9 | def get_parser(cfg, source, source_addr, http2_connection=False): |
| 10 | """Get appropriate parser based on protocol config. |
| 11 | |
| 12 | Args: |
| 13 | cfg: Gunicorn config object |
| 14 | source: Socket or iterable source |
| 15 | source_addr: Source address tuple or None |
| 16 | http2_connection: If True, create HTTP/2 connection handler |
| 17 | |
| 18 | Returns: |
| 19 | Parser instance (RequestParser, UWSGIParser, or HTTP2ServerConnection) |
| 20 | """ |
| 21 | # HTTP/2 connection |
| 22 | if http2_connection: |
| 23 | from gunicorn.http2.connection import HTTP2ServerConnection |
| 24 | return HTTP2ServerConnection(cfg, source, source_addr) |
| 25 | |
| 26 | # uWSGI protocol |
| 27 | protocol = getattr(cfg, 'protocol', 'http') |
| 28 | if protocol == 'uwsgi': |
| 29 | from gunicorn.uwsgi.parser import UWSGIParser |
| 30 | return UWSGIParser(cfg, source, source_addr) |
| 31 | |
| 32 | # Default HTTP/1.x |
| 33 | return RequestParser(cfg, source, source_addr) |
| 34 | |
| 35 | |
| 36 | __all__ = ['Message', 'Request', 'RequestParser', 'get_parser'] |
nothing calls this directly
no test coverage detected