forked from me-no-dev/ESPAsyncWebServer
Change JSON MIME type to application/json (#311)
This commit is contained in:
committed by
Me No Dev
parent
1078e9166b
commit
fc71230a31
@ -717,7 +717,7 @@ This way of sending Json is great for when the result is below 4KB
|
||||
#include "ArduinoJson.h"
|
||||
|
||||
|
||||
AsyncResponseStream *response = request->beginResponseStream("text/json");
|
||||
AsyncResponseStream *response = request->beginResponseStream("application/json");
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject &root = jsonBuffer.createObject();
|
||||
root["heap"] = ESP.getFreeHeap();
|
||||
@ -1126,7 +1126,7 @@ server.on("/scan", HTTP_GET, [](AsyncWebServerRequest *request){
|
||||
}
|
||||
}
|
||||
json += "]";
|
||||
request->send(200, "text/json", json);
|
||||
request->send(200, "application/json", json);
|
||||
json = String();
|
||||
});
|
||||
```
|
||||
|
@ -57,7 +57,7 @@ class AsyncJsonResponse: public AsyncAbstractResponse {
|
||||
public:
|
||||
AsyncJsonResponse(bool isArray=false): _isValid{false} {
|
||||
_code = 200;
|
||||
_contentType = "text/json";
|
||||
_contentType = "application/json";
|
||||
if(isArray)
|
||||
_root = _jsonBuffer.createArray();
|
||||
else
|
||||
|
@ -477,7 +477,7 @@ void SPIFFSEditor::handleRequest(AsyncWebServerRequest *request){
|
||||
dir.close();
|
||||
#endif
|
||||
output += "]";
|
||||
request->send(200, "text/json", output);
|
||||
request->send(200, "application/json", output);
|
||||
output = String();
|
||||
}
|
||||
else if(request->hasParam("edit") || request->hasParam("download")){
|
||||
|
@ -483,7 +483,7 @@ void AsyncFileResponse::_setContentType(const String& path){
|
||||
if (path.endsWith(".html")) _contentType = "text/html";
|
||||
else if (path.endsWith(".htm")) _contentType = "text/html";
|
||||
else if (path.endsWith(".css")) _contentType = "text/css";
|
||||
else if (path.endsWith(".json")) _contentType = "text/json";
|
||||
else if (path.endsWith(".json")) _contentType = "application/json";
|
||||
else if (path.endsWith(".js")) _contentType = "application/javascript";
|
||||
else if (path.endsWith(".png")) _contentType = "image/png";
|
||||
else if (path.endsWith(".gif")) _contentType = "image/gif";
|
||||
|
Reference in New Issue
Block a user