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
Feng_WFeng_W 

how to get server variables in apex?

is it possible to get the server variables in apex code?

like page referer, user browser, those information?

 

like asp.net, has request.ServerVariables["HTTP_REFERER"], etc

 

thanks in advance

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Feng_WFeng_W
thanks JimRae, that is a great Hint

 

actually i just want the current page server variables, don't want to create HTTPRequest/HTTPResponse by using HTTP class

 

but here is my solution , :)

 

PageReference page = ApexPages.currentPage(); Map<string, string> keys = page.getHeaders(); for(string k : keys.keySet()) { System.Debug(k + ':' + keys.get(k));

}

All Answers

JimRaeJimRae
Look in the apex documentation for the HTTPResponse helper class, it has a getHeader that will return the a specific key value, and a getHeaderKeys that will return a full list of the keys.
Feng_WFeng_W
thanks JimRae, that is a great Hint

 

actually i just want the current page server variables, don't want to create HTTPRequest/HTTPResponse by using HTTP class

 

but here is my solution , :)

 

PageReference page = ApexPages.currentPage(); Map<string, string> keys = page.getHeaders(); for(string k : keys.keySet()) { System.Debug(k + ':' + keys.get(k));

}

This was selected as the best answer