From d03283d6dc70c125d9f79700224acc604c8b9506 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 13 Oct 2022 11:41:43 +0900 Subject: [PATCH] Raise ArgumentError with empty host url again. Fixup ruby/ruby@dd5118f8524c425894d4716b787837ad7380bb0d ruby/ruby@1cda4146224e857f6258241bbb30d9358ce2d6c7 Co-authored-by: Koichi Sasada --- lib/net/http/generic_request.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/net/http/generic_request.rb b/lib/net/http/generic_request.rb index 313de6ac..d56835c7 100644 --- a/lib/net/http/generic_request.rb +++ b/lib/net/http/generic_request.rb @@ -15,7 +15,8 @@ def initialize(m, reqbody, resbody, uri_or_path, initheader = nil) if URI === uri_or_path then raise ArgumentError, "not an HTTP URI" unless URI::HTTP === uri_or_path - raise ArgumentError, "no host component for URI" unless uri_or_path.hostname + hostname = uri_or_path.hostname + raise ArgumentError, "no host component for URI" unless (hostname && hostname.length > 0) @uri = uri_or_path.dup host = @uri.hostname.dup host << ":".freeze << @uri.port.to_s if @uri.port != @uri.default_port