ninenines / gun

HTTP/1.1, HTTP/2, Websocket client (and more) for Erlang/OTP.
ISC License
898 stars 231 forks source link

flush(...) may need a timeout #138

Closed refactor closed 6 years ago

refactor commented 6 years ago

it's ok for gun:flush(...) used in console, but when using flush(..) in program code, it may miss the message.

` StreamRef = gun:put(ConnPid, <<"/", Index/binary>>, [], Body),

{response, nofin, 200, _Headers} = gun:await(ConnPid, StreamRef), gun:flush(StreamRef), ... `

I guess 'receive after 0' make gun:flush(...) miss the gun message.

essen commented 6 years ago

You have to cancel the stream first.

refactor commented 6 years ago

noop, cancel doesn't work in this situation, gun:cancel(ConnPid, StreamRef) just send a message to ConnPid. anyway it's not a big deal, just use gun:await_body to get round.