RestClient: Soon to handle streaming bodies

restclient ruby

Thu Jun 24 18:48:21 +0000 2010

Here’s a little patch I wrote to allow RestClient to stream the HTTP request’s body from a File, Tempfile, StringIO or other IO-like object.

The IO object must respond to #size (or #stat.size), #close, and #read(n)

This is particularly useful for doing tasks like uploading files to couchdb and whatnot since it means that the file doesn’t have to be completely read into memory before uploading it.

NOTE: this is different from a form file submission, which was already streamed. In this case, the entire payload of the HTTP request is the file (like in the case of a PUT request, let’s say)

This patch has been merged into the official RestClient repository, and should be included in the next release.

Here it is: patch

blog comments powered by Disqus