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

match headers using equalsIgnoreCase (#2474)

Should fix: https://github.com/esp8266/Arduino/issues/2131
This commit is contained in:
Me No Dev 2016-09-02 11:49:14 +03:00 committed by GitHub
parent c2414a2252
commit 4897e0006b
2 changed files with 13 additions and 9 deletions

View File

@ -42,6 +42,8 @@ ESP8266WebServer::ESP8266WebServer(IPAddress addr, int port)
: _server(addr, port)
, _currentMethod(HTTP_ANY)
, _currentVersion(0)
, _currentStatus(HC_NONE)
, _statusChange(0)
, _currentHandler(0)
, _firstHandler(0)
, _lastHandler(0)
@ -58,6 +60,8 @@ ESP8266WebServer::ESP8266WebServer(int port)
: _server(port)
, _currentMethod(HTTP_ANY)
, _currentVersion(0)
, _currentStatus(HC_NONE)
, _statusChange(0)
, _currentHandler(0)
, _firstHandler(0)
, _lastHandler(0)
@ -393,7 +397,7 @@ bool ESP8266WebServer::hasArg(String name) {
String ESP8266WebServer::header(String name) {
for (int i = 0; i < _headerKeysCount; ++i) {
if (_currentHeaders[i].key == name)
if (_currentHeaders[i].key.equalsIgnoreCase(name))
return _currentHeaders[i].value;
}
return String();
@ -428,7 +432,7 @@ int ESP8266WebServer::headers() {
bool ESP8266WebServer::hasHeader(String name) {
for (int i = 0; i < _headerKeysCount; ++i) {
if ((_currentHeaders[i].key == name) && (_currentHeaders[i].value.length() > 0))
if ((_currentHeaders[i].key.equalsIgnoreCase(name)) && (_currentHeaders[i].value.length() > 0))
return true;
}
return false;

View File

@ -158,7 +158,7 @@ bool ESP8266WebServer::_parseRequest(WiFiClient& client) {
DEBUG_OUTPUT.println(headerValue);
#endif
if (headerName == "Content-Type"){
if (headerName.equalsIgnoreCase("Content-Type")){
if (headerValue.startsWith("text/plain")){
isForm = false;
} else if (headerValue.startsWith("application/x-www-form-urlencoded")){
@ -168,9 +168,9 @@ bool ESP8266WebServer::_parseRequest(WiFiClient& client) {
boundaryStr = headerValue.substring(headerValue.indexOf('=')+1);
isForm = true;
}
} else if (headerName == "Content-Length"){
} else if (headerName.equalsIgnoreCase("Content-Length")){
contentLength = headerValue.toInt();
} else if (headerName == "Host"){
} else if (headerName.equalsIgnoreCase("Host")){
_hostHeader = headerValue;
}
}
@ -237,7 +237,7 @@ bool ESP8266WebServer::_parseRequest(WiFiClient& client) {
DEBUG_OUTPUT.println(headerValue);
#endif
if (headerName == "Host"){
if (headerName.equalsIgnoreCase("Host")){
_hostHeader = headerValue;
}
}
@ -257,7 +257,7 @@ bool ESP8266WebServer::_parseRequest(WiFiClient& client) {
bool ESP8266WebServer::_collectHeader(const char* headerName, const char* headerValue) {
for (int i = 0; i < _headerKeysCount; i++) {
if (_currentHeaders[i].key==headerName) {
if (_currentHeaders[i].key.equalsIgnoreCase(headerName)) {
_currentHeaders[i].value=headerValue;
return true;
}
@ -389,7 +389,7 @@ bool ESP8266WebServer::_parseForm(WiFiClient& client, String boundary, uint32_t
line = client.readStringUntil('\r');
client.readStringUntil('\n');
if (line.startsWith("Content-Disposition")){
if (line.length() > 19 && line.substring(0, 19).equalsIgnoreCase("Content-Disposition")){
int nameStart = line.indexOf('=');
if (nameStart != -1){
argName = line.substring(nameStart+2);
@ -414,7 +414,7 @@ bool ESP8266WebServer::_parseForm(WiFiClient& client, String boundary, uint32_t
argType = "text/plain";
line = client.readStringUntil('\r');
client.readStringUntil('\n');
if (line.startsWith("Content-Type")){
if (line.length() > 12 && line.substring(0, 12).equalsIgnoreCase("Content-Type")){
argType = line.substring(line.indexOf(':')+2);
//skip next line
client.readStringUntil('\r');