Skip to content

Instantly share code, notes, and snippets.

@jarib
Created June 11, 2010 16:52
Show Gist options
  • Save jarib/434745 to your computer and use it in GitHub Desktop.
Save jarib/434745 to your computer and use it in GitHub Desktop.
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