MCPcopy Index your code
hub / github.com/python/cpython / request_host

Function request_host

Lib/urllib/request.py:269–283  ·  view source on GitHub ↗

Return request-host, as defined by RFC 2965. Variation from RFC: returned value is lowercased, for convenient comparison.

(request)

Source from the content-addressed store, hash-verified

267# copied from cookielib.py
268_cut_port_re = re.compile(r":\d+$", re.ASCII)
269def request_host(request):
270 """Return request-host, as defined by RFC 2965.
271
272 Variation from RFC: returned value is lowercased, for convenient
273 comparison.
274
275 """
276 url = request.full_url
277 host = urlparse(url)[1]
278 if host == "":
279 host = request.get_header("Host", "")
280
281 # remove port, if present
282 host = _cut_port_re.sub("", host, 1)
283 return host.lower()
284
285class Request:
286

Callers 1

__init__Method · 0.70

Calls 4

urlparseFunction · 0.90
get_headerMethod · 0.45
subMethod · 0.45
lowerMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…