#27575: Make host validation run on all requests
-------------------------------------+-------------------------------------
Reporter: JorisBenschop | Owner: Ketan
Type: | Bhatt
Cleanup/optimization | Status: assigned
Component: HTTP handling | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Chris Jerdonek):
> In fact, it might be better to move that validation elsewhere so it
always runs during a request, regardless of if get_host() is called.
Doing this might be complicated by the fact that, currently, host
validation has to take place after custom middleware in certain
situations, per this note in the `HttpRequest.get_host()` docs:
https://docs.djangoproject.com/en/3.1/ref/request-
response/#django.http.HttpRequest.get_host
An easier option might be to cache `get_host()`'s return value. Then
middleware that might need the return value could call `get_host()` early
on to warm the cache (or fail the request) without too much penalty (since
`get_host()` can be getting called elsewhere, anyways).
--
Ticket URL: <https://code.djangoproject.com/ticket/27575#comment:13>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/071.49bf37c33f2b7604dc5f931d4727f20e%40djangoproject.com.