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

Commit c82e697

Browse files
authored
v1.5.0 to fix _catchAllHandler bug
#### Release v1.5.0 1. Fix `_catchAllHandler` not working bug. Check [catchAll handler not working #12](#12)
1 parent 0e3463c commit c82e697

23 files changed

+233
-285
lines changed

README.md

Lines changed: 91 additions & 80 deletions
Large diffs are not rendered by default.

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
## Table of Contents
1616

1717
* [Changelog](#changelog)
18+
* [Release v1.5.0](#Release-v150)
1819
* [Release v1.4.2](#Release-v142)
1920
* [Release v1.4.1](#Release-v141)
2021
* [Release v1.4.0](#Release-v140)
@@ -35,6 +36,10 @@
3536

3637
## Changelog
3738

39+
#### Release v1.5.0
40+
41+
1. Fix `_catchAllHandler` not working bug. Check [catchAll handler not working #12](https://github.com/khoih-prog/AsyncWebServer_RP2040W/issues/12)
42+
3843
#### Release v1.4.2
3944

4045
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

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "AsyncWebServer_RP2040W",
3-
"version": "1.4.2",
3+
"version": "1.5.0",
44
"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",
55
"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",
66
"authors":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=AsyncWebServer_RP2040W
2-
version=1.4.2
2+
version=1.5.0
33
author=Hristo Gochkov,Khoi Hoang
44
maintainer=Khoi Hoang <[email protected]>
55
sentence=Asynchronous WebServer Library for RASPBERRY_PI_PICO_W using CYW43439 WiFi with arduino-pico core.

src/AsyncEventSource_RP2040W.cpp

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

3126
#if !defined(_RP2040W_AWS_LOGLEVEL_)

src/AsyncEventSource_RP2040W.h

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

3126
#pragma once

src/AsyncFSEditor_RP2040W.cpp

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

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

403-
if (&fs)
404-
{
405-
AWS_LOGDEBUG0("loadExcludeList: FS * = ");
406-
AWS_LOGDEBUG0( ( (uint32_t) &fs, HEX ) );
407-
}
408-
else
409-
{
410-
AWS_LOGDEBUG0("loadExcludeList: Error FS NULL");
411-
}
412-
413398
File excludeFile = fs.open(filename, FILE_READ);
414399

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

473458
static bool isExcluded(FS& fs, const char *filename)
474459
{
475-
if (&fs)
476-
{
477-
AWS_LOGDEBUG0("isExcluded: FS * = ");
478-
AWS_LOGDEBUG0( ( (uint32_t) &fs, HEX ) );
479-
}
480-
else
481-
{
482-
AWS_LOGDEBUG0("isExcluded: Error FS NULL");
483-
}
484-
485460
if (excludes == NULL)
486461
{
487462
loadExcludeList(fs, excludeListFile);
@@ -513,15 +488,6 @@ AsyncFSEditor::AsyncFSEditor(const String& username, const String& password, con
513488
, _authenticated(false)
514489
, _startTime(0)
515490
{
516-
if (&fs)
517-
{
518-
AWS_LOGDEBUG0("AsyncFSEditor: FS * = ");
519-
AWS_LOGDEBUG0( ( (uint32_t) &fs, HEX ) );
520-
}
521-
else
522-
{
523-
AWS_LOGDEBUG0("AsyncFSEditor: Error FS NULL");
524-
}
525491
}
526492

527493
/////////////////////////////////////////////////////////

src/AsyncFSEditor_RP2040W.h

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

3126
#ifndef RP2040W_ASYNC_FSEDITOR_H_

src/AsyncJson_RP2040W.h

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

src/AsyncWebAuthentication_RP2040W.cpp

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

3126
#if !defined(_RP2040W_AWS_LOGLEVEL_)

src/AsyncWebAuthentication_RP2040W.h

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

3126
#pragma once

src/AsyncWebHandlerImpl_RP2040W.h

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

3126
#pragma once
@@ -142,21 +137,25 @@ class AsyncCallbackWebHandler: public AsyncWebHandler
142137
/////////////////////////////////////////////////
143138

144139
virtual bool canHandle(AsyncWebServerRequest *request) override final
145-
{
140+
{
146141
if (!_onRequest)
142+
{
147143
return false;
144+
}
148145

149146
if (!(_method & request->method()))
147+
{
150148
return false;
151-
149+
}
150+
152151
#ifdef ASYNCWEBSERVER_REGEX
153152

154153
if (_isRegex)
155154
{
156155
std::regex pattern(_uri.c_str());
157156
std::smatch matches;
158157
std::string s(request->url().c_str());
159-
158+
160159
if (std::regex_search(s, matches, pattern))
161160
{
162161
for (size_t i = 1; i < matches.size(); ++i)
@@ -172,17 +171,27 @@ class AsyncCallbackWebHandler: public AsyncWebHandler
172171
}
173172
else
174173
#endif
175-
if (_uri.length() && _uri.endsWith("*"))
176-
{
177-
String uriTemplate = String(_uri);
178-
uriTemplate = uriTemplate.substring(0, uriTemplate.length() - 1);
179-
180-
if (!request->url().startsWith(uriTemplate))
181-
return false;
182-
}
183-
else if (_uri.length() && (_uri != request->url() && !request->url().startsWith(_uri + "/")))
174+
if (_uri.length() && _uri.startsWith("/*."))
175+
{
176+
String uriTemplate = String (_uri);
177+
uriTemplate = uriTemplate.substring(uriTemplate.lastIndexOf("."));
178+
179+
if (!request->url().endsWith(uriTemplate))
180+
return false;
181+
}
182+
else if (_uri.length() && _uri.endsWith("*"))
183+
{
184+
String uriTemplate = String(_uri);
185+
uriTemplate = uriTemplate.substring(0, uriTemplate.length() - 1);
186+
187+
if (!request->url().startsWith(uriTemplate))
184188
return false;
185-
189+
}
190+
else if (_uri.length() && (_uri != request->url() && !request->url().startsWith(_uri + "/")))
191+
{
192+
return false;
193+
}
194+
186195
request->addInterestingHeader("ANY");
187196

188197
return true;
@@ -191,13 +200,24 @@ class AsyncCallbackWebHandler: public AsyncWebHandler
191200
/////////////////////////////////////////////////
192201

193202
virtual void handleRequest(AsyncWebServerRequest *request) override final
194-
{
203+
{
195204
if (_onRequest)
205+
{
196206
_onRequest(request);
207+
}
197208
else
198209
request->send(500);
199210
}
200211

212+
/////////////////////////////////////////////////
213+
214+
virtual void handleUpload(AsyncWebServerRequest *request, const String& filename, size_t index, uint8_t *data,
215+
size_t len, bool final) override final
216+
{
217+
if(_onUpload)
218+
_onUpload(request, filename, index, data, len, final);
219+
}
220+
201221
/////////////////////////////////////////////////
202222

203223
virtual void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index,

0 commit comments

Comments
 (0)