mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-15 00:00:39 -04:00
worked around the fact that jruby doesn't support refinement inheritance yet
This commit is contained in:
parent
44cb82602c
commit
062ccaac31
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user