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:
parent
bf5a0f24dc
commit
291bc6bca5
@ -195,7 +195,7 @@ bool ESP8266WebServer::authenticate(const char * username, const char * password
|
|||||||
#endif
|
#endif
|
||||||
md5.begin();
|
md5.begin();
|
||||||
if(authReq.indexOf(FPSTR(qop_auth)) != -1) {
|
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{
|
}else{
|
||||||
md5.add(_H1 + FPSTR(colon) + _nonce + FPSTR(colon) + _H2);
|
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)
|
if (!content_type)
|
||||||
content_type = mimeTable[html].mimeType;
|
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) {
|
if (_contentLength == CONTENT_LENGTH_NOT_SET) {
|
||||||
sendHeader(String(FPSTR(Content_Length)), String(contentLength));
|
sendHeader(String(FPSTR(Content_Length)), String(contentLength));
|
||||||
} else if (_contentLength != CONTENT_LENGTH_UNKNOWN) {
|
} else if (_contentLength != CONTENT_LENGTH_UNKNOWN) {
|
||||||
@ -485,9 +485,9 @@ void ESP8266WebServer::_streamFileCore(const size_t fileSize, const String & fil
|
|||||||
{
|
{
|
||||||
using namespace mime;
|
using namespace mime;
|
||||||
setContentLength(fileSize);
|
setContentLength(fileSize);
|
||||||
if (fileName.endsWith(mimeTable[gz].endsWith) &&
|
if (fileName.endsWith(String(FPSTR(mimeTable[gz].endsWith))) &&
|
||||||
contentType != mimeTable[gz].mimeType &&
|
contentType != String(FPSTR(mimeTable[gz].mimeType)) &&
|
||||||
contentType != mimeTable[none].mimeType) {
|
contentType != String(FPSTR(mimeTable[none].mimeType))) {
|
||||||
sendHeader(F("Content-Encoding"), F("gzip"));
|
sendHeader(F("Content-Encoding"), F("gzip"));
|
||||||
}
|
}
|
||||||
send(200, contentType, "");
|
send(200, contentType, "");
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "RequestHandler.h"
|
#include "RequestHandler.h"
|
||||||
#include "mimetable.h"
|
#include "mimetable.h"
|
||||||
|
#include "WString.h"
|
||||||
|
|
||||||
using namespace mime;
|
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
|
// 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 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)) {
|
if (!path.endsWith(FPSTR(mimeTable[gz].endsWith)) && !_fs.exists(path)) {
|
||||||
String pathWithGz = path + mimeTable[gz].endsWith;
|
String pathWithGz = path + FPSTR(mimeTable[gz].endsWith);
|
||||||
if(_fs.exists(pathWithGz))
|
if(_fs.exists(pathWithGz))
|
||||||
path += mimeTable[gz].endsWith;
|
path += FPSTR(mimeTable[gz].endsWith);
|
||||||
}
|
}
|
||||||
|
|
||||||
File f = _fs.open(path, "r");
|
File f = _fs.open(path, "r");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user