igrigorik-em-http-request 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/em-http-request.gemspec +1 -1
- data/lib/em-http/request.rb +1 -1
- data/test/test_request.rb +15 -0
- metadata +1 -1
data/em-http-request.gemspec
CHANGED
data/lib/em-http/request.rb
CHANGED
@@ -27,7 +27,7 @@ module EventMachine
|
|
27
27
|
|
28
28
|
def initialize(host, headers = {})
|
29
29
|
@headers = headers
|
30
|
-
@uri = URI
|
30
|
+
@uri = host.kind_of?(URI) ? host : URI::parse(host)
|
31
31
|
end
|
32
32
|
|
33
33
|
# Send an HTTP request and consume the response. Supported options:
|
data/test/test_request.rb
CHANGED
@@ -53,6 +53,20 @@ describe EventMachine::HttpRequest do
|
|
53
53
|
}
|
54
54
|
}
|
55
55
|
end
|
56
|
+
|
57
|
+
it "should perform successfull GET with a URI passed as argument" do
|
58
|
+
EventMachine.run {
|
59
|
+
uri = URI.parse('http://127.0.0.1:8080/')
|
60
|
+
http = EventMachine::HttpRequest.new(uri).get
|
61
|
+
|
62
|
+
http.errback { failed }
|
63
|
+
http.callback {
|
64
|
+
http.response_header.status.should == 200
|
65
|
+
http.response.should match(/Hello/)
|
66
|
+
EventMachine.stop
|
67
|
+
}
|
68
|
+
}
|
69
|
+
end
|
56
70
|
|
57
71
|
it "should return 404 on invalid path" do
|
58
72
|
EventMachine.run {
|
@@ -262,4 +276,5 @@ describe EventMachine::HttpRequest do
|
|
262
276
|
}
|
263
277
|
}
|
264
278
|
end
|
279
|
+
|
265
280
|
end
|