Skip to content

Commit fb038ba

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

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
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

+3-3
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

@@ -160,7 +160,7 @@ class WebServer
160160
void _prepareHeader(String& response, int code, const char* content_type, size_t contentLength);
161161
bool _collectHeader(const char* headerName, const char* headerValue);
162162

163-
void _streamFileCore(const size_t fileSize, const String & fileName, const String & contentType);
163+
void _streamFileCore(const size_t fileSize, const String & fileName, const String & contentType, const int code = 200);
164164

165165
String _getRandomHexString();
166166
// for extracting Auth parameters

0 commit comments

Comments
 (0)