Selaa lähdekoodia

http2: remove duplicate map lookups in checkConnHeaders

Change-Id: I3fa5b27a4846807e8ed1265d696929037b77861b
Reviewed-on: https://go-review.googlesource.com/30160
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Brad Fitzpatrick 9 vuotta sitten
vanhempi
commit
0f2be02c5d
1 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. 4 4
      http2/transport.go

+ 4 - 4
http2/transport.go

@@ -626,11 +626,11 @@ func checkConnHeaders(req *http.Request) error {
 	if v := req.Header.Get("Upgrade"); v != "" {
 	if v := req.Header.Get("Upgrade"); v != "" {
 		return fmt.Errorf("http2: invalid Upgrade request header: %q", req.Header["Upgrade"])
 		return fmt.Errorf("http2: invalid Upgrade request header: %q", req.Header["Upgrade"])
 	}
 	}
-	if v := req.Header.Get("Transfer-Encoding"); (v != "" && v != "chunked") || len(req.Header["Transfer-Encoding"]) > 1 {
-		return fmt.Errorf("http2: invalid Transfer-Encoding request header: %q", req.Header["Transfer-Encoding"])
+	if vv := req.Header["Transfer-Encoding"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "chunked") {
+		return fmt.Errorf("http2: invalid Transfer-Encoding request header: %q", vv)
 	}
 	}
-	if v := req.Header.Get("Connection"); (v != "" && v != "close" && v != "keep-alive") || len(req.Header["Connection"]) > 1 {
-		return fmt.Errorf("http2: invalid Connection request header: %q", req.Header["Connection"])
+	if vv := req.Header["Connection"]; len(vv) > 0 && (len(vv) > 1 || vv[0] != "" && vv[0] != "close" && vv[0] != "keep-alive") {
+		return fmt.Errorf("http2: invalid Connection request header: %q", vv)
 	}
 	}
 	return nil
 	return nil
 }
 }