Skip to content

Do not call close() on the response_stream#775

Merged
quinnj merged 2 commits intomasterfrom
cjf/no-close-response-stream
Dec 15, 2021
Merged

Do not call close() on the response_stream#775
quinnj merged 2 commits intomasterfrom
cjf/no-close-response-stream

Conversation

@c42f
Copy link
Copy Markdown
Contributor

@c42f c42f commented Oct 5, 2021

This PR re-proposes #752.

This was too breaking for the stable release series as was discovered in #773 (comment), so needs to be part of a breaking release (I have added a breaking label for this purpose).

However I still think this is the correct behavior: HTTP.request() doesn't really own the response stream, and closing it inside the request handler doesn't bring additional functionality because HTTP.request is a blocking operation - the caller should easily be able to close the stream themselves:

HTTP.get("http://example.com", response_stream=io)
close(io)

This argument applies to either close or the new closewrite.

The close() was added in 422c8f5 but it's not really clear why. Additional discussion can be found in #543.


Original description from #752

This allows a plain IOBuffer to be used with response_stream.

It seems unnecessary to be calling close(response_stream) inside
HTTP.request() - given that HTTP.request is a blocking operation, the
caller can easily close the stream themselves after HTTP.request()
returns.

This could be considered a breaking change for users who use the
internal IO type Base.BufferStream with the response_stream keyword.

Fixes #543

This allows a plain `IOBuffer` to be used with `response_stream`.

It seems unnecessary to be calling `close(response_stream)` inside
HTTP.request() - given that HTTP.request is a blocking operation, the
caller can easily close the stream themselves after `HTTP.request()`
returns.

This could be considered a breaking change for users who use the
internal IO type Base.BufferStream with the response_stream keyword.

Fixes #543
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 5, 2021

Codecov Report

Merging #775 (5bbd8a5) into master (f3a3fb7) will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #775      +/-   ##
==========================================
- Coverage   76.84%   76.84%   -0.01%     
==========================================
  Files          39       39              
  Lines        2501     2500       -1     
==========================================
- Hits         1922     1921       -1     
  Misses        579      579              
Impacted Files Coverage Δ
src/StreamRequest.jl 93.10% <ø> (-0.12%) ⬇️

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 f3a3fb7...5bbd8a5. Read the comment docs.

@fredrikekre fredrikekre added this to the 1.0 milestone Nov 15, 2021
@fredrikekre fredrikekre mentioned this pull request Dec 8, 2021
12 tasks
@quinnj
Copy link
Copy Markdown
Member

quinnj commented Dec 15, 2021

I resolved the conflict here; once/if tests pass, I'll merge as we prepare for a 1.0 release.

@quinnj quinnj merged commit 1640cd5 into master Dec 15, 2021
@quinnj quinnj deleted the cjf/no-close-response-stream branch December 15, 2021 07:18
@c42f
Copy link
Copy Markdown
Contributor Author

c42f commented Dec 16, 2021

Thanks for pushing this through!

quinnj added a commit that referenced this pull request Mar 10, 2022
This allows a plain `IOBuffer` to be used with `response_stream`.

It seems unnecessary to be calling `close(response_stream)` inside
HTTP.request() - given that HTTP.request is a blocking operation, the
caller can easily close the stream themselves after `HTTP.request()`
returns.

This could be considered a breaking change for users who use the
internal IO type Base.BufferStream with the response_stream keyword.

Fixes #543

Co-authored-by: Jacob Quinn <quinn.jacobd@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

response_stream breaks with IOBuffer()

4 participants