Skip to content

Commit 0f11811

Browse files
authored
Allow Async::HTTP::Internet methods to accept URI::HTTP objects. (#118)
* `URI::HTTP` objects do not define a `to_str` method, so use `to_s` instead.
1 parent 2da8b15 commit 0f11811

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/async/http/endpoint.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def self.[](url)
3939
if url.is_a?(Endpoint)
4040
return url
4141
else
42-
Endpoint.parse(url.to_str)
42+
Endpoint.parse(url.to_s)
4343
end
4444
end
4545

test/async/http/internet.rb

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@
2323
response.close
2424
end
2525

26+
it "can accept URI::HTTP objects" do
27+
uri = URI.parse("https://www.codeotaku.com/index")
28+
response = internet.get(uri, headers)
29+
30+
expect(response).to be(:success?)
31+
ensure
32+
response&.close
33+
end
34+
2635
let(:sample) {{"hello" => "world"}}
2736
let(:body) {[JSON.dump(sample)]}
2837

0 commit comments

Comments
 (0)