Skip to content

Commit

Permalink
fix support for socks proxy in python version <3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
realgam3 committed Jan 8, 2024
1 parent 06c4e1a commit da9b1eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions requests_raw/__version__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
__title__ = 'requests-raw'
__description__ = 'HTTP communication through raw sockets using requests for RFC compliance testing'
__url__ = 'https://github.com/realgam3/requests-raw'
__version__ = '2.0.1'
__build__ = 0x020001
__version__ = '2.0.2'
__build__ = 0x020002
__author__ = 'Tomer Zait (realgam3)'
__author_email__ = '[email protected]'
__license__ = 'Apache 2.0'
Expand Down
22 changes: 15 additions & 7 deletions requests_raw/socks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

try:
import socks # type: ignore[import]
except ImportError:
Expand All @@ -22,13 +24,19 @@
from .connectionpool import RawHTTPConnectionPool, RawHTTPSConnectionPool


class _TYPE_SOCKS_OPTIONS(typing.TypedDict):
socks_version: int
proxy_host: str | None
proxy_port: str | None
username: str | None
password: str | None
rdns: bool
try:
from typing import TypedDict

class _TYPE_SOCKS_OPTIONS(TypedDict):
socks_version: int
proxy_host: str | None
proxy_port: str | None
username: str | None
password: str | None
rdns: bool

except ImportError: # Python 3.7
_TYPE_SOCKS_OPTIONS = typing.Dict[str, typing.Any] # type: ignore[misc, assignment]


class RawSOCKSConnection(SOCKSConnection, RawHTTPConnection):
Expand Down

0 comments on commit da9b1eb

Please sign in to comment.