Skip to content

Commit b27213b

Browse files
committed
Move httpStatusCodes, httpMethods and Url within top-level proxy.http package
1 parent da2a1b2 commit b27213b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+98
-58
lines changed

examples/https_connect_tunnel.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
from proxy import Proxy
1616
from proxy.common.utils import build_http_response
17-
from proxy.http.parser import httpParserStates, httpStatusCodes
17+
from proxy.http import httpStatusCodes
18+
from proxy.http.parser import httpParserStates
1819
from proxy.core.base import BaseTcpTunnelHandler
1920

2021

proxy/common/pki.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
:copyright: (c) 2013-present by Abhinav Singh and contributors.
99
:license: BSD, see LICENSE for more details.
1010
"""
11-
import time
11+
import os
1212
import sys
13+
import uuid
14+
import time
15+
import logging
16+
import tempfile
1317
import argparse
1418
import contextlib
15-
import os
16-
import uuid
1719
import subprocess
18-
import tempfile
19-
import logging
20+
2021
from typing import List, Generator, Optional, Tuple
2122

2223
from .utils import bytes_

proxy/core/connection/client.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
:copyright: (c) 2013-present by Abhinav Singh and contributors.
99
:license: BSD, see LICENSE for more details.
1010
"""
11-
import socket
1211
import ssl
12+
import socket
13+
1314
from typing import Union, Tuple, Optional
1415

1516
from .connection import TcpConnection, TcpConnectionUninitializedException

proxy/core/connection/connection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
:copyright: (c) 2013-present by Abhinav Singh and contributors.
99
:license: BSD, see LICENSE for more details.
1010
"""
11-
import socket
1211
import ssl
12+
import socket
1313
import logging
1414

1515
from abc import ABC, abstractmethod

proxy/core/connection/pool.py

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from typing import Set, Dict, Tuple
1414

1515
from ...common.flag import flags
16+
1617
from .server import TcpServerConnection
1718

1819
logger = logging.getLogger(__name__)

proxy/core/connection/types.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
('CLIENT', int),
1818
],
1919
)
20+
2021
tcpConnectionTypes = TcpConnectionTypes(1, 2)

proxy/dashboard/dashboard.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
from .plugin import ProxyDashboardWebsocketPlugin
1717

1818
from ..common.utils import build_http_response, bytes_
19-
from ..http.server import HttpWebServerPlugin, HttpWebServerBasePlugin, httpProtocolTypes
20-
from ..http.parser import HttpParser, httpStatusCodes
19+
20+
from ..http import httpStatusCodes
21+
from ..http.parser import HttpParser
2122
from ..http.websocket import WebsocketFrame
23+
from ..http.server import HttpWebServerPlugin, HttpWebServerBasePlugin, httpProtocolTypes
2224

2325
logger = logging.getLogger(__name__)
2426

proxy/http/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@
1010
"""
1111
from .handler import HttpProtocolHandler
1212
from .plugin import HttpProtocolHandlerPlugin
13+
from .codes import httpStatusCodes
14+
from .methods import httpMethods
15+
from .url import Url
1316

1417
__all__ = [
1518
'HttpProtocolHandler',
1619
'HttpProtocolHandlerPlugin',
20+
'httpStatusCodes',
21+
'httpMethods',
22+
'Url',
1723
]
File renamed without changes.

proxy/http/exception/proxy_auth_failed.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
:license: BSD, see LICENSE for more details.
1010
"""
1111
from .base import HttpProtocolException
12-
from ..parser import HttpParser, httpStatusCodes
12+
13+
from ..codes import httpStatusCodes
14+
from ..parser import HttpParser
1315

1416
from ...common.constants import PROXY_AGENT_HEADER_VALUE, PROXY_AGENT_HEADER_KEY
1517
from ...common.utils import build_http_response

proxy/http/exception/proxy_conn_failed.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
:license: BSD, see LICENSE for more details.
1010
"""
1111
from .base import HttpProtocolException
12-
from ..parser import HttpParser, httpStatusCodes
12+
13+
from ..codes import httpStatusCodes
14+
from ..parser import HttpParser
1315

1416
from ...common.constants import PROXY_AGENT_HEADER_VALUE, PROXY_AGENT_HEADER_KEY
1517
from ...common.utils import build_http_response

proxy/http/handler.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
:copyright: (c) 2013-present by Abhinav Singh and contributors.
99
:license: BSD, see LICENSE for more details.
1010
"""
11-
import socket
12-
import selectors
1311
import ssl
1412
import time
15-
import contextlib
1613
import errno
14+
import socket
1715
import logging
16+
import selectors
17+
import contextlib
1818

1919
from typing import Tuple, List, Union, Optional, Generator, Dict, Any
2020

proxy/http/parser/methods.py renamed to proxy/http/methods.py

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
('PATCH', bytes),
2525
],
2626
)
27+
2728
httpMethods = HttpMethods(
2829
b'GET',
2930
b'HEAD',

proxy/http/parser/__init__.py

-6
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
"""
1111
from .parser import HttpParser
1212
from .chunk import ChunkParser, chunkParserStates
13-
from .codes import httpStatusCodes
14-
from .methods import httpMethods
1513
from .types import httpParserStates, httpParserTypes
16-
from .url import Url
1714
from .protocol import ProxyProtocol, PROXY_PROTOCOL_V2_SIGNATURE
1815

1916
__all__ = [
@@ -22,9 +19,6 @@
2219
'httpParserStates',
2320
'ChunkParser',
2421
'chunkParserStates',
25-
'httpStatusCodes',
26-
'httpMethods',
27-
'Url',
2822
'ProxyProtocol',
2923
'PROXY_PROTOCOL_V2_SIGNATURE',
3024
]

proxy/http/parser/parser.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
from ...common.utils import build_http_request, build_http_response, find_http_line, text_
1717
from ...common.flag import flags
1818

19-
from .url import Url
20-
from .methods import httpMethods
19+
from ..url import Url
20+
from ..methods import httpMethods
21+
2122
from .protocol import ProxyProtocol
2223
from .chunk import ChunkParser, chunkParserStates
2324
from .types import httpParserTypes, httpParserStates

proxy/http/parser/protocol.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
:license: BSD, see LICENSE for more details.
1010
"""
1111
from typing import Optional, Tuple
12+
1213
from ...common.constants import WHITESPACE
1314

1415
PROXY_PROTOCOL_V2_SIGNATURE = b'\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A'

proxy/http/plugin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
:copyright: (c) 2013-present by Abhinav Singh and contributors.
99
:license: BSD, see LICENSE for more details.
1010
"""
11-
import argparse
1211
import socket
12+
import argparse
1313

14-
from abc import ABC, abstractmethod
1514
from uuid import UUID
15+
from abc import ABC, abstractmethod
1616
from typing import Tuple, List, Union, Optional
1717

1818
from .parser import HttpParser

proxy/http/proxy/auth.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from typing import Optional
1212

1313
from ..exception import ProxyAuthenticationFailed
14+
1415
from ...common.flag import flags
1516
from ...common.constants import DEFAULT_BASIC_AUTH
1617
from ...http.parser import HttpParser

proxy/http/proxy/plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
import socket
1212
import argparse
1313

14+
from abc import ABC
1415
from uuid import UUID
1516
from typing import Any, Dict, List, Optional, Tuple
16-
from abc import ABC, abstractmethod
1717

1818
from ..parser import HttpParser
1919

proxy/http/proxy/server.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020
from typing import Optional, List, Union, Dict, cast, Any, Tuple
2121

2222
from .plugin import HttpProxyBasePlugin
23+
24+
from ..methods import httpMethods
25+
from ..codes import httpStatusCodes
2326
from ..plugin import HttpProtocolHandlerPlugin
2427
from ..exception import HttpProtocolException, ProxyConnectionFailed
25-
from ..parser import HttpParser, httpParserStates, httpParserTypes, httpStatusCodes, httpMethods
28+
from ..parser import HttpParser, httpParserStates, httpParserTypes
2629

2730
from ...common.types import Readables, Writables
2831
from ...common.constants import DEFAULT_CA_CERT_DIR, DEFAULT_CA_CERT_FILE, DEFAULT_CA_FILE

proxy/http/server/pac_plugin.py

+3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
:license: BSD, see LICENSE for more details.
1010
"""
1111
import gzip
12+
1213
from typing import List, Tuple, Optional, Any
1314

1415
from .plugin import HttpWebServerBasePlugin
1516
from .protocols import httpProtocolTypes
17+
1618
from ..websocket import WebsocketFrame
1719
from ..parser import HttpParser
20+
1821
from ...common.utils import bytes_, text_, build_http_response
1922
from ...common.flag import flags
2023
from ...common.constants import DEFAULT_PAC_FILE, DEFAULT_PAC_FILE_URL_PATH

proxy/http/server/plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
import socket
1212
import argparse
1313

14+
from uuid import UUID
1415
from abc import ABC, abstractmethod
1516
from typing import Any, Dict, List, Optional, Tuple
16-
from uuid import UUID
1717

1818
from ..websocket import WebsocketFrame
1919
from ..parser import HttpParser

proxy/http/server/protocols.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
('WEBSOCKET', int),
1818
],
1919
)
20+
2021
httpProtocolTypes = HttpProtocolTypes(1, 2, 3)

proxy/http/server/web.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
from ...common.types import Readables, Writables
2525
from ...common.flag import flags
2626

27+
from ..codes import httpStatusCodes
2728
from ..exception import HttpProtocolException
28-
from ..websocket import WebsocketFrame, websocketOpcodes
29-
from ..parser import HttpParser, httpParserStates, httpParserTypes, httpStatusCodes
3029
from ..plugin import HttpProtocolHandlerPlugin
30+
from ..websocket import WebsocketFrame, websocketOpcodes
31+
from ..parser import HttpParser, httpParserStates, httpParserTypes
3132

3233
from .plugin import HttpWebServerBasePlugin
3334
from .protocols import httpProtocolTypes

proxy/http/parser/url.py renamed to proxy/http/url.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"""
1111
from typing import Optional, Tuple
1212

13-
from ...common.constants import COLON, SLASH
13+
from ..common.constants import COLON, SLASH
1414

1515

1616
class Url:

proxy/http/websocket/client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
:copyright: (c) 2013-present by Abhinav Singh and contributors.
99
:license: BSD, see LICENSE for more details.
1010
"""
11+
import ssl
1112
import base64
12-
import selectors
1313
import socket
1414
import secrets
15-
import ssl
15+
import selectors
1616

1717
from typing import Optional, Union, Callable
1818

proxy/http/websocket/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
:copyright: (c) 2013-present by Abhinav Singh and contributors.
99
:license: BSD, see LICENSE for more details.
1010
"""
11+
import io
1112
import hashlib
1213
import base64
1314
import struct
1415
import secrets
1516
import logging
16-
import io
1717

1818
from typing import TypeVar, Type, Optional, NamedTuple
1919

proxy/plugin/filter_by_client_ip.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
from typing import Optional
1212

1313
from ..common.flag import flags
14-
from ..http.exception import HttpRequestRejected
15-
from ..http.parser import HttpParser, httpStatusCodes
14+
15+
from ..http import httpStatusCodes
16+
from ..http.parser import HttpParser
1617
from ..http.proxy import HttpProxyBasePlugin
18+
from ..http.exception import HttpRequestRejected
1719

1820

1921
flags.add_argument(

proxy/plugin/filter_by_upstream.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212

1313
from ..common.utils import text_
1414
from ..common.flag import flags
15-
from ..http.exception import HttpRequestRejected
16-
from ..http.parser import HttpParser, httpStatusCodes
15+
16+
from ..http import httpStatusCodes
17+
from ..http.parser import HttpParser
1718
from ..http.proxy import HttpProxyBasePlugin
19+
from ..http.exception import HttpRequestRejected
1820

1921

2022
flags.add_argument(

proxy/plugin/filter_by_url_regex.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
from typing import Optional, List, Dict, Any
1515

1616
from ..common.flag import flags
17-
from ..http.exception import HttpRequestRejected
18-
from ..http.parser import HttpParser, httpStatusCodes
19-
from ..http.proxy import HttpProxyBasePlugin
2017
from ..common.utils import text_
2118

19+
from ..http import httpStatusCodes
20+
from ..http.parser import HttpParser
21+
from ..http.proxy import HttpProxyBasePlugin
22+
from ..http.exception import HttpRequestRejected
23+
2224
import re
2325

2426
logger = logging.getLogger(__name__)

proxy/plugin/man_in_the_middle.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
:copyright: (c) 2013-present by Abhinav Singh and contributors.
99
:license: BSD, see LICENSE for more details.
1010
"""
11-
from typing import Optional
12-
1311
from ..common.utils import build_http_response
14-
from ..http.parser import httpStatusCodes
12+
from ..http import httpStatusCodes
1513
from ..http.proxy import HttpProxyBasePlugin
1614

1715

proxy/plugin/mock_rest_api.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
from typing import Optional
1313

1414
from ..common.utils import bytes_, build_http_response, text_
15-
from ..http.parser import HttpParser, httpStatusCodes
15+
16+
from ..http import httpStatusCodes
17+
from ..http.parser import HttpParser
1618
from ..http.proxy import HttpProxyBasePlugin
1719

1820

proxy/plugin/modify_post_data.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
from typing import Optional
1212

1313
from ..common.utils import bytes_
14-
from ..http.parser import HttpParser, httpMethods
14+
15+
from ..http import httpMethods
16+
from ..http.parser import HttpParser
1517
from ..http.proxy import HttpProxyBasePlugin
1618

1719

0 commit comments

Comments
 (0)