public
Fork of igrigorik/em-http-request
Description: EventMachine based HTTP Request interface
Homepage:
Clone URL: git://github.com/eventmachine/em-http-request.git
igrigorik (author)
Mon Feb 16 21:33:57 -0800 2009
commit  1ee05252d0ae1d52188e72b705194058d204c123
tree    8eafe96a0b3f38795ab2a94c37b26f1796589354
parent  26dc93ed18b9b1c69d32d41540b593e65733c1a3
name age message
file .autotest Fri Aug 22 10:56:57 -0700 2008 initial import [igrigorik]
file LICENSE Fri Aug 22 10:56:57 -0700 2008 initial import [igrigorik]
file README Thu Oct 16 21:20:09 -0700 2008 Added EventMachine::MultiRequest for running pa... [igrigorik]
file Rakefile Sun Aug 24 06:50:59 -0700 2008 cleanup [igrigorik]
directory ext/ Fri Aug 22 10:56:57 -0700 2008 initial import [igrigorik]
directory lib/ Mon Feb 16 21:33:57 -0800 2009 *head fake* gzip + deflate support for real thi... [igrigorik]
directory test/ Mon Feb 16 21:33:57 -0800 2009 *head fake* gzip + deflate support for real thi... [igrigorik]
README
EventMachine based HTTP Request interface. Supports streaming response processing / based on Zed Shaw's Ragel HTTP 
parser. 
 - Borrows a lot of good concepts from Rev's HttpClient, Curb, and other libraries.
 - Offers support for single or parallel request queries & via deferred callbacks

Simple client example: 
--------

EventMachine.run {
  http = EventMachine::HttpRequest.new('http://127.0.0.1/').get :query => {'keyname' => 'value'}
 
  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
  }
}