From: Brad Fitzpatrick Date: Wed, 9 Mar 2011 18:24:50 +0000 (-0800) Subject: http: add Flusher type; remove Flush from ResponseWriter X-Git-Tag: weekly.2011-03-15~61 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ec5c4759190006261014c08aceccb6f99aa53d50;p=gostls13.git http: add Flusher type; remove Flush from ResponseWriter The Flush functionality wasn't removed, but now you have to test if your ResponseWriter is also a Flusher: func ServeHTTP(rw http.ResponseWriter, req *http.Request) { if f, ok := rw.(http.Flusher); ok { f.Flush() } } R=rsc, bradfitzwork CC=gburd, golang-dev https://golang.org/cl/4239077 --- diff --git a/src/pkg/http/server.go b/src/pkg/http/server.go index 8a8cdd9332..5f36af5484 100644 --- a/src/pkg/http/server.go +++ b/src/pkg/http/server.go @@ -70,7 +70,16 @@ type ResponseWriter interface { // Thus explicit calls to WriteHeader are mainly used to // send error codes. WriteHeader(int) +} +// The Flusher interface is implemented by ResponseWriters that allow +// an HTTP handler to flush buffered data to the client. +// +// Note that even for ResponseWriters that support Flush, +// if the client is connected through an HTTP proxy, +// the buffered data may not reach the client until the response +// completes. +type Flusher interface { // Flush sends any buffered data to the client. Flush() }