PDA

View Full Version : Prevent Operation.params from being escaped



adambuckley
22 Oct 2012, 9:15 PM
Hi Folks,

I am able to pass parameters along with data store.load request as follows.


dataStore.load({
params :
{
q : 'ShortDescription:Cheese'
}
});

I see that the HTTP GET URL is created as follows.


http://server?q=ShortDescription%3AChese

The ':' character is converted to %3A. This works fine so far.


My problem is that I want to put a '+' character as part of the 'q' parameter.


params :{
q : 'AccountID:257154664274921487+ShortDescription:Cheese'
}


This resolves to the following URL string.


http://server?q=AccountID%3A257154664274921487%2BShortDescription%3AChese

This is a problem because I don't want the URL string to contain %2B - I want it to contain the '+' symbol.

How can I do this?

Many thanks, Adam.

skirtle
22 Oct 2012, 9:38 PM
You seem to be trying to fight HTTP here. If your server isn't handling HTTP parameter decoding correctly then it's a bit of a lost cause.

Are you sure you actually want a + symbol? Many HTTP servers treat an unescaped + as an escape sequence for a space. You may find just using a space (which will be encoded as %20 rather than a + in this case) will work just as well.

adambuckley
23 Oct 2012, 12:01 AM
Thanks Skirtle, that worked. Seems my thinking had got a bit blinkered.

FYI, the 'q' parameter is how Apache Solr exploses its RESTful API.