More reliable way to detect HTTPS requests