2

The following the example works very nicely for HTTP: Send a chunked HTTP response from a Go server

As soon as I add TLS, I see that the responses are no longer chunked:

func main() {
  http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    flusher, ok := w.(http.Flusher)
    if !ok {
      panic("expected http.ResponseWriter to be an http.Flusher")
    }
    w.Header().Set("X-Content-Type-Options", "nosniff")
    for i := 1; i <= 10; i++ {
      fmt.Fprintf(w, "Chunk #%d\n", i)
      flusher.Flush() // Trigger "chunked" encoding and send a chunk...
      time.Sleep(500 * time.Millisecond)
    }
  })

  log.Print("Listening on localhost:8080")
  log.Fatal(http.ListenAndServeTLS(":8080", "<CERT_FILE>", "<KEY_FILE>", nil))
}

Any ideas why this might be?

Mike Eller
  • 31
  • 4

1 Answers1

1
log.Infof("Protocol Version: %s", request.Proto)

Confirms its using HTTP/2.0

Thanks Vorsprung

Mike Eller
  • 31
  • 4