Closed bruno- closed 4 years ago
You cannot use the underlying IO for streaming the response because with HTTP/2 for example, there are multiple requests being multiplexed on the same IO. In addition, the binary framing format is not the raw data you expect.
require 'async'
require 'async/http/internet'
Async do
internet = Async::HTTP::Internet.new
response = internet.get(...)
pipe = Async::HTTP::Body::Pipe.new(response.body)
parse(pipe.to_io)
end
This makes an adapter socket around the HTTP data stream. Hopefully this helps you enough to figure it out - let me know if not.
This was very helpful, thank you very much.
Hi,
I'm not reporting a gem issue, but instead I'm struggling to make the below code work. I'm trying to make asynchronous requests where response IO object is passed to nokogiri SAX parser.
This is the problem line:
parser.parse_io(response.peer.io)
- it errors with this:The
#parse_io
method needs to be passed an IO and I've been unable to figure it out. Any hints? Thank you very much π