Commit c4b9c8bb authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

http: shut up a false Transport warning on Windows

Fixes #2057

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5269044
parent d296fa1c
......@@ -24,4 +24,9 @@ GOFILES=\
transfer.go\
transport.go\
GOFILES_windows=\
transport_windows.go\
GOFILES+=$(GOFILES_$(GOOS))
include ../../Make.pkg
......@@ -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()
......
// 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
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment