fixed an error with http/(s) switching