Here are the examples of the python api requests.compat.urlparse taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
7 Examples
3
Example 1
Project: YCM_WIN_X86 Source File: test_requests.py
def test_mixed_case_scheme_acceptable(self):
s = requests.Session()
s.proxies = getproxies()
parts = urlparse(httpbin('get'))
schemes = ['http://', 'HTTP://', 'hTTp://', 'HttP://',
'https://', 'HTTPS://', 'hTTps://', 'HttPs://']
for scheme in schemes:
url = scheme + parts.netloc + parts.path
r = requests.Request('GET', url)
r = s.send(r.prepare())
assert r.status_code == 200, 'failed for scheme {0}'.format(scheme)
3
Example 2
Project: YCM_WIN_X86 Source File: test_requests.py
def test_uppercase_scheme_redirect(self):
parts = urlparse(httpbin('html'))
url = "HTTP://" + parts.netloc + parts.path
r = requests.get(httpbin('redirect-to'), params={'url': url})
assert r.status_code == 200
assert r.url.lower() == url.lower()
3
Example 3
def prepare_request(self, request):
p = urlparse(request.url)
# Rewrite the url to use foauth.org
request.url = FOAUTH_TEMPLATE.format(domain=p.netloc, path=p.path)
# Authenticate appropriately.
request.prepare_auth(self.auth)
return request
3
Example 4
Project: python-glanceclient Source File: https.py
def _create_glance_httpsconnectionpool(self, url):
kw = self.poolmanager.connection_pool_kw
# Parse the url to get the scheme, host, and port
parsed = compat.urlparse(url)
# If there is no port specified, we should use the standard HTTPS port
port = parsed.port or 443
host = parsed.netloc.rsplit(':', 1)[0]
pool = HTTPSConnectionPool(host, port, **kw)
with self.poolmanager.pools.lock:
self.poolmanager.pools[(parsed.scheme, host, port)] = pool
return pool
0
Example 5
Project: pulp Source File: adapters.py
def get_connection(self, url, proxies=None, verify=None, cert=None):
"""Returns a urllib3 connection for the given URL. This should not be
called from user code, and is only exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param url: The URL to connect to.
:param proxies: (optional) A Requests-style dictionary of proxies used on this request.
"""
parsed_url = urlparse(url)
scheme = parsed_url.scheme.lower()
with self._pool_kw_lock:
proxies = proxies or {}
proxy = proxies.get(scheme)
if proxy:
proxy = prepend_scheme_if_needed(proxy, 'http')
pool_manager = self.proxy_manager_for(proxy)
else:
pool_manager = self.poolmanager
if scheme == 'https':
self._update_poolmanager_ssl_kw(pool_manager, verify, cert)
conn = pool_manager.connection_from_url(parsed_url.geturl())
return conn
0
Example 6
@_api.setter
def _api(self, uri):
self._uri = urlparse(uri)
self.url = uri
0
Example 7
Project: call-congress Source File: test_server.py
def parse_url(self, urlstring):
url = urlparse(urlstring)
return url, dict((k, v if len(v)>1 else v[0])
for k, v in parse_qs(url.query).iteritems())