Skip to content

Commit 45ad531

Browse files
authored
Merge pull request #136 from autoscrape-labs/fix/private-proxy
fix: private proxy not working
2 parents 5ccafbf + 5d6a38e commit 45ad531

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

pydoll/browser/chromium/base.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
DownloadBehavior,
2525
NetworkErrorReason,
2626
PermissionType,
27+
ResourceType,
2728
)
2829
from pydoll.exceptions import BrowserNotRunning, FailedToStartBrowser, NoValidTabFound
29-
from pydoll.protocol.base import Command
30+
from pydoll.protocol.base import Command, Response
3031
from pydoll.protocol.browser.responses import (
3132
GetVersionResponse,
3233
GetVersionResultDict,
@@ -367,7 +368,9 @@ async def callback_wrapper(event):
367368
)
368369

369370
async def enable_fetch_events(
370-
self, handle_auth_requests: bool = False, resource_type: str = ''
371+
self,
372+
handle_auth_requests: bool = False,
373+
resource_type: Optional[ResourceType] = None,
371374
):
372375
"""
373376
Enable network request interception via Fetch domain.
@@ -383,7 +386,10 @@ async def enable_fetch_events(
383386
Paused requests must be continued or they will timeout.
384387
"""
385388
return await self._connection_handler.execute_command(
386-
FetchCommands.enable(handle_auth_requests, resource_type)
389+
FetchCommands.enable(
390+
handle_auth_requests=handle_auth_requests,
391+
resource_type=resource_type,
392+
)
387393
)
388394

389395
async def disable_fetch_events(self):
@@ -444,15 +450,16 @@ async def _continue_request_with_auth_callback(
444450
):
445451
"""Internal callback for proxy authentication."""
446452
request_id = event['params']['requestId']
447-
await self.disable_fetch_events()
448-
return await self._execute_command(
453+
response: Response = await self._execute_command(
449454
FetchCommands.continue_request_with_auth(
450455
request_id,
451456
auth_challenge_response=AuthChallengeResponseValues.PROVIDE_CREDENTIALS,
452457
proxy_username=proxy_username,
453458
proxy_password=proxy_password,
454459
)
455460
)
461+
await self.disable_fetch_events()
462+
return response
456463

457464
async def _verify_browser_running(self):
458465
"""

tests/test_browser/test_browser_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async def test_proxy_configuration(mock_browser):
118118
await mock_browser.start()
119119

120120
mock_browser._connection_handler.execute_command.assert_any_call(
121-
FetchCommands.enable(True, '')
121+
FetchCommands.enable(handle_auth_requests=True, resource_type=None)
122122
)
123123
mock_browser._connection_handler.register_callback.assert_any_call(
124124
FetchEvent.REQUEST_PAUSED, ANY, True
@@ -257,7 +257,7 @@ async def test_enable_events(mock_browser):
257257
handle_auth_requests=True, resource_type='XHR'
258258
)
259259
mock_browser._connection_handler.execute_command.assert_called_with(
260-
FetchCommands.enable(True, 'XHR')
260+
FetchCommands.enable(handle_auth_requests=True, resource_type='XHR')
261261
)
262262

263263

0 commit comments

Comments
 (0)