-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http/httptest: Server uses ipv4 instead of using both Ipv4 and Ipv6 #71178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
CC @neild |
Duplicate of #56998 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go version
go version go1.21.0 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Create a httptest.Server using the NewServer.
Run the test:
What did you see happen?
After drilling down, the listener created for httptest.Server is IPv4 only:
go/src/net/http/httptest/server.go
Line 68 in 39f2032
and uses 127.0.0.1:0.
The test fails because at some point the client starts using IPv6. The server simply doesn't respond.
What did you expect to see?
At least a better error. Simply returning EOF doesn't remotely help pinpoint the error.
You can argue that I should have used
srv.URL
instead of parsing the port and usinglocalhost:port
. However, in real world scenarios the code expects a port and runs a DNS lookup.Even better, why not listen at both ipv4 and ipv6 by default?
The text was updated successfully, but these errors were encountered: