Opened 8 years ago

Closed 8 years ago

#4986 closed (fixed)

get_host should fall back to building from SERVER_NAME/PORT if HTTP_HOST doesn't exist

Reported by: SmileyChris Owned by: nobody
Component: HTTP handling Version: master
Severity: Keywords:
Cc: smileychris+django@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The problem is that get_host currently relies on HTTP_HOST environ variable which may not exist.

Using a section of PEP333 as my muse, I rewrote get_host to fall back to creating the host based on SERVER_NAME and SERVER_PORT.

Attachments (1)

get_host.patch (854 bytes) - added by SmileyChris 8 years ago.

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by SmileyChris

comment:1 Changed 8 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

When this is applied, #4951 can be upgraded to ready for checkin.

comment:2 Changed 8 years ago by SmileyChris

  • Cc smileychris+django@… added
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:3 Changed 8 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(In [6166]) Fixed #4986 -- Improved get_host() host detection. Thanks, SmileyChris.

comment:4 Changed 8 years ago by frasern

  • Resolution fixed deleted
  • Status changed from closed to reopened

The fix doesn't seem to be quite right as the value from HTTP_X_FORWARDED_HOST is now never used and is always overwritten.

comment:5 Changed 8 years ago by anonymous

Indeed, it doesn't look correct. My patch didn't do that ;)

comment:6 Changed 8 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [6449]) Fixed #4986 -- Fixed a logic bug from [6166].

Note: See TracTickets for help on using tickets.
Back to Top