Skip to content

Wrap mimetype strings in FSPTR()s #4338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 10, 2018
10 changes: 5 additions & 5 deletions libraries/ESP8266WebServer/src/ESP8266WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ bool ESP8266WebServer::authenticate(const char * username, const char * password
#endif
md5.begin();
if(authReq.indexOf(FPSTR(qop_auth)) != -1) {
md5.add(_H1 + FPSTR(colon) + _nonce + FPSTR(colon) + _nc + FPSTR(colon) + _cnonce + ':auth:' + _H2);
md5.add(_H1 + FPSTR(colon) + _nonce + FPSTR(colon) + _nc + FPSTR(colon) + _cnonce + ":auth:" + _H2);
}else{
md5.add(_H1 + FPSTR(colon) + _nonce + FPSTR(colon) + _H2);
}
Expand Down Expand Up @@ -376,7 +376,7 @@ void ESP8266WebServer::_prepareHeader(String& response, int code, const char* co
if (!content_type)
content_type = mimeTable[html].mimeType;

sendHeader(String(F("Content-Type")), content_type, true);
sendHeader(String(F("Content-Type")), String(FPSTR(content_type)), true);
if (_contentLength == CONTENT_LENGTH_NOT_SET) {
sendHeader(String(FPSTR(Content_Length)), String(contentLength));
} else if (_contentLength != CONTENT_LENGTH_UNKNOWN) {
Expand Down Expand Up @@ -485,9 +485,9 @@ void ESP8266WebServer::_streamFileCore(const size_t fileSize, const String & fil
{
using namespace mime;
setContentLength(fileSize);
if (fileName.endsWith(mimeTable[gz].endsWith) &&
contentType != mimeTable[gz].mimeType &&
contentType != mimeTable[none].mimeType) {
if (fileName.endsWith(String(FPSTR(mimeTable[gz].endsWith))) &&
contentType != String(FPSTR(mimeTable[gz].mimeType)) &&
contentType != String(FPSTR(mimeTable[none].mimeType))) {
sendHeader(F("Content-Encoding"), F("gzip"));
}
send(200, contentType, "");
Expand Down
7 changes: 4 additions & 3 deletions libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "RequestHandler.h"
#include "mimetable.h"
#include "WString.h"

using namespace mime;

Expand Down Expand Up @@ -101,10 +102,10 @@ class StaticRequestHandler : public RequestHandler {

// look for gz file, only if the original specified path is not a gz. So part only works to send gzip via content encoding when a non compressed is asked for
// if you point the the path to gzip you will serve the gzip as content type "application/x-gzip", not text or javascript etc...
if (!path.endsWith(mimeTable[gz].endsWith) && !_fs.exists(path)) {
String pathWithGz = path + mimeTable[gz].endsWith;
if (!path.endsWith(FPSTR(mimeTable[gz].endsWith)) && !_fs.exists(path)) {
String pathWithGz = path + FPSTR(mimeTable[gz].endsWith);
if(_fs.exists(pathWithGz))
path += mimeTable[gz].endsWith;
path += FPSTR(mimeTable[gz].endsWith);
}

File f = _fs.open(path, "r");
Expand Down