Open
Description
go version go1.5 linux/amd64
Ubuntu 14.04.3 LTS
I made an HTTP request to a server that accepts all TCP connections and then immediately closes them. I was expecting a meaningful error such as "connection closed before request could be sent" but http.RoundTrip returned EOF.
Here are client and server snippets that reproduce this. The client:
package main
import (
"fmt"
"net"
"net/http"
)
func main() {
dialer := &net.Dialer{}
transport := &http.Transport{
Dial: dialer.Dial,
}
request, _ := http.NewRequest("GET", "http://127.0.0.1:19870/", nil)
_, err := transport.RoundTrip(request)
fmt.Println(err)
}
Output is:
EOF
And the server:
package main
import "net"
func main() {
ln, _ := net.Listen("tcp", ":19870")
conn, _ := ln.Accept()
conn.Close()
}
Here is a dump of the TCP exchange:
17:16:31.017342 IP localhost.52287 > localhost.19870: Flags [S], seq 3991906392, win 43690, options [mss 65495,sackOK,TS val 27880590 ecr 0,nop,wscale 7], length 0
E..<..@.@.w..........?M....X.........0.........
..l.........
17:16:31.017356 IP localhost.19870 > localhost.52287: Flags [S.], seq 530413255, ack 3991906393, win 43690, options [mss 65495,sackOK,TS val 27880590 ecr 27880590,nop,wscale 7], length 0
E..<..@.@.<.........M..?..v....Y.....0.........
..l...l.....
17:16:31.017367 IP localhost.52287 > localhost.19870: Flags [.], ack 1, win 342, options [nop,nop,TS val 27880590 ecr 27880590], length 0
E..4..@.@.w..........?M....Y..v....V.(.....
..l...l.
17:16:31.017514 IP localhost.19870 > localhost.52287: Flags [F.], seq 1, ack 1, win 342, options [nop,nop,TS val 27880591 ecr 27880590], length 0
E..4.F@.@."|........M..?..v....Y...V.(.....
..l...l.
17:16:31.019472 IP localhost.52287 > localhost.19870: Flags [F.], seq 1, ack 2, win 342, options [nop,nop,TS val 27880591 ecr 27880591], length 0
E..4..@.@.w..........?M....Y..v....V.(.....
..l...l.
17:16:31.019493 IP localhost.19870 > localhost.52287: Flags [.], ack 2, win 342, options [nop,nop,TS val 27880591 ecr 27880591], length 0
E..4.G@.@."{........M..?..v....Z...V.(.....
..l...l.