summaryrefslogtreecommitdiffstats
path: root/g4f/requests
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-04-21 07:45:23 +0200
committerGitHub <noreply@github.com>2024-04-21 07:45:23 +0200
commit0f3935f1c068c723342153dd040e0e72e95aa11b (patch)
treec4d1e9c9eb2ebfe13e2679afe8a23d7ffa45fa46 /g4f/requests
parentMerge pull request #1865 from hlohaus/carst (diff)
parentAdd MissingRequirementsError to You (diff)
downloadgpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.tar
gpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.tar.gz
gpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.tar.bz2
gpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.tar.lz
gpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.tar.xz
gpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.tar.zst
gpt4free-0f3935f1c068c723342153dd040e0e72e95aa11b.zip
Diffstat (limited to '')
-rw-r--r--g4f/requests/aiohttp.py5
-rw-r--r--g4f/requests/defaults.py36
2 files changed, 25 insertions, 16 deletions
diff --git a/g4f/requests/aiohttp.py b/g4f/requests/aiohttp.py
index cdbedef3..4b629963 100644
--- a/g4f/requests/aiohttp.py
+++ b/g4f/requests/aiohttp.py
@@ -24,6 +24,7 @@ class StreamSession(ClientSession):
headers: dict = {},
timeout: int = None,
connector: BaseConnector = None,
+ proxy: str = None,
proxies: dict = {},
impersonate = None,
**kwargs
@@ -38,11 +39,13 @@ class StreamSession(ClientSession):
connect, timeout = timeout;
if timeout is not None:
timeout = ClientTimeout(timeout, connect)
+ if proxy is None:
+ proxy = proxies.get("all", proxies.get("https"))
super().__init__(
**kwargs,
timeout=timeout,
response_class=StreamResponse,
- connector=get_connector(connector, proxies.get("all", proxies.get("https"))),
+ connector=get_connector(connector, proxy),
headers=headers
)
diff --git a/g4f/requests/defaults.py b/g4f/requests/defaults.py
index 3183eb5a..739839af 100644
--- a/g4f/requests/defaults.py
+++ b/g4f/requests/defaults.py
@@ -1,21 +1,27 @@
+try:
+ import brotli
+ has_brotli = True
+except ImportError:
+ has_brotli = False
+
DEFAULT_HEADERS = {
- "sec-ch-ua": '"Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
- "sec-ch-ua-mobile": "?0",
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36",
- "ec-ch-ua-arch": '"x86"',
- "sec-ch-ua-full-version": '"122.0.6261.69"',
"accept": "*/*",
- "sec-ch-ua-platform-version:": '"6.5.0"',
- "sec-ch-ua-full-version-list": '"Chromium";v="122.0.6261.69", "Not(A:Brand";v="24.0.0.0", "Google Chrome";v="122.0.6261.69"',
- "sec-ch-ua-bitness": '"64"',
- "sec-ch-ua-model": '""',
- "sec-ch-ua-platform": '"Windows"',
- "sec-fetch-site": "same-site",
- "sec-fetch-mode": "cors",
- "sec-fetch-dest": "empty",
- "referer": "",
- "accept-encoding": "gzip, deflate, br",
+ "accept-encoding": "gzip, deflate" + (", br" if has_brotli else ""),
"accept-language": "en-US",
+ "referer": "",
+ "sec-ch-ua": "\"Google Chrome\";v=\"123\", \"Not:A-Brand\";v=\"8\", \"Chromium\";v=\"123\"",
+ "sec-ch-ua-arch": "\"x86\"",
+ "sec-ch-ua-bitness": "\"64\"",
+ "sec-ch-ua-full-version": "\"123.0.6312.122\"",
+ "sec-ch-ua-full-version-list": "\"Google Chrome\";v=\"123.0.6312.122\", \"Not:A-Brand\";v=\"8.0.0.0\", \"Chromium\";v=\"123.0.6312.122\"",
+ "sec-ch-ua-mobile": "?0",
+ "sec-ch-ua-model": "\"\"",
+ "sec-ch-ua-platform": "\"Windows\"",
+ "sec-ch-ua-platform-version": '"15.0.0"',
+ "sec-fetch-dest": "empty",
+ "sec-fetch-mode": "cors",
+ "sec-fetch-site": "same-origin",
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
}
WEBVIEW_HAEDERS = {
"Accept": "*/*",