diff --git a/command/agent/http.go b/command/agent/http.go index 7d952881a0..87260cf8e6 100644 --- a/command/agent/http.go +++ b/command/agent/http.go @@ -362,10 +362,17 @@ func (s *HTTPServer) wrap(handler func(resp http.ResponseWriter, req *http.Reque func (s *HTTPServer) marshalJSON(req *http.Request, obj interface{}) ([]byte, error) { if _, ok := req.URL.Query()["pretty"]; ok { buf, err := json.MarshalIndent(obj, "", " ") - return buf, err + if err != nil { + return nil, err + } + buf = append(buf, "\n"...) + return buf, nil } buf, err := json.Marshal(obj) + if err != nil { + return nil, err + } return buf, err } diff --git a/command/agent/http_test.go b/command/agent/http_test.go index 685f5cbd44..3c9c114fd8 100644 --- a/command/agent/http_test.go +++ b/command/agent/http_test.go @@ -328,6 +328,7 @@ func testPrettyPrint(pretty string, t *testing.T) { srv.wrap(handler)(resp, req) expected, _ := json.MarshalIndent(r, "", " ") + expected = append(expected, "\n"...) actual, err := ioutil.ReadAll(resp.Body) if err != nil { t.Fatalf("err: %s", err)