Browse Source

http2/h2demo: flush headers earlier in demo /ECHO handler

It confused somebody who thought things were hanging because they had
expected to see a response before they started streaming data.

Change-Id: If672956efde3756c966b0c88b9c15ed21daeccba
Reviewed-on: https://go-review.googlesource.com/125644
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Brad Fitzpatrick 7 years ago
parent
commit
3673e40ba2
1 changed files with 3 additions and 0 deletions
  1. 3 0
      http2/h2demo/h2demo.go

+ 3 - 0
http2/h2demo/h2demo.go

@@ -160,6 +160,9 @@ func echoCapitalHandler(w http.ResponseWriter, r *http.Request) {
 		http.Error(w, "PUT required.", 400)
 		return
 	}
+	if f, ok := w.(http.Flusher); ok {
+		f.Flush()
+	}
 	io.Copy(flushWriter{w}, capitalizeReader{r.Body})
 }