1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Wrap mimetype strings in FSPTR()s (#4338)

Mimetype is now in progmem, so any accesses to it need to be using FPSTR()
wrapped Strings.

Fixes #4329
This commit is contained in:
Earle F. Philhower, III 2018-02-10 08:12:38 -08:00 committed by GitHub
parent bf5a0f24dc
commit 291bc6bca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -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);
}
@ -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) {
@ -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, "");

View File

@ -3,6 +3,7 @@
#include "RequestHandler.h"
#include "mimetable.h"
#include "WString.h"
using namespace mime;
@ -101,10 +102,10 @@ public:
// 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");