Global r.Close = true

This commit is contained in:
Jimmy Zelinskie 2013-11-23 18:33:35 -05:00
parent 86f8199bef
commit 31e618c8d9
3 changed files with 155 additions and 162 deletions

View file

@ -61,10 +61,6 @@ func (s *Server) serveScrape(w http.ResponseWriter, r *http.Request) {
}
io.WriteString(w, "e")
// Finish up and write headers
r.Close = true
w.Header().Add("Content-Type", "text/plain")
w.Header().Add("Connection", "close")
w.(http.Flusher).Flush()
}

View file

@ -81,6 +81,7 @@ func (s *Server) Stop() error {
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer atomic.AddInt64(&s.deltaRequests, 1)
r.Close = true
switch r.URL.Path {
case "/stats":
@ -112,10 +113,7 @@ func fail(err error, w http.ResponseWriter, r *http.Request) {
errmsg := err.Error()
message := "d14:failure reason" + strconv.Itoa(len(errmsg)) + ":" + errmsg + "e"
length, _ := io.WriteString(w, message)
r.Close = true
w.Header().Add("Content-Type", "text/plain")
w.Header().Add("Content-Length", string(length))
w.Header().Add("Connection", "close")
w.(http.Flusher).Flush()
}

View file

@ -20,7 +20,6 @@ type stats struct {
func (s *Server) serveStats(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Connection", "close")
stats, _ := json.Marshal(&stats{
config.Duration{time.Now().Sub(s.startTime)},