Skip to content

Commit

Permalink
Merge branch 'master' into NVS_Flash_CI_test
Browse files Browse the repository at this point in the history
  • Loading branch information
P-R-O-C-H-Y authored Aug 15, 2022
2 parents df0fdd5 + 0260cd6 commit f8888ab
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
6 changes: 0 additions & 6 deletions cores/esp32/esp32-hal-touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,13 @@ static void __touchConfigInterrupt(uint8_t pin, void (*userFunc)(void), void *Ar
} else {
// attach ISR User Call
__touchInit();
#if SOC_TOUCH_VERSION_2 // ESP32S2, ESP32S3
__touchChannelInit(pad);
#endif
__touchInterruptHandlers[pad].fn = userFunc;
__touchInterruptHandlers[pad].callWithArgs = callWithArgs;
__touchInterruptHandlers[pad].arg = Args;
}

#if SOC_TOUCH_VERSION_1 // ESP32
touch_pad_config(pad, threshold);
#elif SOC_TOUCH_VERSION_2 // ESP32S2, ESP32S3
touch_pad_set_thresh(pad, threshold);
#endif
}

// it keeps backwards compatibility
Expand Down
19 changes: 9 additions & 10 deletions libraries/WebServer/src/Parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ bool WebServer::_parseRequest(WiFiClient& client) {
//reset header value
for (int i = 0; i < _headerKeysCount; ++i) {
_currentHeaders[i].value =String();
}
}

// First line of HTTP request looks like "GET /path HTTP/1.1"
// Retrieve the "/path" part by finding the spaces
Expand All @@ -103,6 +103,7 @@ bool WebServer::_parseRequest(WiFiClient& client) {
}
_currentUri = url;
_chunked = false;
_clientContentLength = 0; // not known yet, or invalid

HTTPMethod method = HTTP_ANY;
size_t num_methods = sizeof(_http_method_str) / sizeof(const char *);
Expand Down Expand Up @@ -136,7 +137,6 @@ bool WebServer::_parseRequest(WiFiClient& client) {
String headerValue;
bool isForm = false;
bool isEncoded = false;
uint32_t contentLength = 0;
//parse headers
while(1){
req = client.readStringUntil('\r');
Expand Down Expand Up @@ -167,20 +167,20 @@ bool WebServer::_parseRequest(WiFiClient& client) {
isForm = true;
}
} else if (headerName.equalsIgnoreCase(F("Content-Length"))){
contentLength = headerValue.toInt();
_clientContentLength = headerValue.toInt();
} else if (headerName.equalsIgnoreCase(F("Host"))){
_hostHeader = headerValue;
}
}

if (!isForm){
size_t plainLength;
char* plainBuf = readBytesWithTimeout(client, contentLength, plainLength, HTTP_MAX_POST_WAIT);
if (plainLength < contentLength) {
char* plainBuf = readBytesWithTimeout(client, _clientContentLength, plainLength, HTTP_MAX_POST_WAIT);
if (plainLength < _clientContentLength) {
free(plainBuf);
return false;
}
if (contentLength > 0) {
if (_clientContentLength > 0) {
if(isEncoded){
//url encoded form
if (searchStr != "") searchStr += '&';
Expand All @@ -200,11 +200,10 @@ bool WebServer::_parseRequest(WiFiClient& client) {
// No content - but we can still have arguments in the URL.
_parseArguments(searchStr);
}
}

if (isForm){
} else {
// it IS a form
_parseArguments(searchStr);
if (!_parseForm(client, boundaryStr, contentLength)) {
if (!_parseForm(client, boundaryStr, _clientContentLength)) {
return false;
}
}
Expand Down
2 changes: 2 additions & 0 deletions libraries/WebServer/src/WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ WebServer::WebServer(IPAddress addr, int port)
, _headerKeysCount(0)
, _currentHeaders(nullptr)
, _contentLength(0)
, _clientContentLength(0)
, _chunked(false)
{
log_v("WebServer::Webserver(addr=%s, port=%d)", addr.toString().c_str(), port);
Expand All @@ -80,6 +81,7 @@ WebServer::WebServer(int port)
, _headerKeysCount(0)
, _currentHeaders(nullptr)
, _contentLength(0)
, _clientContentLength(0)
, _chunked(false)
{
log_v("WebServer::Webserver(port=%d)", port);
Expand Down
13 changes: 8 additions & 5 deletions libraries/WebServer/src/WebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ class WebServer
int args(); // get arguments count
bool hasArg(String name); // check if argument exists
void collectHeaders(const char* headerKeys[], const size_t headerKeysCount); // set the request headers to collect
String header(String name); // get request header value by name
String header(int i); // get request header value by number
String headerName(int i); // get request header name by number
int headers(); // get header count
bool hasHeader(String name); // check if header exists
String header(String name); // get request header value by name
String header(int i); // get request header value by number
String headerName(int i); // get request header name by number
int headers(); // get header count
bool hasHeader(String name); // check if header exists

int clientContentLength() { return _clientContentLength; } // return "content-length" of incoming HTTP header from "_currentClient"

String hostHeader(); // get request host header if available or empty String if not

Expand Down Expand Up @@ -198,6 +200,7 @@ class WebServer
int _headerKeysCount;
RequestArgument* _currentHeaders;
size_t _contentLength;
int _clientContentLength; // "Content-Length" from header of incoming POST or GET request
String _responseHeaders;

String _hostHeader;
Expand Down

0 comments on commit f8888ab

Please sign in to comment.