本文整理汇总了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