From b5de2ddcae5bb29f72d589c546749a9ae4bd7979 Mon Sep 17 00:00:00 2001
From: Cyril Danilevski <cyril.danilevski@xfel.eu>
Date: Fri, 14 Mar 2025 15:14:09 +0100
Subject: [PATCH] Set correct mime-type for json data

---
 rest.cpp | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/rest.cpp b/rest.cpp
index 3a73c7f..a783793 100644
--- a/rest.cpp
+++ b/rest.cpp
@@ -91,7 +91,7 @@ void identify() {
 
     message += "\n}";
 
-    restServer.send(418, "text/json", message);
+    restServer.send(418, "application/json", message);
 }
 
 void panel() {
@@ -117,7 +117,7 @@ void notFound() {
     }
 
     message += "\n}\n}";
-    restServer.send(404, "text/json", message);
+    restServer.send(404, "application/json", message);
     Serial.println(message);
 }
 
@@ -134,7 +134,8 @@ enum {
 
 void sendSNMP() {
     if (PINS.ramping) {
-        restServer.send(403, "text/json", "{\"success\": 0, \"reason\": \"ramping ongoing\"}");
+        restServer.send(403, "application/json",
+                        "{\"success\": 0, \"reason\": \"ramping ongoing\"}");
         return;
     }
     uint8_t output = NONE;
@@ -180,21 +181,23 @@ void sendSNMP() {
 
     http_msg += "\n}";
 
-    restServer.send(success ? 200 : 406, "text/json", http_msg);
+    restServer.send(success ? 200 : 406, "application/json", http_msg);
 }
 
 void getMpodStatus() {
     if (PINS.ramping) {
-        restServer.send(403, "text/json", "{\"success\": 0, \"reason\": \"ramping ongoing\"}");
+        restServer.send(403, "application/json",
+                        "{\"success\": 0, \"reason\": \"ramping ongoing\"}");
         return;
     }
 
-    restServer.send(200, "text/json", pproc.toJSON());
+    restServer.send(200, "application/json", pproc.toJSON());
 }
 
 void powerGroup() {
     if (PINS.ramping) {
-        restServer.send(403, "text/json", "{\"success\": 0, \"reason\": \"ramping ongoing\"}");
+        restServer.send(403, "application/json",
+                        "{\"success\": 0, \"reason\": \"ramping ongoing\"}");
         return;
     }
     String output;
@@ -247,12 +250,13 @@ void powerGroup() {
     }
     http_msg += "\n}";
 
-    restServer.send(success ? 200 : 406, "text/json", http_msg);
+    restServer.send(success ? 200 : 406, "application/json", http_msg);
 }
 
 void powerAllOff() {
     if (PINS.ramping) {
-        restServer.send(403, "text/json", "{\"success\": 0, \"reason\": \"ramping ongoing\"}");
+        restServer.send(403, "application/json",
+                        "{\"success\": 0, \"reason\": \"ramping ongoing\"}");
         return;
     }
     String group;
@@ -290,7 +294,7 @@ void powerAllOff() {
     // }
     http_msg += "\n}";
 
-    restServer.send(success ? 200 : 406, "text/json", http_msg);
+    restServer.send(success ? 200 : 406, "application/json", http_msg);
 }
 
 void pollMPODChannel() {
@@ -328,5 +332,5 @@ void pollMPODChannel() {
     http_msg += ret;
     http_msg += "}";
 
-    restServer.send(channel ? 200 : 406, "text/json", http_msg);
+    restServer.send(channel ? 200 : 406, "application/json", http_msg);
 }
-- 
GitLab