Modified to explicitly check that the url protocol is http or https instead of relying on tornado