Add DEBUGF
This commit is contained in:
parent
1ffa6fb8e9
commit
9c5d0edf76
|
@ -8,6 +8,7 @@
|
||||||
#ifndef ASYNCWEBSERVERHANDLERIMPL_H_
|
#ifndef ASYNCWEBSERVERHANDLERIMPL_H_
|
||||||
#define ASYNCWEBSERVERHANDLERIMPL_H_
|
#define ASYNCWEBSERVERHANDLERIMPL_H_
|
||||||
|
|
||||||
|
|
||||||
#include "stddef.h"
|
#include "stddef.h"
|
||||||
|
|
||||||
class AsyncStaticWebHandler: public AsyncWebHandler {
|
class AsyncStaticWebHandler: public AsyncWebHandler {
|
||||||
|
@ -25,11 +26,11 @@ class AsyncStaticWebHandler: public AsyncWebHandler {
|
||||||
_isFile = _fs.exists(path) || _fs.exists((String(path)+".gz").c_str());
|
_isFile = _fs.exists(path) || _fs.exists((String(path)+".gz").c_str());
|
||||||
if (_uri != "/" && _uri.endsWith("/")) {
|
if (_uri != "/" && _uri.endsWith("/")) {
|
||||||
_uri = _uri.substring(0, _uri.length() - 1);
|
_uri = _uri.substring(0, _uri.length() - 1);
|
||||||
//os_printf("[AsyncStaticWebHandler] _uri / removed");
|
DEBUGF("[AsyncStaticWebHandler] _uri / removed");
|
||||||
}
|
}
|
||||||
if (_path != "/" && _path.endsWith("/")) {
|
if (_path != "/" && _path.endsWith("/")) {
|
||||||
_path = _path.substring(0, _path.length() - 1);
|
_path = _path.substring(0, _path.length() - 1);
|
||||||
//os_printf("[AsyncStaticWebHandler] _path / removed");
|
DEBUGF("[AsyncStaticWebHandler] _path / removed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
|
|
||||||
#include "StringArray.h"
|
#include "StringArray.h"
|
||||||
|
|
||||||
|
#define DEBUGF(...) //os_printf(__VA_ARGS__)
|
||||||
|
|
||||||
|
|
||||||
class AsyncWebServer;
|
class AsyncWebServer;
|
||||||
class AsyncWebServerRequest;
|
class AsyncWebServerRequest;
|
||||||
class AsyncWebServerResponse;
|
class AsyncWebServerResponse;
|
||||||
|
|
|
@ -21,28 +21,28 @@ bool AsyncStaticWebHandler::canHandle(AsyncWebServerRequest *request)
|
||||||
void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request)
|
void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request)
|
||||||
{
|
{
|
||||||
String path = request->url();
|
String path = request->url();
|
||||||
// os_printf("[AsyncStaticWebHandler::handleRequest]\n");
|
DEBUGF("[AsyncStaticWebHandler::handleRequest]\n");
|
||||||
// os_printf(" [stored] _uri = %s, _path = %s\n" , _uri.c_str(), _path.c_str() ) ;
|
DEBUGF(" [stored] _uri = %s, _path = %s\n" , _uri.c_str(), _path.c_str() ) ;
|
||||||
// os_printf(" [request] url = %s\n", request->url().c_str() );
|
DEBUGF(" [request] url = %s\n", request->url().c_str() );
|
||||||
|
|
||||||
if (!_isFile) {
|
if (!_isFile) {
|
||||||
//os_printf(" _isFile = false\n");
|
DEBUGF(" _isFile = false\n");
|
||||||
String baserequestUrl = request->url().substring(_uri.length()); // this is the request - stored _uri... /espman/
|
String baserequestUrl = request->url().substring(_uri.length()); // this is the request - stored _uri... /espman/
|
||||||
//os_printf(" baserequestUrl = %s\n", baserequestUrl.c_str());
|
DEBUGF(" baserequestUrl = %s\n", baserequestUrl.c_str());
|
||||||
|
|
||||||
if (baserequestUrl.length()) {
|
if (baserequestUrl.length()) {
|
||||||
path = _path + baserequestUrl;
|
path = _path + baserequestUrl;
|
||||||
//os_printf(" baserequestUrl length > 0: path = path + baserequestUrl, path = %s\n", path.c_str());
|
DEBUGF(" baserequestUrl length > 0: path = path + baserequestUrl, path = %s\n", path.c_str());
|
||||||
}
|
}
|
||||||
if (path.endsWith("/")) {
|
if (path.endsWith("/")) {
|
||||||
//os_printf(" 3 path ends with / : path = index.htm \n");
|
DEBUGF(" 3 path ends with / : path = index.htm \n");
|
||||||
path += "index.htm";
|
path += "index.htm";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
path = _path;
|
path = _path;
|
||||||
}
|
}
|
||||||
|
|
||||||
// os_printf("[AsyncStaticWebHandler::handleRequest] final path = %s\n", path.c_str());
|
DEBUGF("[AsyncStaticWebHandler::handleRequest] final path = %s\n", path.c_str());
|
||||||
|
|
||||||
if (_fs.exists(path) || _fs.exists(path + ".gz")) {
|
if (_fs.exists(path) || _fs.exists(path + ".gz")) {
|
||||||
AsyncWebServerResponse * response = request->beginResponse(_fs, path);
|
AsyncWebServerResponse * response = request->beginResponse(_fs, path);
|
||||||
|
@ -54,6 +54,6 @@ void AsyncStaticWebHandler::handleRequest(AsyncWebServerRequest *request)
|
||||||
}
|
}
|
||||||
path = String();
|
path = String();
|
||||||
|
|
||||||
// os_printf("[AsyncStaticWebHandler::handleRequest] END\n\n");
|
DEBUGF("[AsyncStaticWebHandler::handleRequest] END\n\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue