#19517: Add support for X-Forwarded-Port to HttpRequest.get_host when
USE_X_FORWARDED_HOST is in use
-------------------------------------+-------------------------------------
     Reporter:  david_k_hess@…       |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  HTTP handling        |                  Version:  1.4
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:  httprequest,         |             Triage Stage:  Accepted
  get_host, X-Forwarded-Host,        |      Needs documentation:  0
  USE_X_FORWARDED_HOST               |  Patch needs improvement:  0
    Has patch:  1                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  1                    |
-------------------------------------+-------------------------------------

Comment (by mattlong):

 To be fair, `X-Forwarded-Host` is also not in any spec or standard that I
 can find. It's added automatically by Apache's mod_proxy, but that seems
 to be the only place. Having special handling for one custom header
 without the other seems incorrect as there is currently no way (besides
 middleware to change `HTTP_HOST` as jezdez suggests) to accurately get the
 original request's host/port combo as the OP describes.

 It seems reasonable to me to expect that `HTTP_X_FORWARDED_PORT` would
 also be respected by HttpRequest.get_host if `USE_X_FORWARDED_HOST` is
 enabled. Currently, I will also be opting to monkey patch get_host rather
 than add the (admittedly small) overhead of an additional middleware on
 all requests.

--
Ticket URL: <https://code.djangoproject.com/ticket/19517#comment:6>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/078.57dc60bbc90ac48c6c81658e0b29af58%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to