diff options
author | Jakob Borg <jakob@nym.se> | 2014-06-22 17:26:31 +0200 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2014-06-22 18:18:21 +0200 |
commit | 77fe8449ba0658b9327d08ca60715e617faa37b0 (patch) | |
tree | 704d8f99d40c5fcd479b77c29a75c1ec6b5d3af6 /cmd | |
parent | 33e9a35f08c3821f6683552fe767f80f82f49e0b (diff) |
Test script for REST interfacev0.8.16
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/syncthing/gui.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go index 8a57d53253..5d70ed5804 100644 --- a/cmd/syncthing/gui.go +++ b/cmd/syncthing/gui.go @@ -152,7 +152,7 @@ func restGetModelVersion(m *model.Model, w http.ResponseWriter, r *http.Request) res["version"] = m.Version(repo) - w.Header().Set("Content-Type", "application/json") + w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(res) } @@ -182,7 +182,7 @@ func restGetModel(m *model.Model, w http.ResponseWriter, r *http.Request) { res["state"] = m.State(repo) res["version"] = m.Version(repo) - w.Header().Set("Content-Type", "application/json") + w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(res) } @@ -198,13 +198,13 @@ func restGetNeed(m *model.Model, w http.ResponseWriter, r *http.Request) { files := m.NeedFilesRepo(repo) - w.Header().Set("Content-Type", "application/json") + w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(files) } func restGetConnections(m *model.Model, w http.ResponseWriter) { var res = m.ConnectionStats() - w.Header().Set("Content-Type", "application/json") + w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(res) } @@ -213,6 +213,7 @@ func restGetConfig(w http.ResponseWriter) { if encCfg.GUI.Password != "" { encCfg.GUI.Password = unchangedPassword } + w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(encCfg) } @@ -289,21 +290,25 @@ func restPostConfig(req *http.Request, m *model.Model) { } func restGetConfigInSync(w http.ResponseWriter) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(map[string]bool{"configInSync": configInSync}) } func restPostRestart(w http.ResponseWriter) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") flushResponse(`{"ok": "restarting"}`, w) go restart() } func restPostReset(w http.ResponseWriter) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") flushResponse(`{"ok": "resetting repos"}`, w) resetRepositories() go restart() } func restPostShutdown(w http.ResponseWriter) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") flushResponse(`{"ok": "shutting down"}`, w) go shutdown() } @@ -338,11 +343,12 @@ func restGetSystem(w http.ResponseWriter) { cpuUsageLock.RUnlock() res["cpuPercent"] = cpusum / 10 - w.Header().Set("Content-Type", "application/json") + w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(res) } func restGetErrors(w http.ResponseWriter) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") guiErrorsMut.Lock() json.NewEncoder(w).Encode(guiErrors) guiErrorsMut.Unlock() @@ -379,10 +385,12 @@ func restPostDiscoveryHint(r *http.Request) { } func restGetDiscovery(w http.ResponseWriter) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(discoverer.All()) } func restGetReport(w http.ResponseWriter, m *model.Model) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") json.NewEncoder(w).Encode(reportData(m)) } |