mirror of
https://github.com/golang/go
synced 2024-11-13 18:00:30 -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:
parent
d296fa1c95
commit
c4b9c8bb7d
@ -24,4 +24,9 @@ GOFILES=\
|
|||||||
transfer.go\
|
transfer.go\
|
||||||
transport.go\
|
transport.go\
|
||||||
|
|
||||||
|
GOFILES_windows=\
|
||||||
|
transport_windows.go\
|
||||||
|
|
||||||
|
GOFILES+=$(GOFILES_$(GOOS))
|
||||||
|
|
||||||
include ../../Make.pkg
|
include ../../Make.pkg
|
||||||
|
@ -489,12 +489,24 @@ func (pc *persistConn) expectingResponse() bool {
|
|||||||
return pc.numExpectedResponses > 0
|
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() {
|
func (pc *persistConn) readLoop() {
|
||||||
alive := true
|
alive := true
|
||||||
for alive {
|
for alive {
|
||||||
pb, err := pc.br.Peek(1)
|
pb, err := pc.br.Peek(1)
|
||||||
if err != nil {
|
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
|
// Remote side closed on us. (We probably hit their
|
||||||
// max idle timeout)
|
// max idle timeout)
|
||||||
pc.close()
|
pc.close()
|
||||||
|
21
src/pkg/http/transport_windows.go
Normal file
21
src/pkg/http/transport_windows.go
Normal 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
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user