FAQ
overflow

Great Answers to
Questions About Everything

QUESTION

I'm developing on Force.com Sites, and having trouble distinguishing whether the current request is coming in on HTTP or HTTPS. Do you have any tips?

ApexPages.CurrentPage().getUrl();
// ==> relative url without the domain or protocol

ApexPages.CurrentPage().getHeaders() 
// doesn't dependably include any url information

{ asked by Benj }

ANSWER

You could use the URL class:

System.debug('URL Protocol: ' + URL.getSalesforceBaseUrl().getProtocol()); 

{ answered by Daniel Ballinger }
Tweet