diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2011-03-09 10:24:50 -0800 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2011-03-09 10:24:50 -0800 |
| commit | ec5c4759190006261014c08aceccb6f99aa53d50 (patch) | |
| tree | 1bd8a2d655e7b78a11a8f18fe276bb4740ce1aa0 /src/pkg/http/server.go | |
| parent | 2ac4d5270f65464c136cf978ad61f293e393f0d3 (diff) | |
| download | go-ec5c4759190006261014c08aceccb6f99aa53d50.tar.xz | |
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
Diffstat (limited to 'src/pkg/http/server.go')
| -rw-r--r-- | src/pkg/http/server.go | 9 |
1 files changed, 9 insertions, 0 deletions
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() } |
