diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/echo.ru | 27 | ||||
-rw-r--r-- | examples/git.ru | 13 |
2 files changed, 40 insertions, 0 deletions
diff --git a/examples/echo.ru b/examples/echo.ru new file mode 100644 index 0000000..c79cb7b --- /dev/null +++ b/examples/echo.ru @@ -0,0 +1,27 @@ +#\-E none +# +# 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/ =~ env['HTTP_EXPECT'] and return [100, {}, []] + [ 200, { 'Content-Type' => 'application/octet-stream' }, + EchoBody.new(env['rack.input']) ] +} diff --git a/examples/git.ru b/examples/git.ru new file mode 100644 index 0000000..59a31c9 --- /dev/null +++ b/examples/git.ru @@ -0,0 +1,13 @@ +#\-E none + +# See http://thread.gmane.org/gmane.comp.web.curl.general/10473/raw on +# how to setup git for this. A better version of the above patch was +# accepted and committed on June 15, 2009, so you can pull the latest +# curl CVS snapshot to try this out. +require 'unicorn/app/inetd' + +use Rack::Lint +use Rack::Chunked # important! +run Unicorn::App::Inetd.new( + *%w(git daemon --verbose --inetd --export-all --base-path=/home/ew/unicorn) +) |