123456789_123456789_123456789_123456789_123456789_

Class: Rackup::Handler::WEBrick::Input

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: lib/rackup/handler/webrick.rb

Overview

This handles mapping the Handler::WEBrick request to a ::Rack input stream.

Class Method Summary

Instance Method Summary

Stream::Reader - Included

#each, #gets,
#read

read behaves like IO#read.

#read_nonblock,
#read_partial

Read at most length bytes from the stream.

Constructor Details

.new(request) ⇒ Input

[ GitHub ]

  
# File 'lib/rackup/handler/webrick.rb', line 63

def initialize(request)
  @request = request

  @reader = Fiber.new do
    @request.body do |chunk|
      Fiber.yield(chunk)
    end

    Fiber.yield(nil)

    # End of stream:
    @reader = nil
  end
end

Instance Method Details

#close

[ GitHub ]

  
# File 'lib/rackup/handler/webrick.rb', line 78

def close
  @request = nil
  @reader = nil
end

#read_next (private)

Read one chunk from the request body.

[ GitHub ]

  
# File 'lib/rackup/handler/webrick.rb', line 86

def read_next
  @reader&.resume
end