Browse Source

Merge pull request #314 from xiangli-cmu/fix-content-type

fix set content-type to application/json
Xiang Li 12 years ago
parent
commit
01a0f79efb
2 changed files with 3 additions and 0 deletions
  1. 2 0
      server/server.go
  2. 1 0
      server/v2/get_handler.go

+ 2 - 0
server/server.go

@@ -160,6 +160,7 @@ func (s *Server) handleFunc(path string, f func(http.ResponseWriter, *http.Reque
 		if err := f(w, req); err != nil {
 			if etcdErr, ok := err.(*etcdErr.Error); ok {
 				log.Debug("Return error: ", (*etcdErr).Error())
+				w.Header().Set("Content-Type", "application/json")
 				etcdErr.Write(w)
 			} else {
 				http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -260,6 +261,7 @@ func (s *Server) Dispatch(c raft.Command, w http.ResponseWriter, req *http.Reque
 			e, _ := result.(*store.Event)
 			b, _ = json.Marshal(e)
 
+			w.Header().Set("Content-Type", "application/json")
 			// etcd index should be the same as the event index
 			// which is also the last modified index of the node
 			w.Header().Add("X-Etcd-Index", fmt.Sprint(e.Index))

+ 1 - 0
server/v2/get_handler.go

@@ -68,6 +68,7 @@ func GetHandler(w http.ResponseWriter, req *http.Request, s Server) error {
 		}
 	}
 
+	w.Header().Set("Content-Type", "application/json")
 	w.Header().Add("X-Etcd-Index", fmt.Sprint(s.Store().Index()))
 	w.Header().Add("X-Raft-Index", fmt.Sprint(s.CommitIndex()))
 	w.Header().Add("X-Raft-Term", fmt.Sprint(s.Term()))