You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by william kinney <wi...@gmail.com> on 2008/09/18 17:29:39 UTC
startkey and quotes
Hi (again),
It seems that the startkey query parameter requires quotes around the value.
However, my lovely Apache java HttpClient library doesn't like that, and
throws a org.apache.commons.httpclient.URIException: Invalid query.
Has anyone had any experience with this? I'd like to avoid having to extend
or hack http client to get around this.
On a side note, I've never seen quotes being specified/used in query
parameters before. I couldn't find any mention of it in the w3c spec. I'm
sure of course it is intended functionality. Bu t does anyone know why?
Thanks,
Will
Re: startkey and quotes
Posted by william kinney <wi...@gmail.com>.
URLEncoder to the rescue. I could have sworn I saw it failed on testing w/ a
hard coded %22. Much thanks!
Will
On Thu, Sep 18, 2008 at 11:50 AM, Christopher Lenz <cm...@gmx.de> wrote:
> Hey Will,
>
> On 18.09.2008, at 17:29, william kinney wrote:
>
>> It seems that the startkey query parameter requires quotes around the
>> value.
>> However, my lovely Apache java HttpClient library doesn't like that, and
>> throws a org.apache.commons.httpclient.URIException: Invalid query.
>> Has anyone had any experience with this? I'd like to avoid having to
>> extend
>> or hack http client to get around this.
>>
>
> You should percent-encode the quotes before passing them to HttpClient.
>
> In this case, " -> %22
>
> See <http://en.wikipedia.org/wiki/Percent-encoding>
>
> On a side note, I've never seen quotes being specified/used in query
>> parameters before. I couldn't find any mention of it in the w3c spec. I'm
>> sure of course it is intended functionality. Bu t does anyone know why?
>>
>
> The key parameters need to be JSON encoded values, as they can be some
> other type than strings, such as integers, arrays or dictionaries. So the
> rule is: JSON-encode the value (which will need to be either ASCII or
> UTF-8), then percent-encode, finally pass the complete URI to the HTTP
> client lib.
>
> Cheers,
> --
> Christopher Lenz
> cmlenz at gmx.de
> http://www.cmlenz.net/
>
>
Re: startkey and quotes
Posted by Christopher Lenz <cm...@gmx.de>.
Hey Will,
On 18.09.2008, at 17:29, william kinney wrote:
> It seems that the startkey query parameter requires quotes around
> the value.
> However, my lovely Apache java HttpClient library doesn't like that,
> and
> throws a org.apache.commons.httpclient.URIException: Invalid query.
> Has anyone had any experience with this? I'd like to avoid having to
> extend
> or hack http client to get around this.
You should percent-encode the quotes before passing them to HttpClient.
In this case, " -> %22
See <http://en.wikipedia.org/wiki/Percent-encoding>
> On a side note, I've never seen quotes being specified/used in query
> parameters before. I couldn't find any mention of it in the w3c
> spec. I'm
> sure of course it is intended functionality. Bu t does anyone know
> why?
The key parameters need to be JSON encoded values, as they can be some
other type than strings, such as integers, arrays or dictionaries. So
the rule is: JSON-encode the value (which will need to be either ASCII
or UTF-8), then percent-encode, finally pass the complete URI to the
HTTP client lib.
Cheers,
--
Christopher Lenz
cmlenz at gmx.de
http://www.cmlenz.net/
Re: startkey and quotes
Posted by Paul Campbell <pa...@rushedsunlight.com>.
Hi Will,
The quotes are because the key has to be valid JSON ... and in JSON, a
string has to be in quotes!
Paul
On Thu, Sep 18, 2008 at 4:29 PM, william kinney
<wi...@gmail.com> wrote:
> Hi (again),
>
> It seems that the startkey query parameter requires quotes around the value.
> However, my lovely Apache java HttpClient library doesn't like that, and
> throws a org.apache.commons.httpclient.URIException: Invalid query.
> Has anyone had any experience with this? I'd like to avoid having to extend
> or hack http client to get around this.
>
> On a side note, I've never seen quotes being specified/used in query
> parameters before. I couldn't find any mention of it in the w3c spec. I'm
> sure of course it is intended functionality. Bu t does anyone know why?
>
> Thanks,
> Will
>