2i: url encoding/decoding of index names/values

Age Mooij age.mooij at gmail.com
Wed Feb 20 15:56:29 EST 2013


Hi all,

I'm writing a new Scala (http) client library for Riak [1] 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?

Regards,
Age


[1] https://github.com/agemooij/riak-scala-client

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20130220/fdbace8a/attachment.html>


More information about the riak-users mailing list