Fix issue #78 with protocol assignment

Some withespace cleanup, and code to figure out whether the protocol is HTTPS or HTTP.