Refactored request host processing out into separate method

Refactored the way `hostname` is taken out of `request` so that it's possible to override the mechanics. Specifically, my use-case is that I want to include the port in domain lookup. Another option would be to introduce a separate django setting, but that would be less customizable.