mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-11 18:54:28 +05:00
fix: `Content-Length` for pretty json for chunked response
This commit is contained in:
@@ -12,15 +12,17 @@ public:
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void send(int code, T contentType, const JsonVariantConst content, bool pretty = false) {
|
void send(int code, T contentType, const JsonVariantConst content, bool pretty = false) {
|
||||||
|
auto contentLength = pretty ? measureJsonPretty(content) : measureJson(content);
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP8266
|
#ifdef ARDUINO_ARCH_ESP8266
|
||||||
if (!this->webServer->chunkedResponseModeStart(code, contentType)) {
|
if (!this->webServer->chunkedResponseModeStart(code, contentType)) {
|
||||||
this->webServer->send(505, F("text/html"), F("HTTP1.1 required"));
|
this->webServer->send(505, F("text/html"), F("HTTP1.1 required"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->webServer->setContentLength(measureJson(content));
|
this->webServer->setContentLength(contentLength);
|
||||||
#else
|
#else
|
||||||
this->webServer->setContentLength(measureJson(content));
|
this->webServer->setContentLength(contentLength);
|
||||||
this->webServer->send(code, contentType, emptyString);
|
this->webServer->send(code, contentType, emptyString);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user