Closed matti closed 5 years ago
Async::HTTP::Internet - it looks like the one I should use?
It's the easiest one.
call internet.close manually (?)
You must always close the resource you use once you are done.
I need to call response.body.join to read the full body
Or call response.read
which is a bit easier.
I need to wrap body in an array
Yes, like rack, anything where #each
yields successive values.
btw why are headers and array and not hash?
They can be if you want, it must just #each -> yield key, value
.
The reason to use array is because:
set-cookie
.thanks @ioquatix !
call internet.close manually (?)
You must always close the resource you use once you are done.
yeah - would call
(and VERBS) with an optional block that automatically closes be a good idea or not? (see https://github.com/matti/async-nats/blob/master/lib/async/nats/client.rb#L51-L53 where I experimented with this)
I need to call response.body.join to read the full body
Or call response.read which is a bit easier.
Oh okay, didn't understand that I could just do that, thanks!
I need to wrap body in an array
Yes, like rack, anything where #each yields successive values.
Okay, but I think the library should work like most (?) people expect it to work - I don't think everybody is that familiar with how rack works. Anyway, the example helps a lot here.
It can contain multiple values for the same key. e.g. multiple set-cookie.
got it, didn't thought of that at all.
Consider using async-rest instead.
nice, I didn't know about it. inb4: gonna complain about lack of examples in that repo very soon ;)
More complex protocols require explicit close including features like keep-alive, http/2 multiplexing. Unfortunately it’s not that simple.
So through some trial and error I got this together:
Async::HTTP::Internet
- it looks like the one I should use?internet.close
manually (?)response.body.join
to read the full bodySo if I got this right, something like this should be in the
examples
dir:btw why are headers and array and not hash?