You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 using localhost: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?
l, err := net.Listen("tcp", ":0")
The text was updated successfully, but these errors were encountered:
ianlancetaylor
changed the title
httptest.Server uses ipv4 instead of using both Ipv4 and Ipv6
net/http/httptest: Server uses ipv4 instead of using both Ipv4 and Ipv6
Jan 8, 2025
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: