proxy.http.parser package#
Submodules#
Module contents#
proxy.py#
⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on Network monitoring, controls & Application development, testing, debugging.
- copyright
2013-present by Abhinav Singh and contributors.
- license
BSD, see LICENSE for more details.
- class proxy.http.parser.ChunkParser[source]#
Bases:
object
HTTP chunked encoding response parser.
- parse(raw: memoryview) memoryview [source]#
- process(raw: bytes) Tuple[bool, memoryview] [source]#
- class proxy.http.parser.HttpParser(parser_type: int, enable_proxy_protocol: int = False)[source]#
Bases:
object
HTTP request/response parser.
TODO: Make me zero-copy by using
memoryview
. Currently due to chunk/buffer handling we are not able to utilizememoryview
efficiently.For this to happen we must store
buffer
asList[memoryview]
instead of raw bytes and update parser to work accordingly.- _process_body(raw: memoryview) Tuple[bool, memoryview] [source]#
- _process_headers(raw: memoryview) Tuple[bool, memoryview] [source]#
Returns False when no CRLF could be found in received bytes.
TODO: We should not return until parser reaches headers complete state or when there is no more data left to parse.
TODO: For protection against Slowloris attack, we must parse the request line and headers only after receiving end of header marker. This will also help make the parser even more stateless.
- _process_line(raw: memoryview, allowed_url_schemes: Optional[List[bytes]] = None) Tuple[bool, memoryview] [source]#
- add_header(key: bytes, value: bytes) bytes [source]#
Add/Update a header to internal data structure.
Returns key with which passed (key, value) tuple is available.
- add_headers(headers: List[Tuple[bytes, bytes]]) None [source]#
Add/Update multiple headers to internal data structure
- build(disable_headers: Optional[List[bytes]] = None, for_proxy: bool = False) bytes [source]#
Rebuild the request object.
- header(key: bytes) bytes [source]#
Convenient method to return original header value from internal data structure.
- property http_handler_protocol: int#
Returns
HttpProtocols
that this request belongs to.
- parse(raw: memoryview, allowed_url_schemes: Optional[List[bytes]] = None) None [source]#
Parses HTTP request out of raw bytes.
Check for
HttpParser.state
afterparse
has successfully returned.
- classmethod request(raw: bytes, enable_proxy_protocol: int = False) proxy.http.parser.parser.T [source]#