Sha256: 78c54cf65a861d189011eb4398c9b4b5d7d8e367eec9409d82025c540737e4c4

Contents?: true

Size: 641 Bytes

Versions: 4

Compression:

Stored size: 641 Bytes

Contents

# Example application that echoes read data back to the HTTP client.
# This emulates the old echo protocol people used to run.
#
# An example of using this in a client would be to run:
#   curl --no-buffer -T- http://host:port/
#
# Then type random stuff in your terminal to watch it get echoed back!

class EchoBody < Struct.new(:input)

  def each(&block)
    while buf = input.read(4096)
      yield buf
    end
    self
  end

end

use Rack::Chunked
run lambda { |env|
  /\A100-continue\z/i =~ env['HTTP_EXPECT'] and return [100, {}, []]
  [ 200, { 'content-type' => 'application/octet-stream' },
    EchoBody.new(env['rack.input']) ]
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pitchfork-0.2.0 examples/echo.ru
pitchfork-0.1.2 examples/echo.ru
pitchfork-0.1.1 examples/echo.ru
pitchfork-0.1.0 examples/echo.ru