SSL/HTTPS Detection fix

Should be a more reliable way to fix #5.

@emilbjorklund, does this solution work for you? Thanks.