summaryrefslogtreecommitdiff
path: root/lang/go/patches/patch-src_net_http_h2__bundle.go
blob: 5ef3dceb5ea86a68e8b1841c00dc43b9e26293ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$NetBSD: patch-src_net_http_h2__bundle.go,v 1.1 2016/09/17 15:56:58 bsiegert Exp $

From: Brad Fitzpatrick <bradfitz@golang.org>
Date: Mon, 12 Sep 2016 14:44:02 +0000
Subject: [PATCH] http2: don't sniff first Request.Body byte in Transport until we have a conn

bodyAndLength mutates Request.Body if Request.ContentLength == 0,
reading the first byte to determine whether it's actually empty or
just undeclared. But we did that before we checked whether our
connection was overloaded, which meant the caller could retry the
request on an new or lesser-loaded connection, but then lose the first
byte of the request.

Updates golang/go#17071 (needs bundle into std before fixed)

--- src/net/http/h2_bundle.go.orig	2016-09-07 19:34:35.000000000 +0000
+++ src/net/http/h2_bundle.go
@@ -5486,9 +5486,6 @@ func (cc *http2ClientConn) RoundTrip(req
 	}
 	hasTrailers := trailers != ""
 
-	body, contentLen := http2bodyAndLength(req)
-	hasBody := body != nil
-
 	cc.mu.Lock()
 	cc.lastActive = time.Now()
 	if cc.closed || !cc.canTakeNewRequestLocked() {
@@ -5496,6 +5493,9 @@ func (cc *http2ClientConn) RoundTrip(req
 		return nil, http2errClientConnUnusable
 	}
 
+	body, contentLen := http2bodyAndLength(req)
+	hasBody := body != nil
+
 	// TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere?
 	var requestedGzip bool
 	if !cc.t.disableCompression() &&