blob: 16db5ae04feae63ea18a5d062b0a4ff572ae83c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
require 'nickserver/adapters'
require 'em-http'
module Nickserver::Adapters
class EmHttp
def initialize
@timeout = 5
end
def get(url, options = {})
get_request(url, options).callback {|http|
yield http.response_header.status, http.response
}.errback {|http|
yield 0, http.error
}
end
def get_request(url, options = {})
@request = EventMachine::HttpRequest.new(url)
@request.get timeout: @timeout, query: options[:query]
end
end
end
|