Return request-host, as defined by RFC 2965. Variation from RFC: returned value is lowercased, for convenient comparison.
(request)
| 267 | # copied from cookielib.py |
| 268 | _cut_port_re = re.compile(r":\d+$", re.ASCII) |
| 269 | def 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 | |
| 285 | class Request: |
| 286 |
no test coverage detected
searching dependent graphs…