Skip to content

receiveResponse() may not return response body stream #4180

@SpitchAG

Description

@SpitchAG

version 1.12.x, using SSL and ChunkedStream request.
something looks wrong in the receiveResponse() implementation:

[Note that in the following scenario, receiveResponse() follow a peekResponse() returning false because other end didnt send 100 continue (and also close connection after sending a body response)].

at begining of receiveResponse() a flushRequest() is performed.
If the other end closed the connection after having sent a response body,
the flushRequest , which deletes the requestStream object, ends up calling HTTPChunkedStreamBuf::close () which writes some stuff on the underlying socket.
This can throw because remote end closed the sock, but it shall not prevent receiveResponse() to provide a response body reader, and caller to retrieve this body.

i did a quick work around so that the flush exception is ignored and it seems to work ok (however it is probably unsafe)

Before 1.12.x, strangely enough, HTTPChunkedStreamBuf::close was sending the 5 bytes 0/r/n/r/n in a raw, and SSL_write() didnt trigger any exc (probably because nothing was really sent on the sock),
but since response trailer header impl, this was changed to 2 consecutive writes (3 long, then 2 long) , and this triggers the exception in my case (i didnt look further in SSL_write see what happens there)

thanks and keep the good work,

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions