Skip to content
Myr

Only send URL path to servers

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

Closes #256

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 2ccc68c · Browse files · 1 file+37 added−12 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+37 added−12 removed

  • other:+37 added−12 removed

1 file+37 added−12 removed

modified:requests/models.py+37 added-12 removed
9 unmodified lines
10import urllib11import zlib1213from Cookie import SimpleCookie14from urlparse import urlparse, urlunparse, urljoin14from urlparse import urlparse, urlunparse, urljoin, urlsplit15from datetime import datetime1617from .auth import dispatch as auth_dispatch18from .hooks import dispatch_hook
161 unmodified lines
180181 if is_error:182 response.error = resp183184 response.url = self._build_url()184 response.url = self.full_url185186 return response187188
91 unmodified lines
280 return result, urllib.urlencode(result, doseq=True)281 else:282 return data, data283284285 def _build_url(self):284 @property285 def full_url(self):286 """Build the actual URL to use."""287288 if not self.url:289 raise URLRequired()
9 unmodified lines
299 if isinstance(path, unicode):300 path = path.encode('utf-8')301302 path = urllib.quote(urllib.unquote(path))303 self.url = str(urlunparse([ scheme, netloc, path, params, query, fragment ]))303304 url = str(urlunparse([ scheme, netloc, path, params, query, fragment ]))305306 if self._enc_params:306 if urlparse(self.url).query:307 return '%s&%s' % (self.url, self._enc_params)307 if urlparse(url).query:308 return '%s&%s' % (url, self._enc_params)309 else:309 return '%s?%s' % (self.url, self._enc_params)310 return '%s?%s' % (url, self._enc_params)311 else:311 return self.url312 return url313314 @property315 def path_url(self):316 """Build the path URL to use."""317318 url = []319320 p = urlsplit(self.full_url)321322 # Proxies use full URLs.323 if p.scheme in self.proxies:324 return self.full_url325326 path = p.path327 if not path:328 path = '/'329 url.append(path)330331 query = p.query332 if query:333 url.append('?')334 url.append(query)335336 return ''.join(url)337338339340 def send(self, anyway=False, prefetch=False):341 """Sends the request. Returns True of successful, false if not.342 If there was an HTTPError during transmission,343 self.response.status_code will contain the HTTPError code.
10 unmodified lines
354 datetime.now().isoformat(), self.method, self.url355 ))356357 # Build the URL332 url = self._build_url()358 url = self.full_url359360 # Nottin' on you.361 body = None362 content_type = None
68 unmodified lines
431 self.headers['Cookie'] = cookie_header432433 try:434 # Send the request.409435 r = conn.urlopen(436 method=self.method,412 url=url,437 url=self.path_url,438 body=body,439 headers=self.headers,440 redirect=False,441 assert_same_host=False,
177 unmodified lines