Skip to content

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

@eric-christian

Description

@eric-christian

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions