I want every datasource request that goes from my client to have custom HTTP headers.. hence I created a CustomDS which implements the RestDatasource and so now all specific DS's implement CustomDS instead of the RestDatasource.
In Chrome and Firefox....
If I remove this code and do not manipulate the headers the request goes to the server.. but if I set the HTTP headers as shown above.. the request does not reach the server.. in short nothing happens at all...
It works fine in Hosted Mode and IE with and without the headers...
What am I doing wrong..??
Code:
public class GenericDataSource extends RestDataSource { @Override protected Object transformRequest(DSRequest dsRequest) { Map<String, String> httpMap = new HashMap<String, String>(); String encodeStr = "login:secret"; String encoded = Base64.encode(encodeStr); httpMap.put("Authorization","Basic "+encoded); /*httpMap.put("User-Agent" , "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)"); httpMap.put("Accept", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png;q=0.5"); httpMap.put("Accept-Language","en-us,en;q=0.9,de;q=0.8,ja;q=0.8,zh;q=0.7,zh-cn;q=0.6,nl;q=0.5,fr;q=0.5,it;q=0.4,ko;q=0.3,es;q=0.2,ru;q=0.2,pt;q=0.1"); httpMap.put("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7"); httpMap.put("Accept-Encoding","gzip,deflate"); httpMap.put("Connection","keep-alive"); httpMap.put("Content-Type", "text/xml"); */ dsRequest.setHttpHeaders(httpMap); return super.transformRequest(dsRequest); } }
If I remove this code and do not manipulate the headers the request goes to the server.. but if I set the HTTP headers as shown above.. the request does not reach the server.. in short nothing happens at all...
It works fine in Hosted Mode and IE with and without the headers...
What am I doing wrong..??
Comment