will add comment that if https is used some info about the URL must be available early on, and that the code could stand to be improved