]> Cypherpunks repositories - gostls13.git/commitdiff
http: add Flusher type; remove Flush from ResponseWriter
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 9 Mar 2011 18:24:50 +0000 (10:24 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 9 Mar 2011 18:24:50 +0000 (10:24 -0800)
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

src/pkg/http/server.go

index 8a8cdd93328f07fe188774a47da46aa02b7b0a0d..5f36af5484cee5abfdebf089f257c15d02403e11 100644 (file)
@@ -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()
 }