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

Exception Errno::ESPIPE with chunked transfer encoding and pipe-io as body #105

Open
eric-christian opened this issue Apr 13, 2021 · 1 comment
Assignees

Comments

@eric-christian
Copy link

Describe the bug

Hello,

We encountered an Illegal seek (Errno::ESPIPE) exception while doing some chunked transfer encoding with a pipe-io as body.
The exception is raised when the body is rewinded. While a pipe-io responses to rewind it actually can't be rewinded.

body.rewind if body.respond_to?(:rewind)

In the source of the http.rb gem is a comment as to what happens when rewind is called on a pipe-io. Maybe that explains it a little better. :) https://github.com/httprb/http/blob/a0f540ffd03b29bf35bd5476b82a20fb8c3b88b8/lib/http/request/body.rb#L57

Steps to reproduce

require 'http'
require 'httplog'

rd, wr = IO.pipe
wr.write('a chunk')
wr.close
HTTP.post('https://www.sumcumo.com', body: rd, headers: { 'Transfer-Encoding' => 'chunked' })

Expected behavior

Don't raise an exception while chunked transfer encoding with pipe-io as body is used.

Environment

  • Ruby version: 2.7.2
  • httplog version: 1.4.3
  • http version: 4.4.1

Have a great day! :)

Eric

@trusche
Copy link
Owner

trusche commented Apr 17, 2021

Ugh. Thanks for reporting. This is what I was afraid of when we first introduced support for streams - they need to be rewound because reading them is not idempotent. I'll take a closer look in a while - it might be we simply can't log the body content in this case.

@trusche trusche self-assigned this Apr 17, 2021
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

2 participants