1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:34:40 -07:00

http: shut up a false Transport warning on Windows

Fixes #2057

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5269044
This commit is contained in:
Brad Fitzpatrick 2011-10-14 11:31:00 -07:00
parent d296fa1c95
commit c4b9c8bb7d
3 changed files with 39 additions and 1 deletions

View File

@ -24,4 +24,9 @@ GOFILES=\
transfer.go\
transport.go\
GOFILES_windows=\
transport_windows.go\
GOFILES+=$(GOFILES_$(GOOS))
include ../../Make.pkg

View File

@ -489,12 +489,24 @@ func (pc *persistConn) expectingResponse() bool {
return pc.numExpectedResponses > 0
}
var remoteSideClosedFunc func(os.Error) bool // or nil to use default
func remoteSideClosed(err os.Error) bool {
if err == os.EOF || err == os.EINVAL {
return true
}
if remoteSideClosedFunc != nil {
return remoteSideClosedFunc(err)
}
return false
}
func (pc *persistConn) readLoop() {
alive := true
for alive {
pb, err := pc.br.Peek(1)
if err != nil {
if (err == os.EOF || err == os.EINVAL) && !pc.expectingResponse() {
if remoteSideClosed(err) && !pc.expectingResponse() {
// Remote side closed on us. (We probably hit their
// max idle timeout)
pc.close()

View File

@ -0,0 +1,21 @@
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package http
import (
"os"
"net"
)
func init() {
remoteSideClosedFunc = func(err os.Error) (out bool) {
op, ok := err.(*net.OpError)
if ok && op.Op == "WSARecv" && op.Net == "tcp" && op.Error == os.Errno(10058) {
// TODO(bradfitz): find the symbol for 10058
return true
}
return false
}
}