diff --git a/README.md b/README.md index 50d19d5..c7e4cf2 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@
- Release/stability diff --git a/doc.go b/doc.go index 98443c4..b4dbce1 100644 --- a/doc.go +++ b/doc.go @@ -5,13 +5,13 @@ Source code and other details for the project are available at GitHub: Current Version -1.0.7 +1.0.8 Installation The only requirement is the Go Programming Language - $ go get -u github.com/kataras/muxie + $ go get github.com/kataras/muxie Examples diff --git a/params_writer.go b/params_writer.go index 023eefc..14fe932 100644 --- a/params_writer.go +++ b/params_writer.go @@ -105,3 +105,25 @@ func (pw *paramsWriter) reset(w http.ResponseWriter) { pw.ResponseWriter = w pw.params = pw.params[0:0] } + +// Flusher indicates if `Flush` is supported by the client. +// +// The default HTTP/1.x and HTTP/2 ResponseWriter implementations +// support Flusher, but ResponseWriter wrappers may not. Handlers +// should always test for this ability at runtime. +// +// 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. +func (pw *paramsWriter) Flusher() (http.Flusher, bool) { + flusher, canFlush := pw.ResponseWriter.(http.Flusher) + return flusher, canFlush +} + +// Flush sends any buffered data to the client. +func (pw *paramsWriter) Flush() { + if flusher, ok := pw.Flusher(); ok { + flusher.Flush() + } +}