2i: url encoding/decoding of index names/values
age.mooij at gmail.com
Wed Feb 20 15:56:29 EST 2013
I'm writing a new Scala (http) client library for Riak  and I ran into some trouble with special characters while implementing 2i.
Reading through the docs, all the 2i examples are for simple one-word index names but I have not been able to find any rules about index names and values containing spaces, commas, and other special characters and how the HTTP api deals with encoding and decoding these?
My unit tests use the following troublesome corner cases:
- index values containing spaces
- index names containing spaces
- index values containing commas
I tried a number of approaches and none of them work for all three:
1) Don't encode the index names or the values when creating "x-riak-index-" http headers but encode both the name and the value in the URL used to fetch by an index
This works fine for values containing spaces but creates illegal headers for index names containing spaces and breaks for values containing commas (the values get split into two).
2) Encode everything
This creates valid headers and storing index values containing commas now works fine. The only trouble is that index fetching fails whenever there are spaces, commas or other encoded characters involved.
Could anyone enlighten me about the correct way to deal with these cases?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the riak-users