worked around the fact that jruby doesn't support refinement inheritance yet

This commit is contained in:
HoneyryderChuck 2019-03-16 04:50:49 +00:00
parent 44cb82602c
commit 062ccaac31

View File

@ -55,26 +55,35 @@ module HTTPX
end
module URIExtensions
refine URI::Generic do
def authority
port_string = port == default_port ? nil : ":#{port}"
"#{host}#{port_string}"
end
URI_KLASSES = case RUBY_ENGINE
when "jruby"
[URI::Generic, URI::HTTP, URI::HTTPS]
else
[URI::Generic]
end
def origin
"#{scheme}://#{authority}"
end
URI_KLASSES.each do |klass|
refine klass do
def authority
port_string = port == default_port ? nil : ":#{port}"
"#{host}#{port_string}"
end
def altsvc_match?(uri)
uri = URI.parse(uri)
self == uri || begin
case scheme
when 'h2'
uri.scheme == "https" &&
host == uri.host &&
(port || default_port) == (uri.port || uri.default_port)
else
false
def origin
"#{scheme}://#{authority}"
end
def altsvc_match?(uri)
uri = URI.parse(uri)
self == uri || begin
case scheme
when 'h2'
uri.scheme == "https" &&
host == uri.host &&
(port || default_port) == (uri.port || uri.default_port)
else
false
end
end
end
end