BUG http/https switching results in an exception