-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Copy of #2582, Added proxy parameters for ClientSession #3405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| Yusuke Tsutsumi | ||
| Марк Коренберг | ||
| Семён Марьясин | ||
| Семён Марьясин No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is unrelated. Fix your editor to preserve original EOF.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aiohttp/client.py
Outdated
| version = self._version | ||
|
|
||
| # Merge with session proxy | ||
| proxy = self._proxy_info['proxy'] \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use brackets instead of escaping EOL
|
Not sure if I like yet another params in ClientSession constructor. Anyway, the biggest showstopper now is proxy tests. |
|
@asvetlov I am thinking about sending a separate PR with test proxy server and new tests. |
|
@webknjaz I am unable to solve the issue with mypy I have not used mypy before, can you guide me through that I have done wrong ? |
|
So the errors are: aiohttp/client.py:293: error: Incompatible types in assignment (expression has type "Union[str, URL, None, BasicAuth, Mapping[str, str]]", variable has type "Union[str, URL, None]")
aiohttp/client.py:296: error: Incompatible types in assignment (expression has type "Union[str, URL, None, BasicAuth, Mapping[str, str]]", variable has type "Optional[BasicAuth]")
aiohttp/client.py:299: error: Incompatible types in assignment (expression has type "Union[str, URL, None, BasicAuth, Mapping[str, str]]", variable has type "Union[Mapping[str, str], CIMultiDict[str], CIMultiDictProxy[str], None]")Let's look at the first one. The statement (partially) is proxy = self._proxy_info['proxy']So it says proxy: Optional[StrOrURL]=sentinel,you declared that allowed types for data to assign to the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
asvetlov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please reserve merge conflicts
- Docs update is needed.
- @webknjaz asked for changes, not all comments are addressed as I see.
proxy_test_server implementation suggestion:
In my mind the server fixture proxies requests to the app.
Why not pass a app server to the fixture to check the proxy? It can get rid of mocks in tests.
docs/client_reference.rst
Outdated
| connector_owner=True, \ | ||
| auto_decompress=True, proxies=None) | ||
| auto_decompress=True, \ | ||
| proxy=None, proxy_auth=None, proxy_headers=None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document these params, not only enumerate in constructor signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have documented these changes.
| if proxy is None and self._session_proxy is not None: | ||
| try: | ||
| proxy = self._session_proxy | ||
| proxy_auth = self._session_proxy_auth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By this line you are overriding explicitly passed proxy_auth and proxy_headers arguments with session default ones.
I have no idea how to resolve the conflict properly but proposed behavior looks confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am trying to use session proxy if proxy is not mentioned explicitly for a particular request.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Hey @RatanShreshtha, this PR needs updating |
|
@webknjaz let me update the PR |
| Eugene Naydenov | ||
| Eugene Tolmachev | ||
| Evert Lammerts | ||
| Fan Yu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz clean-up all unrelated changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I squash all the changes ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to you. We'll use "Merge and squash" strategy on this PR anyway :)
asvetlov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, please address my comment
| skip_headers.add(istr(i)) | ||
|
|
||
| if proxy is not None: | ||
| if proxy is not None and self._session_proxy is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the behavior if proxy is not None and self._session_proxy is not None?
I think passed proxy parameter should take precedence.
Added proxy parameters for ClientSession so that subsequent requests can use the session proxy.
Are there changes in behavior for the user?
New parameters of ClientSession():
Related issue number
#2580
#2582
Checklist
CONTRIBUTORS.txtCHANGESfolder<issue_id>.<type>for example (588.bugfix)issue_idchange it to the pr id after creating the pr.feature: Signifying a new feature..bugfix: Signifying a bug fix..doc: Signifying a documentation improvement..removal: Signifying a deprecation or removal of public API..misc: A ticket has been closed, but it is not of interest to users.