Created
June 11, 2010 16:52
-
-
Save jarib/434745 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "curb" | |
require "sinatra/base" | |
class App < Sinatra::Base | |
get "/" do | |
"get" | |
end | |
delete "/" do | |
"delete" | |
end | |
end | |
curb = Curl::Easy.new | |
curb.url = "http://localhost:1234/" | |
begin | |
curb.http_delete | |
rescue Curl::Err::ConnectionFailedError | |
puts "rescued delete" | |
end | |
Thread.new do | |
Rack::Handler::WEBrick.run(App.new, :Port => 1234) | |
end | |
sleep 2 | |
curb.http_get | |
p curb.body_str | |
__END__ | |
rescued delete | |
[2010-06-11 18:51:43] INFO WEBrick 1.3.1 | |
[2010-06-11 18:51:43] INFO ruby 1.9.1 (2010-01-10) [i386-darwin9.8.0] | |
[2010-06-11 18:51:43] INFO WEBrick::HTTPServer#start: pid=5853 port=1234 | |
localhost - - [11/Jun/2010:18:51:45 CEST] "DELETE / HTTP/1.1" 200 6 | |
"delete" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment