Browse Source

http2: delete pre-Go1.5 request cancellation

This was always a no-op in 1.4 and earlier. This change directly
inlines the 1.5 version.

Change-Id: I6dcf69497d876d7dde729c1801cef5382b97fa07
Reviewed-on: https://go-review.googlesource.com/22388
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Dave Day 9 years ago
parent
commit
b797637b7a
3 changed files with 2 additions and 25 deletions
  1. 0 11
      http2/go15.go
  2. 0 11
      http2/not_go15.go
  3. 2 3
      http2/transport.go

+ 0 - 11
http2/go15.go

@@ -1,11 +0,0 @@
-// Copyright 2015 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.
-
-// +build go1.5
-
-package http2
-
-import "net/http"
-
-func requestCancel(req *http.Request) <-chan struct{} { return req.Cancel }

+ 0 - 11
http2/not_go15.go

@@ -1,11 +0,0 @@
-// Copyright 2015 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.
-
-// +build !go1.5
-
-package http2
-
-import "net/http"
-
-func requestCancel(req *http.Request) <-chan struct{} { return nil }

+ 2 - 3
http2/transport.go

@@ -683,7 +683,6 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) {
 	}
 	}
 
 
 	readLoopResCh := cs.resc
 	readLoopResCh := cs.resc
-	requestCanceledCh := requestCancel(req)
 	bodyWritten := false
 	bodyWritten := false
 
 
 	for {
 	for {
@@ -717,7 +716,7 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) {
 				cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel)
 				cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel)
 			}
 			}
 			return nil, errTimeout
 			return nil, errTimeout
-		case <-requestCanceledCh:
+		case <-req.Cancel:
 			cc.forgetStreamID(cs.ID)
 			cc.forgetStreamID(cs.ID)
 			if !hasBody || bodyWritten {
 			if !hasBody || bodyWritten {
 				cc.writeStreamReset(cs.ID, ErrCodeCancel, nil)
 				cc.writeStreamReset(cs.ID, ErrCodeCancel, nil)
@@ -1285,7 +1284,7 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
 	cs.bufPipe = pipe{b: buf}
 	cs.bufPipe = pipe{b: buf}
 	cs.bytesRemain = res.ContentLength
 	cs.bytesRemain = res.ContentLength
 	res.Body = transportResponseBody{cs}
 	res.Body = transportResponseBody{cs}
-	go cs.awaitRequestCancel(requestCancel(cs.req))
+	go cs.awaitRequestCancel(cs.req.Cancel)
 
 
 	if cs.requestedGzip && res.Header.Get("Content-Encoding") == "gzip" {
 	if cs.requestedGzip && res.Header.Get("Content-Encoding") == "gzip" {
 		res.Header.Del("Content-Encoding")
 		res.Header.Del("Content-Encoding")