using punycode name as the authority in the headers, which is actually a bugfix

This commit is contained in:
HoneyryderChuck 2021-06-11 18:51:57 +01:00
parent 4df2363cc5
commit 0c7712ca88
3 changed files with 8 additions and 4 deletions

View File

@ -78,7 +78,7 @@ module HTTPX
def authority
port_string = port == default_port ? nil : ":#{port}"
"#{@non_ascii_hostname || host}#{port_string}"
"#{host}#{port_string}"
end
def origin

View File

@ -17,12 +17,12 @@ module ResponseHelpers
if value.respond_to?(:start_with?)
assert value.start_with?(expect), "#{meth} assertion failed: \#{key}=\#{value} (expected: \#{expect}})"
else
assert value == expect, "#{meth} assertion failed: \#{key}=\#{value.to_s} (expected: \#{expect.to_s})"
assert value == expect, "#{meth} assertion failed: \#{key}=\#{value.inspect} (expected: \#{expect.to_s})"
end
end
def verify_no_#{meth}(#{meth}s, key)
assert !#{meth}s.key?(key), "#{meth}s contains the given key (" + key + ": \#{#{meth}s[key]})"
assert !#{meth}s.key?(key), "#{meth}s contains the given key (" + key + ": \#{#{meth}s[key].inspect})"
end
DEFINE
end

View File

@ -96,8 +96,12 @@ module Requests
def test_get_idn
response = HTTPX.get("http://bücher.ch")
verify_status(response, 200)
verify_status(response, 301)
verify_header(response.headers, "location", "https://www.buecher.de")
response.close
assert response.instance_variable_get(:@request).authority == "xn--bcher-kva.ch"
end unless RUBY_VERSION < "2.3"
def test_get_non_ascii