forked from igrigorik/em-http-request
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
36 lines (27 loc) · 997 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
}
}