mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-12-06 00:00:28 -05:00
raise invalid uri if passed request uri does not contain the host part
This commit is contained in:
parent
599b6865da
commit
02ed2ae87d
@ -83,7 +83,7 @@ module HTTPX
|
||||
|
||||
@options = @body.options
|
||||
|
||||
if @uri.relative?
|
||||
if @uri.relative? || @uri.host.nil?
|
||||
origin = @options.origin
|
||||
raise(Error, "invalid URI: #{@uri}") unless origin
|
||||
|
||||
|
||||
@ -2,6 +2,13 @@
|
||||
|
||||
module Requests
|
||||
module Errors
|
||||
def test_errors_invalid_uri
|
||||
exc = assert_raises { HTTPX.get("/get") }
|
||||
assert exc.message.include?("invalid URI: /get")
|
||||
exc = assert_raises { HTTPX.get("http:/smth/get") }
|
||||
assert exc.message.include?("invalid URI: http:/smth/get")
|
||||
end
|
||||
|
||||
def test_errors_connection_refused
|
||||
unavailable_host = URI(origin("localhost"))
|
||||
unavailable_host.port = next_available_port
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user