本文整理匯總了Python中urllib.request.get_full_url方法的典型用法代碼示例。如果您正苦於以下問題:Python request.get_full_url方法的具體用法?Python request.get_full_url怎麽用?Python request.get_full_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類urllib.request
的用法示例。
在下文中一共展示了request.get_full_url方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: request_host
# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request import get_full_url [as 別名]
def request_host(request):
"""Return request-host, as defined by RFC 2965.
Variation from RFC: returned value is lowercased, for convenient
comparison.
"""
url = request.get_full_url()
host = urllib.parse.urlparse(url)[1]
if host == "":
host = request.get_header("Host", "")
# remove port, if present
host = cut_port_re.sub("", host, 1)
return host.lower()
示例2: request_path
# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request import get_full_url [as 別名]
def request_path(request):
"""Path component of request-URI, as defined by RFC 2965."""
url = request.get_full_url()
parts = urllib.parse.urlsplit(url)
path = escape_path(parts.path)
if not path.startswith("/"):
# fix bad RFC 2396 absoluteURI
path = "/" + path
return path
示例3: test_endpoint_with_format_param
# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request import get_full_url [as 別名]
def test_endpoint_with_format_param(self, loads, urlopen):
urlopen.return_value = self.dummy_response
loads.return_value = {'type': 'video',
'url': 'http://www.example.com'}
result = OEmbedFinder().find_embed("https://vimeo.com/217403396")
self.assertEqual(result['type'], 'video')
request = urlopen.call_args[0][0]
self.assertEqual(request.get_full_url().split('?')[0], "http://www.vimeo.com/api/oembed.json")
示例4: http_request
# 需要導入模塊: from urllib import request [as 別名]
# 或者: from urllib.request import get_full_url [as 別名]
def http_request(self, request):
host, full_url = request.host, request.get_full_url()
url_path = full_url[full_url.find(host) + len(host):]
log_url ( self.log, "Requesting: ", request.get_full_url(), TRACE_LEVEL )
self.log.log(self.log_level, "%s %s" % (request.get_method(), url_path))
for header in request.header_items():
self.log.log(self.log_level, " . %s: %s" % header[:])
return request