fix: apply the session-level proxy when no per-request proxy is given
The per-request proxy resolution never fell back to the session default, so FetcherSession(proxy=...) was silently ignored, and requests went direct. Same fix in the sync and async paths, with regression tests asserting on the proxy that reaches curl_cffi. Closes #295
This commit is contained in:
@@ -19,6 +19,7 @@ from scrapling.core._types import (
|
||||
Unpack,
|
||||
Optional,
|
||||
Awaitable,
|
||||
ProxyType,
|
||||
SUPPORTED_HTTP_METHODS,
|
||||
FollowRedirects,
|
||||
)
|
||||
@@ -244,10 +245,11 @@ class _SyncSessionLogic(_ConfigurationLogic):
|
||||
|
||||
try:
|
||||
for attempt in range(max_retries):
|
||||
proxy: Optional[ProxyType]
|
||||
if self._proxy_rotator and static_proxy is None:
|
||||
proxy = self._proxy_rotator.get_proxy()
|
||||
else:
|
||||
proxy = static_proxy
|
||||
proxy = static_proxy or self._default_proxy
|
||||
|
||||
request_args = self._merge_request_args(stealth=stealth, proxy=proxy, **kwargs)
|
||||
try:
|
||||
@@ -461,10 +463,11 @@ class _ASyncSessionLogic(_ConfigurationLogic):
|
||||
try:
|
||||
# Determine if we should use proxy rotation
|
||||
for attempt in range(max_retries):
|
||||
proxy: Optional[ProxyType]
|
||||
if self._proxy_rotator and static_proxy is None:
|
||||
proxy = self._proxy_rotator.get_proxy()
|
||||
else:
|
||||
proxy = static_proxy
|
||||
proxy = static_proxy or self._default_proxy
|
||||
|
||||
request_args = self._merge_request_args(stealth=stealth, proxy=proxy, **kwargs)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user