Requests.jl icon indicating copy to clipboard operation
Requests.jl copied to clipboard

Disallow reading from a closed ResponseStream

Open omus opened this issue 8 years ago • 4 comments

Closing a ResponseStream would still allow you to continue reading content from the buffer. I've updated the code to work similarly to how IOStream's behave.

omus avatar Jan 18 '17 17:01 omus

Codecov Report

Merging #144 into master will decrease coverage by 0.74%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #144      +/-   ##
==========================================
- Coverage   70.17%   69.42%   -0.75%     
==========================================
  Files           4        4              
  Lines         523      520       -3     
==========================================
- Hits          367      361       -6     
- Misses        156      159       +3
Impacted Files Coverage Δ
src/streaming.jl 74.59% <100%> (-4.41%) :arrow_down:
src/Requests.jl 60% <0%> (-1.23%) :arrow_down:
src/multipart.jl 61.73% <0%> (+2.6%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c2c07cd...7cafa47. Read the comment docs.

codecov-io avatar Jan 18 '17 21:01 codecov-io

@omus should we merge this?

aviks avatar Jul 14 '17 15:07 aviks

@aviks I'm not sure that this should be the behaviour anymore based upon https://github.com/JuliaWeb/HTTP.jl/issues/45#issuecomment-315277826. @samoconnor can you elaborate on why you want to be able to read from the buffer when the socket has been closed?

omus avatar Jul 14 '17 20:07 omus

Hi @aviks, perhaps there is confusion about the reader closing the stream vs the server closing the stream.

If the server has closed the stream (or the connection was unexpectedly lost), the reader should be able to continue to read whatever was received from the buffer until there is nothing left to read.

If the reader calls close on the stream, that indicates that they do not intend to read anything else from the stream, I think any subsequent calls to read or eof for that stream should result in an exception e.g. "ERROR: Attempted access to closed stream".

Of course, if this assumes a uni-directional stream. If the stream is read/write, then there needs to be a way to close the write half without closing the read half (i.e. shutdown(socket, SHUT_WR)) so that the writer can signal that they have finished sending a request, but can still receive a response from the read half of the stream.

samoconnor avatar Jul 15 '17 00:07 samoconnor