Added code to support http/https option

Added code to handled option of http vs https.
Cleaned up lots of indentations.