diff --git a/examples/stream.go b/examples/stream.go index 9bda175..1a6e2e4 100644 --- a/examples/stream.go +++ b/examples/stream.go @@ -37,7 +37,8 @@ func main() { func stream(w *gemini.ResponseWriter, r *gemini.Request) { for { - fmt.Fprintln(w, time.Now()) + fmt.Fprintln(w, time.Now().UTC()) + w.Flush() time.Sleep(time.Second) } } diff --git a/server.go b/server.go index 20d57bf..5643dcd 100644 --- a/server.go +++ b/server.go @@ -283,7 +283,7 @@ func (w *ResponseWriter) SetMediaType(mediatype string) { w.mediatype = mediatype } -// Write writes the response body. +// Write writes data to the connection as part of the response body. // If the response status does not allow for a response body, Write returns // ErrBodyNotAllowed. // @@ -303,6 +303,11 @@ func (w *ResponseWriter) Write(b []byte) (int, error) { return w.b.Write(b) } +// Flush writes any buffered data to the underlying io.Writer. +func (w *ResponseWriter) Flush() error { + return w.b.Flush() +} + // A Responder responds to a Gemini request. type Responder interface { // Respond accepts a Request and constructs a Response.