Improve the logic for determining the port number of the server.
Improve the logic for determining the port number of the server.

Previously, we relied on the "referer" query parameter being passed
in (which is the case when going through the login flow in the UI,
but not when going directly to the "/signin" page).

This changes the logic to instead rely on the request's "host"
header field, which should always be set regardless of whether or
not the "referer" query parameter is set.

yebrahim/datalab,googledatalab/datalab,craigcitro/datalab,yebrahim/datalab,craigcitro/datalab,craigcitro/datalab,craigcitro/datalab,parthea/datalab,parthea/datalab,googledatalab/datalab,parthea/datalab,googledatalab/datalab,yebrahim/datalab,googledatalab/datalab,parthea/datalab,parthea/datalab,parthea/datalab,craigcitro/datalab,googledatalab/datalab,yebrahim/datalab,yebrahim/datalab,googledatalab/datalab