Skip to content
Myr

Use full URL when contacting proxies.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Requests should use the full URL, not the path URL, when forwarding traffic through proxies.

authored by Cory Benfield · committed by Cory Benfield · parent b479a62 · Browse files · 1 file+19 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+19 added−2 removed

  • other:+19 added−2 removed

1 file+19 added−2 removed

modified:requests/adapters.py+19 added-2 removed
11 unmodified lines
1213from .models import Response14from .packages.urllib3.poolmanager import PoolManager, proxy_from_url15from .hooks import dispatch_hook16from .compat import urlparse, basestring16from .compat import urlparse, basestring, urldefrag17from .utils import DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers18from .structures import CaseInsensitiveDict19from .packages.urllib3.exceptions import MaxRetryError20from .packages.urllib3.exceptions import TimeoutError
108 unmodified lines
129 connections.130 """131 self.poolmanager.clear()132133 def request_url(self, request, proxies):134 """Obtain the url to use when making the final request.135136 If the message is being sent through a proxy, the full URL has to be137 used. Otherwise, we should only use the path portion of the URL."""138 proxies = proxies or {}139 proxy = proxies.get(urlparse(request.url).scheme)140141 if proxy:142 url, _ = urldefrag(request.url)143 else:144 url = request.path_url145146 return url147148 def send(self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None):149 """Sends PreparedRequest object. Returns Response object."""150151 conn = self.get_connection(request.url, proxies)152153 self.cert_verify(conn, request.url, verify, cert)154155 url = self.request_url(request, proxies)156157 try:158 # Send the request.159 resp = conn.urlopen(160 method=request.method,144 url=request.path_url,161 url=url,162 body=request.body,163 headers=request.headers,164 redirect=False,165 assert_same_host=False,
26 unmodified lines