class EventMachine::Protocols::HttpClient2

}
}
p(response.content)
p(response.headers)
p(response.status)
req.callback{ |response|
req = conn.get(‘/’)
conn = EM::Protocols::HttpClient2.connect ‘google.com’, 80
EM.run{
=== Usage
Note: This class is deprecated and will be removed. Please use EM-HTTP-Request instead.

def self.connect *args

:ssl => true to enable ssl
:port => a port number
:host => a hostname or ip-address
If the arguments are a hash, then supported values include:
a hostname/ip-address and a port), or a hash.
Can take either a pair of arguments (which will be interpreted as
Make a connection to a remote HTTP server.
def self.connect *args
  if args.length == 2
    args = {:host=>args[0], :port=>args[1]}
  else
    args = args.first
  end
  h,prt,ssl = args[:host], Integer(args[:port]), (args[:tls] || args[:ssl])
  conn = EM.connect( h, prt, self )
  conn.start_tls if ssl
  conn.set_default_host_header( h, prt, ssl )
  conn
end

def connection_completed

Other tags:
    Private: -
def connection_completed
  super
  @connected.succeed
end

def get args


req.callback{|response| puts response.content }
req = conn.get(:uri => '/')

Get a url
def get args
  if args.is_a?(String)
    args = {:uri=>args}
  end
  args[:verb] = "GET"
  request args
end

def initialize

def initialize
  warn "HttpClient2 is deprecated and will be removed. EM-Http-Request should be used instead."
  @authorization = nil
  @closed = nil
  @requests = nil
end

def pop_request

Other tags:
    Private: -
def pop_request
  @requests.pop
end

def post args

XXX there's no way to supply a POST body.. wtf?
--
req.callback{|response| puts response.content }
req = conn.post('/data')

Post to a url
def post args
  if args.is_a?(String)
    args = {:uri=>args}
  end
  args[:verb] = "POST"
  request args
end

def post_init

Other tags:
    Private: -
def post_init
  super
  @connected = EM::DefaultDeferrable.new
end

def receive_binary_data text

Other tags:
    Private: -
def receive_binary_data text
  @requests.last.receive_text text
end

def receive_line ln

Other tags:
    Private: -
def receive_line ln
  if req = @requests.last
    req.receive_line ln
  else
    p "??????????"
    p ln
  end
end

def request args

Other tags:
    Private: -
def request args
  args[:host_header] = @host_header unless args.has_key?(:host_header)
  args[:authorization] = @authorization unless args.has_key?(:authorization)
  r = Request.new self, args
  if @closed
    r.fail
  else
    (@requests ||= []).unshift r
    @connected.callback {r.send_request}
  end
  r
end

def set_default_host_header host, port, ssl

Other tags:
    Private: -
def set_default_host_header host, port, ssl
  if (ssl and port != 443) or (!ssl and port != 80)
    @host_header = "#{host}:#{port}"
  else
    @host_header = host
  end
end

def unbind

Other tags:
    Private: -
def unbind
  super
  @closed = true
  (@requests || []).each {|r| r.fail}
end