mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-12-08 00:00:58 -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
|
@options = @body.options
|
||||||
|
|
||||||
if @uri.relative?
|
if @uri.relative? || @uri.host.nil?
|
||||||
origin = @options.origin
|
origin = @options.origin
|
||||||
raise(Error, "invalid URI: #{@uri}") unless origin
|
raise(Error, "invalid URI: #{@uri}") unless origin
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
module Requests
|
module Requests
|
||||||
module Errors
|
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
|
def test_errors_connection_refused
|
||||||
unavailable_host = URI(origin("localhost"))
|
unavailable_host = URI(origin("localhost"))
|
||||||
unavailable_host.port = next_available_port
|
unavailable_host.port = next_available_port
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user