Commit ec5c4759 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

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
parent 2ac4d527
...@@ -70,7 +70,16 @@ type ResponseWriter interface { ...@@ -70,7 +70,16 @@ type ResponseWriter interface {
// Thus explicit calls to WriteHeader are mainly used to // Thus explicit calls to WriteHeader are mainly used to
// send error codes. // send error codes.
WriteHeader(int) 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 sends any buffered data to the client.
Flush() Flush()
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment