Return request-host, as defined by RFC 2965. Variation from RFC: returned value is lowercased, for convenient comparison.
(request)
| 299 | # copied from cookielib.py |
| 300 | _cut_port_re = re.compile(r":\d+$", re.ASCII) |
| 301 | def request_host(request): |
| 302 | """Return request-host, as defined by RFC 2965. |
| 303 | |
| 304 | Variation from RFC: returned value is lowercased, for convenient |
| 305 | comparison. |
| 306 | |
| 307 | """ |
| 308 | url = request.full_url |
| 309 | host = urlparse(url)[1] |
| 310 | if host == "": |
| 311 | host = request.get_header("Host", "") |
| 312 | |
| 313 | # remove port, if present |
| 314 | host = _cut_port_re.sub("", host, 1) |
| 315 | return host.lower() |
| 316 | |
| 317 | class Request: |
| 318 |
no test coverage detected