Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Using Logger Breaks Request Streaming #785

Open
ksylvest opened this issue Jun 21, 2024 · 0 comments
Open

Bug: Using Logger Breaks Request Streaming #785

ksylvest opened this issue Jun 21, 2024 · 0 comments

Comments

@ksylvest
Copy link

ksylvest commented Jun 21, 2024

Per the documentation, it should be possible to pass a an each block to body to stream:

require 'http'
response = HTTP.get('https://news.ycombinator.com')
response.body.each { |chunk| puts(chunk) }

This works as expected. However, if logging is used then an HTTP::StateError is raised:

require 'http'
require 'logger'
logger = Logger.new($stdout)

response = HTTP.use({ logging: { logger: logger }}).get('https://news.ycombinator.com')
response.body.each { |chunk| puts(chunk) }
# raises: http/response/body.rb:67:in `stream!': body has already been consumed (HTTP::StateError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant