class HTTP_Spew::ChunkyPipe

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.

Attributes

error[RW]

other threads may force an error to be raised in the read method

Public Instance Methods

check_err!() click to toggle source
# File lib/http_spew/chunky_pipe.rb, line 29
def check_err!
  if defined?(@error)
    closed? or close
    raise @error
  end
  nil
end
read(len = 16384, buf = '') click to toggle source

Override IO#read to behave like IO#readpartial, but still return nil on EOF instead of raising EOFError.

# File lib/http_spew/chunky_pipe.rb, line 17
def read(len = 16384, buf = '')
  check_err!
  case read_nonblock(len, buf, exception: false)
  when nil
    return check_err! || close
  when :wait_readable
    wait_readable # retry
  else
    return buf
  end while true
end