From dd9f4524d1a829a394f5d96da0c1e6338c476019 Mon Sep 17 00:00:00 2001 From: Dan Hirsch Date: Sun, 27 Oct 2013 21:17:10 -0400 Subject: [PATCH] Make /events API send headers immediately Go's net/http API does not send headers until the first call to ResponseWriter.Write(). Ordinarily, this is fine, because in most cases, responses are returned immediately. However, for the events API, nothing is written until some event is sent, which causes timeouts and/or hangs in some HTTP client APIs, which wait for headers before returning from the "make request" call. --- api.go | 1 + 1 file changed, 1 insertion(+) diff --git a/api.go b/api.go index 6c1c47a001..517fe59923 100644 --- a/api.go +++ b/api.go @@ -236,6 +236,7 @@ func getEvents(srv *Server, version float64, w http.ResponseWriter, r *http.Requ } w.Header().Set("Content-Type", "application/json") wf := utils.NewWriteFlusher(w) + wf.Write([]byte{}) if since != 0 { // If since, send previous events that happened after the timestamp for _, event := range srv.events {