Sha256: 843e45efaeddf75ef389e325715053491ed52a00d6a5037a0c9094a74c10acb6

Contents?: true

Size: 677 Bytes

Versions: 6

Compression:

Stored size: 677 Bytes

Contents

# -*- encoding: binary -*-
#
# This is a OS-level pipe that overrides IO#read to provide
# IO#readpartial-like semantics while remaining Rack::Lint-compatible
# for EOF, meaning we return nil on EOF instead of raising EOFError.
class HTTP_Spew::ChunkyPipe < Kgio::Pipe

  # other threads may force an error to be raised in the +read+
  # method
  attr_accessor :error

  # Override IO#read to behave like IO#readpartial, but still return +nil+
  # on EOF instead of raising EOFError.
  def read(*args)
    check_err!
    kgio_read(*args) || check_err! || close
  end

  def check_err!
    if defined?(@error)
      closed? or close
      raise @error
    end
    nil
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
http_spew-0.6.0 lib/http_spew/chunky_pipe.rb
http_spew-0.5.0 lib/http_spew/chunky_pipe.rb
http_spew-0.4.1 lib/http_spew/chunky_pipe.rb
http_spew-0.4.0 lib/http_spew/chunky_pipe.rb
http_spew-0.3.0 lib/http_spew/chunky_pipe.rb
http_spew-0.2.0 lib/http_spew/chunky_pipe.rb