Yeah, in attempt number two the index names and values have been url encoded 
when creating the relevant HTTP headers and when doing the index fetch the 
index name and value are again encoded. 

What is probably happening is that Riak will decode the incoming fetch url and 
then use the decoded values to match against indexes internally (since the 
http_url_encoding setting will be set to "on" for most people). Since those 
indexes themselves have been encoded, they won't match.

Approach number 3), double encoding the index name and value when constructing 
the fetch URL, works in all cases but seems a bit overkill. 

If nothing better comes along I guess I'll go with number 3)

Thanks,
Age


On Feb 20, 2013, at 22:19, Dmitri Zagidulin <[email protected]> wrote:

> Question about 2) -- are you also encoding the index names and values when 
> issuing the fetch? (Maybe post some example code or Riak object header 
> snippets, and examples of the fetch queries, that might help).
> 
> On Wed, Feb 20, 2013 at 3:56 PM, Age Mooij <[email protected]> wrote:
> 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
> 
> 
> _______________________________________________
> riak-users mailing list
> [email protected]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> 
> 
> _______________________________________________
> riak-users mailing list
> [email protected]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to