Here's the deal, any help would be greatly appreciated because as of now I am at a loss.
I'm setting custom headers in my jQuery.ajax like so:
$.ajax({
type:'GET',
url: url,
dataType: 'json',
headers: {
'customHeader': 'value',
}, etc...
I'm using spring mvc and spring security with a custom filter and getting the header like this:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {
HttpServletResponse httpResponse = (HttpServletResponse) response;
HttpServletRequest httpRequest = (HttpServletRequest) request;
httpResponse.setHeader("Access-Control-Allow-Origin", "*");
String header = httpRequest.getHeader('customHeader');
Unfortunately the header is always null, I've tried things like using beforeSend in the ajax call still same effect. Can anyone please she some light on this?
Remote Address:127.0.0.1:8080
Request URL:http://localhost:8080/ecom/ws/session
Request Method:OPTIONS
Status Code:401 Unauthorized
Request Headersview parsed
OPTIONS /ecom/ws/session HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Access-Control-Request-Method: GET
Origin: null
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
Access-Control-Request-Headers: accept, ecom_string_s3c, ecom_client_uuid, content-type
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,es;q=0.6
Response Headersview parsed
HTTP/1.1 401 Unauthorized
Date: Wed, 02 Jul 2014 18:15:03 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: ecom_string_s3c, ecom_client_uuid, content-type
Content-Length: 0
Server: Jetty(6.1.26)