Be more clever about whether to use HTTPS or not