0

I created a new Apex class:

public with sharing class PWSHttpHeadersController {

public PWSHttpHeadersController(){
    ApexPages.currentPage().getHeaders().put('X-XSS-Protection','1; mode=block');
    ApexPages.currentPage().getHeaders().put('Strict-Transport-Security', 'max-age=3600; includeSubDomains');
}
public PWSHttpHeadersController(cms.CoreController coreController){
    ApexPages.currentPage().getHeaders().put('X-XSS-Protection','1; mode=block');
    ApexPages.currentPage().getHeaders().put('Strict-Transport-Security', 'max-age=3600; includeSubDomains');
}

}

Once deployed to my sandbox I can see that the Strict Transport Security header in effect but not the XSS protection header.

Have tried setting it to 1 instead of 1:mode=block but that has no effect.

Is this something i am doing wrong? Or does Salesforce not implement this header in the response.

1

I believe that ApexPages.currentPage().getHeaders() returns the request headers, which should be read only at this point.

As far as I can see there is no way to set response headers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.