mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-01 03:26:58 +03:00
additional mimetable fixes, additional string moves to progmem (#4371)
This commit is contained in:
@ -36,11 +36,9 @@
|
||||
#define DEBUG_OUTPUT Serial
|
||||
#endif
|
||||
|
||||
//const char * AUTHORIZATION_HEADER = "Authorization";
|
||||
static const char AUTHORIZATION_HEADER[] PROGMEM = "Authorization";
|
||||
static const char qop_auth[] PROGMEM = "qop=auth";
|
||||
static const char WWW_Authenticate[] PROGMEM = "WWW-Authenticate";
|
||||
static const char colon[] PROGMEM = ":";
|
||||
static const char Content_Length[] PROGMEM = "Content-Length";
|
||||
|
||||
|
||||
@ -81,10 +79,9 @@ ESP8266WebServer::ESP8266WebServer(int port)
|
||||
}
|
||||
|
||||
ESP8266WebServer::~ESP8266WebServer() {
|
||||
close();
|
||||
_server.close();
|
||||
if (_currentHeaders)
|
||||
delete[]_currentHeaders;
|
||||
_headerKeysCount = 0;
|
||||
RequestHandler* handler = _firstHandler;
|
||||
while (handler) {
|
||||
RequestHandler* next = handler->next();
|
||||
@ -105,7 +102,7 @@ void ESP8266WebServer::begin(uint16_t port) {
|
||||
|
||||
String ESP8266WebServer::_extractParam(String& authReq,const String& param,const char delimit){
|
||||
int _begin = authReq.indexOf(param);
|
||||
if (_begin==-1)
|
||||
if (_begin == -1)
|
||||
return "";
|
||||
return authReq.substring(_begin+param.length(),authReq.indexOf(delimit,_begin+param.length()));
|
||||
}
|
||||
@ -195,9 +192,9 @@ 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);
|
||||
}else{
|
||||
md5.add(_H1 + FPSTR(colon) + _nonce + FPSTR(colon) + _H2);
|
||||
md5.add(_H1 + ':' + _nonce + ':' + _nc + ':' + _cnonce + F(":auth:") + _H2);
|
||||
} else {
|
||||
md5.add(_H1 + ':' + _nonce + ':' + _H2);
|
||||
}
|
||||
md5.calculate();
|
||||
String _responsecheck = md5.toString();
|
||||
@ -237,7 +234,7 @@ void ESP8266WebServer::requestAuthentication(HTTPAuthMethod mode, const char* re
|
||||
sendHeader(String(FPSTR(WWW_Authenticate)), String(F("Digest realm=\"")) +_srealm + String(F("\", qop=\"auth\", nonce=\"")) + _snonce + String(F("\", opaque=\"")) + _sopaque + String(F("\"")));
|
||||
}
|
||||
using namespace mime;
|
||||
send(401, mimeTable[html].mimeType, authFailMsg);
|
||||
send(401, String(FPSTR(mimeTable[html].mimeType)), authFailMsg);
|
||||
}
|
||||
|
||||
void ESP8266WebServer::on(const String &uri, ESP8266WebServer::THandlerFunction handler) {
|
||||
@ -603,7 +600,7 @@ void ESP8266WebServer::_handleRequest() {
|
||||
}
|
||||
if (!handled) {
|
||||
using namespace mime;
|
||||
send(404, mimeTable[html].mimeType, String(F("Not found: ")) + _currentUri);
|
||||
send(404, String(FPSTR(mimeTable[html].mimeType)), String(F("Not found: ")) + _currentUri);
|
||||
handled = true;
|
||||
}
|
||||
if (handled) {
|
||||
|
Reference in New Issue
Block a user