Http post in chunks

This isn’t strictly a rails query. I have created a rails application
that accepts post data on an action and I’m writing a ruby client that
sends a file using HTTP::Post. However, the file is quite big and I want
to display some kind of feedback on the send progress but I can’t work
out any way to either write in chunks of a small size or to monitor the
send progress in any other way. Is there a way I can do this?


Well if anyone is interested heres how i solved it:

class VerboseStringIO < StringIO
def read(len = nil)
progress = (pos.to_f / length.to_f) * 100
puts “Progress: #{progress}%”

data # string of data to post
tio =

req ="/controller/action")
req.body_stream = tio
req.content_length = data.length
req.content_type = “text/xml” #or whatever

http =“localhost”,3000)
http.read_timeout = 999
response = http.start{|query| query.request req}

This should output:
Progress: 1%
Progress: 2%
Progress: 3%

and so on so you can do whatever and show a progress bar or something.