Sha256: d69733f211c10106414776609a021ccde93b6eac57882449a9fb33b2c22c86c1

Contents?: true

Size: 2 KB

Versions: 6

Compression:

Stored size: 2 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/

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

    # ...
  }

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
em-http-request-0.2.4 README.rdoc
em-http-request-0.2.3 README.rdoc
astro-em-http-request-0.2.3 README.rdoc
astro-em-http-request-0.2.2 README.rdoc
em-http-request-0.2.2 README.rdoc
em-http-request-0.2.1 README.rdoc