Skip to content

Commit

Permalink
Adding host details in proxy headers
Browse files Browse the repository at this point in the history
  • Loading branch information
harikrishnan925 committed Jan 3, 2025
1 parent 23540c9 commit f280f8a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/requests/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ def proxy_manager_for(self, proxy, **proxy_kwargs):
)
else:
proxy_headers = self.proxy_headers(proxy)
if 'host' in proxy_kwargs and proxy_kwargs['host']:
proxy_headers['host'] = f"{proxy_kwargs['host']}"
manager = self.proxy_manager[proxy] = proxy_from_url(
proxy,
proxy_headers=proxy_headers,
Expand Down Expand Up @@ -480,7 +482,9 @@ def get_connection_with_tls_context(self, request, verify, proxies=None, cert=No
"Please check proxy URL. It is malformed "
"and could be missing the host."
)
proxy_manager = self.proxy_manager_for(proxy)
u = parse_url(request.url)
host=u.host
proxy_manager = self.proxy_manager_for(proxy, host=host)
conn = proxy_manager.connection_from_host(
**host_params, pool_kwargs=pool_kwargs
)
Expand Down

0 comments on commit f280f8a

Please sign in to comment.