Fix HTTPS detection

Fix #281