Skip to content

Commit 9077b70

Browse files
committed
added http code param to WebServer.streamFile (espressif#6899)
1 parent c93bf11 commit 9077b70

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: libraries/WebServer/src/WebServer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ void WebServer::sendContent_P(PGM_P content, size_t size) {
527527
}
528528

529529

530-
void WebServer::_streamFileCore(const size_t fileSize, const String & fileName, const String & contentType)
530+
void WebServer::_streamFileCore(const size_t fileSize, const String & fileName, const String & contentType, const int code = 200)
531531
{
532532
using namespace mime;
533533
setContentLength(fileSize);
@@ -536,7 +536,7 @@ void WebServer::_streamFileCore(const size_t fileSize, const String & fileName,
536536
contentType != String(FPSTR(mimeTable[none].mimeType))) {
537537
sendHeader(F("Content-Encoding"), F("gzip"));
538538
}
539-
send(200, contentType, "");
539+
send(code, contentType, "");
540540
}
541541

542542
String WebServer::pathArg(unsigned int i) {

Diff for: libraries/WebServer/src/WebServer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ class WebServer
139139
static String urlDecode(const String& text);
140140

141141
template<typename T>
142-
size_t streamFile(T &file, const String& contentType) {
143-
_streamFileCore(file.size(), file.name(), contentType);
142+
size_t streamFile(T &file, const String& contentType, const int code = 200) {
143+
_streamFileCore(file.size(), file.name(), contentType, code);
144144
return _currentClient.write(file);
145145
}
146146

0 commit comments

Comments
 (0)