Skip to content

Commit f09784b

Browse files
committed
Fixed issue with setting Content-Length incorrectly if it had been set previously with setContentLength()
1 parent 727a8b8 commit f09784b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ESPWebServer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void ESPWebServer::_prepareStreamFile(size_t fileSize, const String& contentType
230230
}
231231

232232
void ESPWebServer::send(int code, const char* content_type, const String& content) {
233-
_contentLength = content.length();
233+
if (_contentLength == CONTENT_LENGTH_NOT_SET) _contentLength = content.length();
234234
_activeResponse->setStatusCode(code);
235235
_activeResponse->setHeader("Content-Type", content_type);
236236
_standardHeaders();
@@ -246,7 +246,7 @@ void ESPWebServer::send(int code, const String& content_type, const String& cont
246246
}
247247

248248
void ESPWebServer::send_P(int code, PGM_P content_type, PGM_P content) {
249-
_contentLength = strlen_P(content);
249+
if (_contentLength == CONTENT_LENGTH_NOT_SET) _contentLength = strlen_P(content);
250250
_activeResponse->setStatusCode(code);
251251
String memContentType(FPSTR(content_type));
252252
_activeResponse->setHeader("Content-Type", memContentType.c_str());
@@ -255,7 +255,7 @@ void ESPWebServer::send_P(int code, PGM_P content_type, PGM_P content) {
255255
}
256256

257257
void ESPWebServer::send_P(int code, PGM_P content_type, PGM_P content, size_t contentLength) {
258-
_contentLength = contentLength;
258+
if (_contentLength == CONTENT_LENGTH_NOT_SET) _contentLength = contentLength;
259259
_activeResponse->setStatusCode(code);
260260
String memContentType(FPSTR(content_type));
261261
_activeResponse->setHeader("Content-Type", memContentType.c_str());

0 commit comments

Comments
 (0)