PsychicHTTP

This commit is contained in:
iranl
2024-08-26 23:41:54 +02:00
parent ca9c2feebc
commit 89393cee58
16 changed files with 1522 additions and 1447 deletions

View File

@@ -325,11 +325,19 @@ const std::list<PsychicClient*>& PsychicHttpServer::getClientList() {
}
bool ON_STA_FILTER(PsychicRequest *request) {
#ifndef CONFIG_IDF_TARGET_ESP32H2
return WiFi.localIP() == request->client()->localIP();
#else
return false;
#endif
}
bool ON_AP_FILTER(PsychicRequest *request) {
#ifndef CONFIG_IDF_TARGET_ESP32H2
return WiFi.softAPIP() == request->client()->localIP();
#else
return false;
#endif
}
String urlDecode(const char* encoded)

View File

@@ -318,6 +318,11 @@ PsychicWebParameter * PsychicRequest::addParam(PsychicWebParameter *param) {
return param;
}
int PsychicRequest::params()
{
return _params.size();
}
bool PsychicRequest::hasParam(const char *key)
{
return getParam(key) != NULL;
@@ -332,6 +337,18 @@ PsychicWebParameter * PsychicRequest::getParam(const char *key)
return NULL;
}
PsychicWebParameter * PsychicRequest::getParam(int index)
{
if (_params.size() > index){
std::list<PsychicWebParameter*>::iterator it = _params.begin();
for(int i=0; i<index; i++){
++it;
}
return *it;
}
return NULL;
}
bool PsychicRequest::hasSessionKey(const String& key)
{
return this->_session->find(key) != this->_session->end();

View File

@@ -81,9 +81,11 @@ class PsychicRequest {
void loadParams();
PsychicWebParameter * addParam(PsychicWebParameter *param);
PsychicWebParameter * addParam(const String &name, const String &value, bool decode = true, bool post = false);
int params();
bool hasParam(const char *key);
PsychicWebParameter * getParam(const char *name);
PsychicWebParameter * getParam(int index);
const String getFilename();
bool authenticate(const char * username, const char * password);