This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 9268ba468f2e9798c5c2684c9a7a1ec69f83abe4
tree cb415e77195a09798315e35993bb22e16a067a62
parent 40c5fe89226dd93cfb663db1038182114cf132fe
tree cb415e77195a09798315e35993bb22e16a067a62
parent 40c5fe89226dd93cfb663db1038182114cf132fe
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Sun Feb 01 10:47:43 -0800 2009 | |
| |
LICENSE | Fri Aug 22 10:56:57 -0700 2008 | |
| |
README.rdoc | Sun Oct 25 12:58:34 -0700 2009 | |
| |
Rakefile | ||
| |
VERSION | Thu Oct 29 15:55:06 -0700 2009 | |
| |
examples/ | Sun Oct 25 12:33:07 -0700 2009 | |
| |
ext/ | Sun Oct 25 12:15:27 -0700 2009 | |
| |
lib/ | ||
| |
test/ |
README.rdoc
EM-HTTP-Client
EventMachine based HTTP Request interface. Supports streaming response processing, uses Ragel HTTP parser.
- Simple interface for single & parallel requests via deferred callbacks
- Automatic gzip & deflate decoding
- Basic-Auth support
- Custom timeouts
Screencast / Demo of using EM-HTTP-Request:
Getting started
# install & configure gemcutter repos gem update --system gem install gemcutter gem tumble gem install em-http-request irb:0> require 'em-http'
Simple client example
EventMachine.run {
http = EventMachine::HttpRequest.new('http://127.0.0.1/').get :query => {'keyname' => 'value'}, :timeout => 10
http.callback {
p http.response_header.status
p http.response_header
p http.response
EventMachine.stop
}
}
Multi request example
EventMachine.run {
multi = EventMachine::MultiRequest.new
# add multiple requests to the multi-handler
multi.add(EventMachine::HttpRequest.new('http://www.google.com/').get)
multi.add(EventMachine::HttpRequest.new('http://www.yahoo.com/').get)
multi.callback {
p multi.responses[:succeeded]
p multi.responses[:failed]
EventMachine.stop
}
}
Basic-Auth example
EventMachine.run {
http = EventMachine::HttpRequest.new('http://www.website.com/').get :head => {'authorization' => ['user', 'pass']}
http.errback { failed }
http.callback {
p http.response_header
EventMachine.stop
}
}
POST example
EventMachine.run {
http1 = EventMachine::HttpRequest.new('http://www.website.com/').post :body => {"key1" => 1, "key2" => [2,3]}
http2 = EventMachine::HttpRequest.new('http://www.website.com/').post :body => "some data"
# ...
}
Streaming body processing
EventMachine.run {
http = EventMachine::HttpRequest.new('http://www.website.com/').get
http.stream { |chunk| print chunk }
# ...
}








