Class EventMachine::HttpRequest
In: lib/em-http/request.rb
lib/em-http/version.rb
Parent: Object

EventMachine based HTTP request class with support for streaming consumption of the response. Response is parsed with a Ragel-generated whitelist parser which supports chunked HTTP encoding.

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

Methods

delete   get   head   new   post   put   send_request   setup_request  

Constants

VERSION = "0.3.0"

Attributes

method  [R] 
options  [R] 

Public Class methods

Public Instance methods

Send an HTTP request and consume the response. Supported options:

  head: {Key: Value}
    Specify an HTTP header, e.g. {'Connection': 'close'}

  query: {Key: Value}
    Specify query string parameters (auto-escaped)

  body: String
    Specify the request body (you must encode it for now)

  on_response: Proc
    Called for each response body chunk (you may assume HTTP 200
    OK then)

Protected Instance methods

[Validate]