function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dke01dke01 

Get Protocol HTTP or HTTPS

How can I determine if  the current page is running in HTTP or HTTPS mode

it seems: ApexPages.currentPage().getHeaders();  does not contain this information

Best Answer chosen by Admin (Salesforce Developers) 
BrendanOCBrendanOC

You can do it in a round-about way.  There is a header parameter called "CipherSuite."  This parameter will only appear if its an HTTPS page.  Within Apex, you can call ApexPages.currentPage().getHeaders() and evaluate that CipherSuite exists and is not Null.

 

As a test, run this in the execute anonymous section of the system log in your DE org:

system.debug(ApexPages.currentPage().getHeaders());

 

You can temporarily disable "require secure connection" under Setup > Security Controls > Session Settings

and run execute anonymous in HTTP mode.  You will see that the CipherSuite header no longer appears.

 

Just remember to turn "require secure connection" back on after you test!

All Answers

paul-lmipaul-lmi
I don't think you can do it in Apex directly.  Check out my thread history though.  I did post how to do this in a thread with a title geared toward this.
BrendanOCBrendanOC

You can do it in a round-about way.  There is a header parameter called "CipherSuite."  This parameter will only appear if its an HTTPS page.  Within Apex, you can call ApexPages.currentPage().getHeaders() and evaluate that CipherSuite exists and is not Null.

 

As a test, run this in the execute anonymous section of the system log in your DE org:

system.debug(ApexPages.currentPage().getHeaders());

 

You can temporarily disable "require secure connection" under Setup > Security Controls > Session Settings

and run execute anonymous in HTTP mode.  You will see that the CipherSuite header no longer appears.

 

Just remember to turn "require secure connection" back on after you test!

This was selected as the best answer
dke01dke01
Thank you this HACK seems to work well.
Message Edited by dke01 on 01-04-2010 11:30 AM