Sha256: ebdee796a8372f0fc89cb78d35a3661f89406311a6ef78ef2b11db5090f3e0c9

Contents?: true

Size: 1.82 KB

Versions: 10

Compression:

Stored size: 1.82 KB

Contents

= 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: 
 - http://everburning.com/news/eventmachine-screencast-em-http-request/

== 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 }

    # ...
  }

Version data entries

10 entries across 10 versions & 4 rubygems

Version Path
dwaite-em-http-request-0.1.10 README.rdoc
dwaite-em-http-request-0.1.9 README.rdoc
julien51-em-http-request-0.1.10 README.rdoc
julien51-em-http-request-0.1.11 README.rdoc
julien51-em-http-request-0.1.9 README.rdoc
igrigorik-em-http-request-0.1.8 README.rdoc
astro-em-http-request-0.1.15 README.rdoc
astro-em-http-request-0.1.14 README.rdoc
astro-em-http-request-0.1.13 README.rdoc
astro-em-http-request-0.1.12 README.rdoc