work on both http and https