Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
v1.5.0 to fix _catchAllHandler bug
Browse files Browse the repository at this point in the history
#### Release v1.5.0

1. Fix `_catchAllHandler` not working bug. Check [catchAll handler not working #12](#12)
  • Loading branch information
khoih-prog authored Jan 30, 2023
1 parent 0e3463c commit c82e697
Show file tree
Hide file tree
Showing 23 changed files with 233 additions and 285 deletions.
171 changes: 91 additions & 80 deletions README.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
## Table of Contents

* [Changelog](#changelog)
* [Release v1.5.0](#Release-v150)
* [Release v1.4.2](#Release-v142)
* [Release v1.4.1](#Release-v141)
* [Release v1.4.0](#Release-v140)
Expand All @@ -35,6 +36,10 @@

## Changelog

#### Release v1.5.0

1. Fix `_catchAllHandler` not working bug. Check [catchAll handler not working #12](https://github.com/khoih-prog/AsyncWebServer_RP2040W/issues/12)

#### Release v1.4.2

1. Add examples [Async_AdvancedWebServer_SendChunked_MQTT](https://github.com/khoih-prog/AsyncWebServer_RP2040W/tree/main/examples/Async_AdvancedWebServer_SendChunked_MQTT) and [AsyncWebServer_MQTT_RP2040W](https://github.com/khoih-prog/AsyncWebServer_RP2040W/tree/main/examples/AsyncWebServer_MQTT_RP2040W) to demo how to use `AsyncWebServer_RP2040W` and `AsyncMQTT_Generic` libraries together
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "AsyncWebServer_RP2040W",
"version": "1.4.2",
"version": "1.5.0",
"keywords": "http, async, websocket, webserver, async-webserver, async-tcp, async-udp, async-websocket, async-http, ssl, tls, rp2040, rp2040w, raspberry-pi-pico-w, cyw43439, wifi",
"description": "Asynchronous WebServer Library for RASPBERRY_PI_PICO_W using CYW43439 WiFi with arduino-pico core. This library, which is relied on AsyncTCP_RP2040W, is part of a series of advanced Async libraries for RP2040W, such as AsyncTCP_RP2040W, AsyncUDP_RP2040W, AsyncWebServer_RP2040W, AsyncHTTPRequest_RP2040W, AsyncHTTPSRequest_RP2040W, etc. Now can display programmed WiFi country-code, support using CString to save heap to send very large data and examples to demo how to use beginChunkedResponse() to send large html in chunks",
"authors":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=AsyncWebServer_RP2040W
version=1.4.2
version=1.5.0
author=Hristo Gochkov,Khoi Hoang
maintainer=Khoi Hoang <khoih.prog@gmail.com>
sentence=Asynchronous WebServer Library for RASPBERRY_PI_PICO_W using CYW43439 WiFi with arduino-pico core.
Expand Down
11 changes: 3 additions & 8 deletions src/AsyncEventSource_RP2040W.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_RP2040W
Licensed under GPLv3 license
Version: 1.4.2
Version: 1.5.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 13/08/2022 Initial coding for RP2040W with CYW43439 WiFi
1.0.1 K Hoang 15/08/2022 Fix bug in examples, `library.json`
1.0.2 K Hoang 15/08/2022 Fix LED bug in examples
1.0.3 K Hoang 22/09/2022 To display country-code and tempo method to modify in arduino-pico core
1.1.0 K Hoang 25/09/2022 Fix issue with slow browsers or network
1.1.2 K Hoang 26/09/2022 Add function and example to support favicon.ico
1.2.0 K Hoang 03/10/2022 Option to use cString instead of String to save Heap
1.2.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed
...
1.3.0 K Hoang 10/10/2022 Fix crash when using AsyncWebSockets server
1.3.1 K Hoang 10/10/2022 Improve robustness of AsyncWebSockets server
1.4.0 K Hoang 20/10/2022 Add LittleFS functions such as AsyncFSWebServer
1.4.1 K Hoang 10/11/2022 Add examples to demo how to use beginChunkedResponse() to send in chunks
1.4.2 K Hoang 28/01/2023 Add Async_AdvancedWebServer_SendChunked_MQTT and AsyncWebServer_MQTT_RP2040W examples
1.5.0 K Hoang 30/01/2023 Fix _catchAllHandler not working bug
*****************************************************************************************************************************/

#if !defined(_RP2040W_AWS_LOGLEVEL_)
Expand Down
11 changes: 3 additions & 8 deletions src/AsyncEventSource_RP2040W.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_RP2040W
Licensed under GPLv3 license
Version: 1.4.2
Version: 1.5.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 13/08/2022 Initial coding for RP2040W with CYW43439 WiFi
1.0.1 K Hoang 15/08/2022 Fix bug in examples, `library.json`
1.0.2 K Hoang 15/08/2022 Fix LED bug in examples
1.0.3 K Hoang 22/09/2022 To display country-code and tempo method to modify in arduino-pico core
1.1.0 K Hoang 25/09/2022 Fix issue with slow browsers or network
1.1.2 K Hoang 26/09/2022 Add function and example to support favicon.ico
1.2.0 K Hoang 03/10/2022 Option to use cString instead of String to save Heap
1.2.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed
...
1.3.0 K Hoang 10/10/2022 Fix crash when using AsyncWebSockets server
1.3.1 K Hoang 10/10/2022 Improve robustness of AsyncWebSockets server
1.4.0 K Hoang 20/10/2022 Add LittleFS functions such as AsyncFSWebServer
1.4.1 K Hoang 10/11/2022 Add examples to demo how to use beginChunkedResponse() to send in chunks
1.4.2 K Hoang 28/01/2023 Add Async_AdvancedWebServer_SendChunked_MQTT and AsyncWebServer_MQTT_RP2040W examples
1.5.0 K Hoang 30/01/2023 Fix _catchAllHandler not working bug
*****************************************************************************************************************************/

#pragma once
Expand Down
40 changes: 3 additions & 37 deletions src/AsyncFSEditor_RP2040W.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_RP2040W
Licensed under GPLv3 license
Version: 1.4.2
Version: 1.5.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 13/08/2022 Initial coding for RP2040W with CYW43439 WiFi
1.0.1 K Hoang 15/08/2022 Fix bug in examples, `library.json`
1.0.2 K Hoang 15/08/2022 Fix LED bug in examples
1.0.3 K Hoang 22/09/2022 To display country-code and tempo method to modify in arduino-pico core
1.1.0 K Hoang 25/09/2022 Fix issue with slow browsers or network
1.1.2 K Hoang 26/09/2022 Add function and example to support favicon.ico
1.2.0 K Hoang 03/10/2022 Option to use cString instead of String to save Heap
1.2.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed
...
1.3.0 K Hoang 10/10/2022 Fix crash when using AsyncWebSockets server
1.3.1 K Hoang 10/10/2022 Improve robustness of AsyncWebSockets server
1.4.0 K Hoang 20/10/2022 Add LittleFS functions such as AsyncFSWebServer
1.4.1 K Hoang 10/11/2022 Add examples to demo how to use beginChunkedResponse() to send in chunks
1.4.2 K Hoang 28/01/2023 Add Async_AdvancedWebServer_SendChunked_MQTT and AsyncWebServer_MQTT_RP2040W examples
1.5.0 K Hoang 30/01/2023 Fix _catchAllHandler not working bug
*****************************************************************************************************************************/

#include "AsyncFSEditor_RP2040W.h"
Expand Down Expand Up @@ -400,16 +395,6 @@ static void loadExcludeList(FS& fs, const char *filename)
{
static char linebuf[SPIFFS_MAXLENGTH_FILEPATH];

if (&fs)
{
AWS_LOGDEBUG0("loadExcludeList: FS * = ");
AWS_LOGDEBUG0( ( (uint32_t) &fs, HEX ) );
}
else
{
AWS_LOGDEBUG0("loadExcludeList: Error FS NULL");
}

File excludeFile = fs.open(filename, FILE_READ);

if (!excludeFile)
Expand Down Expand Up @@ -472,16 +457,6 @@ static void loadExcludeList(FS& fs, const char *filename)

static bool isExcluded(FS& fs, const char *filename)
{
if (&fs)
{
AWS_LOGDEBUG0("isExcluded: FS * = ");
AWS_LOGDEBUG0( ( (uint32_t) &fs, HEX ) );
}
else
{
AWS_LOGDEBUG0("isExcluded: Error FS NULL");
}

if (excludes == NULL)
{
loadExcludeList(fs, excludeListFile);
Expand Down Expand Up @@ -513,15 +488,6 @@ AsyncFSEditor::AsyncFSEditor(const String& username, const String& password, con
, _authenticated(false)
, _startTime(0)
{
if (&fs)
{
AWS_LOGDEBUG0("AsyncFSEditor: FS * = ");
AWS_LOGDEBUG0( ( (uint32_t) &fs, HEX ) );
}
else
{
AWS_LOGDEBUG0("AsyncFSEditor: Error FS NULL");
}
}

/////////////////////////////////////////////////////////
Expand Down
11 changes: 3 additions & 8 deletions src/AsyncFSEditor_RP2040W.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_RP2040W
Licensed under GPLv3 license
Version: 1.4.2
Version: 1.5.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 13/08/2022 Initial coding for RP2040W with CYW43439 WiFi
1.0.1 K Hoang 15/08/2022 Fix bug in examples, `library.json`
1.0.2 K Hoang 15/08/2022 Fix LED bug in examples
1.0.3 K Hoang 22/09/2022 To display country-code and tempo method to modify in arduino-pico core
1.1.0 K Hoang 25/09/2022 Fix issue with slow browsers or network
1.1.2 K Hoang 26/09/2022 Add function and example to support favicon.ico
1.2.0 K Hoang 03/10/2022 Option to use cString instead of String to save Heap
1.2.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed
...
1.3.0 K Hoang 10/10/2022 Fix crash when using AsyncWebSockets server
1.3.1 K Hoang 10/10/2022 Improve robustness of AsyncWebSockets server
1.4.0 K Hoang 20/10/2022 Add LittleFS functions such as AsyncFSWebServer
1.4.1 K Hoang 10/11/2022 Add examples to demo how to use beginChunkedResponse() to send in chunks
1.4.2 K Hoang 28/01/2023 Add Async_AdvancedWebServer_SendChunked_MQTT and AsyncWebServer_MQTT_RP2040W examples
1.5.0 K Hoang 30/01/2023 Fix _catchAllHandler not working bug
*****************************************************************************************************************************/

#ifndef RP2040W_ASYNC_FSEDITOR_H_
Expand Down
11 changes: 3 additions & 8 deletions src/AsyncJson_RP2040W.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_RP2040W
Licensed under GPLv3 license
Version: 1.4.2
Version: 1.5.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 13/08/2022 Initial coding for RP2040W with CYW43439 WiFi
1.0.1 K Hoang 15/08/2022 Fix bug in examples, `library.json`
1.0.2 K Hoang 15/08/2022 Fix LED bug in examples
1.0.3 K Hoang 22/09/2022 To display country-code and tempo method to modify in arduino-pico core
1.1.0 K Hoang 25/09/2022 Fix issue with slow browsers or network
1.1.2 K Hoang 26/09/2022 Add function and example to support favicon.ico
1.2.0 K Hoang 03/10/2022 Option to use cString instead of String to save Heap
1.2.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed
...
1.3.0 K Hoang 10/10/2022 Fix crash when using AsyncWebSockets server
1.3.1 K Hoang 10/10/2022 Improve robustness of AsyncWebSockets server
1.4.0 K Hoang 20/10/2022 Add LittleFS functions such as AsyncFSWebServer
1.4.1 K Hoang 10/11/2022 Add examples to demo how to use beginChunkedResponse() to send in chunks
1.4.2 K Hoang 28/01/2023 Add Async_AdvancedWebServer_SendChunked_MQTT and AsyncWebServer_MQTT_RP2040W examples
1.5.0 K Hoang 30/01/2023 Fix _catchAllHandler not working bug
*****************************************************************************************************************************/
/*
Async Response to use with ArduinoJson and AsyncWebServer
Expand Down
11 changes: 3 additions & 8 deletions src/AsyncWebAuthentication_RP2040W.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_RP2040W
Licensed under GPLv3 license
Version: 1.4.2
Version: 1.5.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 13/08/2022 Initial coding for RP2040W with CYW43439 WiFi
1.0.1 K Hoang 15/08/2022 Fix bug in examples, `library.json`
1.0.2 K Hoang 15/08/2022 Fix LED bug in examples
1.0.3 K Hoang 22/09/2022 To display country-code and tempo method to modify in arduino-pico core
1.1.0 K Hoang 25/09/2022 Fix issue with slow browsers or network
1.1.2 K Hoang 26/09/2022 Add function and example to support favicon.ico
1.2.0 K Hoang 03/10/2022 Option to use cString instead of String to save Heap
1.2.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed
...
1.3.0 K Hoang 10/10/2022 Fix crash when using AsyncWebSockets server
1.3.1 K Hoang 10/10/2022 Improve robustness of AsyncWebSockets server
1.4.0 K Hoang 20/10/2022 Add LittleFS functions such as AsyncFSWebServer
1.4.1 K Hoang 10/11/2022 Add examples to demo how to use beginChunkedResponse() to send in chunks
1.4.2 K Hoang 28/01/2023 Add Async_AdvancedWebServer_SendChunked_MQTT and AsyncWebServer_MQTT_RP2040W examples
1.5.0 K Hoang 30/01/2023 Fix _catchAllHandler not working bug
*****************************************************************************************************************************/

#if !defined(_RP2040W_AWS_LOGLEVEL_)
Expand Down
11 changes: 3 additions & 8 deletions src/AsyncWebAuthentication_RP2040W.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_RP2040W
Licensed under GPLv3 license
Version: 1.4.2
Version: 1.5.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 13/08/2022 Initial coding for RP2040W with CYW43439 WiFi
1.0.1 K Hoang 15/08/2022 Fix bug in examples, `library.json`
1.0.2 K Hoang 15/08/2022 Fix LED bug in examples
1.0.3 K Hoang 22/09/2022 To display country-code and tempo method to modify in arduino-pico core
1.1.0 K Hoang 25/09/2022 Fix issue with slow browsers or network
1.1.2 K Hoang 26/09/2022 Add function and example to support favicon.ico
1.2.0 K Hoang 03/10/2022 Option to use cString instead of String to save Heap
1.2.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed
...
1.3.0 K Hoang 10/10/2022 Fix crash when using AsyncWebSockets server
1.3.1 K Hoang 10/10/2022 Improve robustness of AsyncWebSockets server
1.4.0 K Hoang 20/10/2022 Add LittleFS functions such as AsyncFSWebServer
1.4.1 K Hoang 10/11/2022 Add examples to demo how to use beginChunkedResponse() to send in chunks
1.4.2 K Hoang 28/01/2023 Add Async_AdvancedWebServer_SendChunked_MQTT and AsyncWebServer_MQTT_RP2040W examples
1.5.0 K Hoang 30/01/2023 Fix _catchAllHandler not working bug
*****************************************************************************************************************************/

#pragma once
Expand Down
64 changes: 42 additions & 22 deletions src/AsyncWebHandlerImpl_RP2040W.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@
Built by Khoi Hoang https://github.com/khoih-prog/AsyncWebServer_RP2040W
Licensed under GPLv3 license
Version: 1.4.2
Version: 1.5.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 13/08/2022 Initial coding for RP2040W with CYW43439 WiFi
1.0.1 K Hoang 15/08/2022 Fix bug in examples, `library.json`
1.0.2 K Hoang 15/08/2022 Fix LED bug in examples
1.0.3 K Hoang 22/09/2022 To display country-code and tempo method to modify in arduino-pico core
1.1.0 K Hoang 25/09/2022 Fix issue with slow browsers or network
1.1.2 K Hoang 26/09/2022 Add function and example to support favicon.ico
1.2.0 K Hoang 03/10/2022 Option to use cString instead of String to save Heap
1.2.1 K Hoang 05/10/2022 Don't need memmove(), String no longer destroyed
...
1.3.0 K Hoang 10/10/2022 Fix crash when using AsyncWebSockets server
1.3.1 K Hoang 10/10/2022 Improve robustness of AsyncWebSockets server
1.4.0 K Hoang 20/10/2022 Add LittleFS functions such as AsyncFSWebServer
1.4.1 K Hoang 10/11/2022 Add examples to demo how to use beginChunkedResponse() to send in chunks
1.4.2 K Hoang 28/01/2023 Add Async_AdvancedWebServer_SendChunked_MQTT and AsyncWebServer_MQTT_RP2040W examples
1.5.0 K Hoang 30/01/2023 Fix _catchAllHandler not working bug
*****************************************************************************************************************************/

#pragma once
Expand Down Expand Up @@ -142,21 +137,25 @@ class AsyncCallbackWebHandler: public AsyncWebHandler
/////////////////////////////////////////////////

virtual bool canHandle(AsyncWebServerRequest *request) override final
{
{
if (!_onRequest)
{
return false;
}

if (!(_method & request->method()))
{
return false;

}

#ifdef ASYNCWEBSERVER_REGEX

if (_isRegex)
{
std::regex pattern(_uri.c_str());
std::smatch matches;
std::string s(request->url().c_str());

if (std::regex_search(s, matches, pattern))
{
for (size_t i = 1; i < matches.size(); ++i)
Expand All @@ -172,17 +171,27 @@ class AsyncCallbackWebHandler: public AsyncWebHandler
}
else
#endif
if (_uri.length() && _uri.endsWith("*"))
{
String uriTemplate = String(_uri);
uriTemplate = uriTemplate.substring(0, uriTemplate.length() - 1);

if (!request->url().startsWith(uriTemplate))
return false;
}
else if (_uri.length() && (_uri != request->url() && !request->url().startsWith(_uri + "/")))
if (_uri.length() && _uri.startsWith("/*."))
{
String uriTemplate = String (_uri);
uriTemplate = uriTemplate.substring(uriTemplate.lastIndexOf("."));

if (!request->url().endsWith(uriTemplate))
return false;
}
else if (_uri.length() && _uri.endsWith("*"))
{
String uriTemplate = String(_uri);
uriTemplate = uriTemplate.substring(0, uriTemplate.length() - 1);

if (!request->url().startsWith(uriTemplate))
return false;

}
else if (_uri.length() && (_uri != request->url() && !request->url().startsWith(_uri + "/")))
{
return false;
}

request->addInterestingHeader("ANY");

return true;
Expand All @@ -191,13 +200,24 @@ class AsyncCallbackWebHandler: public AsyncWebHandler
/////////////////////////////////////////////////

virtual void handleRequest(AsyncWebServerRequest *request) override final
{
{
if (_onRequest)
{
_onRequest(request);
}
else
request->send(500);
}

/////////////////////////////////////////////////

virtual void handleUpload(AsyncWebServerRequest *request, const String& filename, size_t index, uint8_t *data,
size_t len, bool final) override final
{
if(_onUpload)
_onUpload(request, filename, index, data, len, final);
}

/////////////////////////////////////////////////

virtual void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index,
Expand Down
Loading

0 comments on commit c82e697

Please sign in to comment.