Sha256: 3d7fc18067cc221687d36fbf227b5315003b63f8bf32eb724f4097e0edb1589a

Contents?: true

Size: 623 Bytes

Versions: 12

Compression:

Stored size: 623 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

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

12 entries across 12 versions & 1 rubygems

Version Path
pitchfork-0.12.0 examples/echo.ru
pitchfork-0.11.1 examples/echo.ru
pitchfork-0.11.0 examples/echo.ru
pitchfork-0.10.0 examples/echo.ru
pitchfork-0.9.0 examples/echo.ru
pitchfork-0.8.0 examples/echo.ru
pitchfork-0.7.0 examples/echo.ru
pitchfork-0.6.0 examples/echo.ru
pitchfork-0.5.0 examples/echo.ru
pitchfork-0.4.1 examples/echo.ru
pitchfork-0.4.0 examples/echo.ru
pitchfork-0.3.0 examples/echo.ru