Skip to content

Bug: Using Logger Breaks Request Streaming #785

@ksylvest

Description

@ksylvest

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions