Rigel Group

They shoot Yaks, don't they?

Simulating Directories in Riak

In the course of trying to store a directory structure of files in Riak using the Ripple gem, we ran into some problems with the way Ripple handled the escaping of slashes.  Basically, Ripple calls URI.escape on the URL it submits to the Riak server, and the URI lib escapes everything except the “/” character, since it is a valid character in URLs.  So we end up sending a request to Riak that looks like this:

```
 GET http://host.com/riak/bucket/key/with/slashes%20and%20spaces
```

The Riak server doesn’t like slashes in keys, they need to be escaped to %2f. So the above request will fail. To work around this, and make sure that the slashes (and “+” characters) get escaped, we came up with this monkey patch:

It is definitely a quick hack, as it requires the HTTPBackend class to know about the structure of the riak URLs, but I am sure the author of Ripple Sean Cribbs will come up with a much better long term solution to the problem. Until then, monkey patch away!

Update: The latest release on Github has this baked in already. Those guys move fast.