1
0
Fork 0
mirror of https://git.sr.ht/~adnano/go-gemini synced 2024-06-01 17:56:04 +02:00

Add ResponseWriter.Flush function

This commit is contained in:
Adnan Maolood 2020-12-18 13:15:17 -05:00
parent a912ef996a
commit 61b417a5c4
2 changed files with 8 additions and 2 deletions

View File

@ -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)
}
}

View File

@ -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.