https protocol detection improvement (this solves css loading problem for https pages)