http2: merge multiple GOAWAY frames' contents into error message

The http2 spec permits multiple GOAWAY frames if the conditions
change.  Merge their error messages together, preferring the first
non-empty debug data, and first non-ErrCodeNo error code.

Updates golang/go#14627

Change-Id: I073b9234d71f128ed0713f09a24c728b56d7c1ae
Reviewed-on: https://go-review.googlesource.com/24600
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
diff --git a/http2/transport_test.go b/http2/transport_test.go
index e1274b0..39abde2 100644
--- a/http2/transport_test.go
+++ b/http2/transport_test.go
@@ -2044,7 +2044,7 @@
 			res.Body.Close()
 		}
 		want := GoAwayError{
-			LastStreamID: 0,
+			LastStreamID: 5,
 			ErrCode:      goAwayErrCode,
 			DebugData:    goAwayDebugData,
 		}
@@ -2077,7 +2077,10 @@
 					BlockFragment: buf.Bytes(),
 				})
 			}
-			ct.fr.WriteGoAway(0, goAwayErrCode, []byte(goAwayDebugData))
+			// Write two GOAWAY frames, to test that the Transport takes
+			// the interesting parts of both.
+			ct.fr.WriteGoAway(5, ErrCodeNo, []byte(goAwayDebugData))
+			ct.fr.WriteGoAway(5, goAwayErrCode, nil)
 			ct.sc.Close()
 			<-clientDone
 			return nil