From cb28c2639882c4713a42bf66d2e8cebd863cdd1f Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 13 Jun 2014 18:16:03 -0700 Subject: [PATCH] Setting application/json for json result. Setting application/javascript for jsonp result. --- go/weed/weed_server/common.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/go/weed/weed_server/common.go b/go/weed/weed_server/common.go index 8d8c91da6..a547d7462 100644 --- a/go/weed/weed_server/common.go +++ b/go/weed/weed_server/common.go @@ -25,7 +25,6 @@ func init() { } func writeJson(w http.ResponseWriter, r *http.Request, obj interface{}) (err error) { - w.Header().Set("Content-Type", "application/javascript") var bytes []byte if r.FormValue("pretty") != "" { bytes, err = json.MarshalIndent(obj, "", " ") @@ -37,8 +36,10 @@ func writeJson(w http.ResponseWriter, r *http.Request, obj interface{}) (err err } callback := r.FormValue("callback") if callback == "" { + w.Header().Set("Content-Type", "application/json") _, err = w.Write(bytes) } else { + w.Header().Set("Content-Type", "application/javascript") if _, err = w.Write([]uint8(callback)); err != nil { return }