2019-12-02 06:46:00 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
proxy.py
|
|
|
|
~~~~~~~~
|
|
|
|
⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on
|
|
|
|
Network monitoring, controls & Application development, testing, debugging.
|
|
|
|
|
|
|
|
:copyright: (c) 2013-present by Abhinav Singh and contributors.
|
|
|
|
:license: BSD, see LICENSE for more details.
|
2021-11-16 23:34:29 +00:00
|
|
|
|
|
|
|
.. spelling::
|
|
|
|
|
|
|
|
http
|
2019-12-02 06:46:00 +00:00
|
|
|
"""
|
2021-12-22 03:50:06 +00:00
|
|
|
from typing import Any, Optional, TYPE_CHECKING
|
2019-12-02 06:46:00 +00:00
|
|
|
|
2022-01-14 09:43:14 +00:00
|
|
|
if TYPE_CHECKING: # pragma: no cover
|
2021-12-21 23:54:31 +00:00
|
|
|
from ..parser import HttpParser
|
2019-12-02 06:46:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
class HttpProtocolException(Exception):
|
2021-11-16 23:34:29 +00:00
|
|
|
"""Top level :exc:`HttpProtocolException` exception class.
|
2019-12-02 06:46:00 +00:00
|
|
|
|
2021-11-16 23:34:29 +00:00
|
|
|
All exceptions raised during execution of HTTP request lifecycle MUST
|
|
|
|
inherit :exc:`HttpProtocolException` base class. Implement
|
|
|
|
``response()`` method to optionally return custom response to client.
|
|
|
|
"""
|
2019-12-02 06:46:00 +00:00
|
|
|
|
2021-12-22 03:50:06 +00:00
|
|
|
def __init__(self, message: Optional[str] = None, **kwargs: Any) -> None:
|
|
|
|
super().__init__(message or 'Reason unknown')
|
|
|
|
|
2021-12-21 23:54:31 +00:00
|
|
|
def response(self, request: 'HttpParser') -> Optional[memoryview]:
|
2019-12-02 06:46:00 +00:00
|
|
|
return None # pragma: no cover
|