11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/gnarly/client/emhttp.rb', line 11
def http(request, options={}, &block)
if block
method, url, , body = request
opts = {}
opts[:head] = if
case url
when Array
url, query = url
opts[:query] = query
end
http = EventMachine::HttpRequest.new(url).__send__(method, opts)
http.stream &options[:stream] if options[:stream]
http.callback {
= Client. http..to_hash
block.call [http..status, , http.response]
}
else
raise :async_only
end
end
|