Closed ProjectMoon closed 4 years ago
This is for streaming.
With a block, an Crest::Response
body is returned and the response's body is available as an IO
.
You can use
response = ""
Crest.get("http://httpbin.org/get") do |resp|
response = resp.body_io.gets_to_end
end
which is equal to
response = Crest.get("http://httpbin.org/get").body
In the use case I have, I want to stream XML in and then convert that whole body to a hash. Didn't realize I could just assign it to a variable outside the block.
Feature request: When doing something like this:
Would it be possible to have the method return the expression from the block?
break
/next
don't seem to be respected here, and after looking at the source I think it's because this version of the method always just returns nil?Or am I missing something?