hostip: resolve *.localhost to 127.0.0.1/::1

Following the footsteps of other clients like Firefox/Chrome.  RFC 6761
says clients SHOULD do this.

Add test 389 to verify.

Reported-by: TheKnarf on github
Fixes #9192
Closes #9296
This commit is contained in:
Daniel Stenberg 2022-08-11 11:32:22 +02:00
parent 586cfc3c2c
commit b5c0fe20e3
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 82 additions and 14 deletions

57
tests/data/test389 Normal file
View file

@ -0,0 +1,57 @@
<testcase>
<info>
<keywords>
HTTP
.localhost
</keywords>
</info>
#
# Server-side
<reply>
<data>
HTTP/1.1 200 OK
Date: Tue, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
ETag: "21025-dc7-39462498"
Accept-Ranges: bytes
Content-Length: 6
Connection: close
Content-Type: text/html
Funny-head: yesyes
-foo-
</data>
</reply>
#
# Client-side
<client>
<server>
http
</server>
<name>
*.localhost is a local host
</name>
<command>
http://curlmachine.localhost:%HTTPPORT/%TESTNUMBER
</command>
# Ensure that we're running on localhost
<precheck>
perl -e "print 'Test requires default test server host' if ( '%HOSTIP' ne '127.0.0.1' );"
</precheck>
</client>
#
# Verify data after the test has been "shot"
<verify>
<protocol>
GET /%TESTNUMBER HTTP/1.1
Host: curlmachine.localhost:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
</protocol>
</verify>
</testcase>