Add WebServer, WebServerSecure, HTTPUpdateServer, HTTPUpdateServerSecure (#791)
* Add HTTP-parser lib to support ESP32 WebServer * Add WebServer from ESP32. Only supports HTTP * Separate HTTP server from the network server Instead of managing the WiFiServer/WiFiServerSecure in the same object as the HTTP handling, split them into separate objects. This lets HTTP and HTTPS servers work without templates or duplicating code. The HTTP block just gets a `WiFiClient*` and works with that to only do HTTP processing, while the upper object handles the appropriate server and client types. * Add HTTPS server * Clean up some THandlerFunction refs * Refactor into a template-ized WebServer/WebServerSecure * Add DNSServer examples which need WebServer * Fix CoreMutex infinite recursion crash Core could crash while Serial debugging was going on and prints were happening from LWIP/IRQ land and the main app. * Add HTTPUpdateServer(Secure) * Add MIME include, optimize WebServer::send(size,len) When send()ing a large buffer, the WebServer::send() call would actually convert that buffer into a String (i.e. duplicate it, and potential issues with embedded \0s in binary data). Make a simple override to send(size, len) to allow writing from the source buffer instead. * Fix WiFiClient::send(Stream), add FSBrowser example
This commit was merged in pull request #791.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <WebServer.h>
|
||||
|
||||
template <typename ServerType, int ServerPort>
|
||||
class HTTPUpdateServerTemplate {
|
||||
public:
|
||||
HTTPUpdateServerTemplate(bool serial_debug = false);
|
||||
|
||||
void setup(WebServerTemplate<ServerType, ServerPort> *server) {
|
||||
setup(server, "", "");
|
||||
}
|
||||
|
||||
void setup(WebServerTemplate<ServerType, ServerPort> *server, const String& path) {
|
||||
setup(server, path, "", "");
|
||||
}
|
||||
|
||||
void setup(WebServerTemplate<ServerType, ServerPort> *server, const String& username, const String& password) {
|
||||
setup(server, "/update", username, password);
|
||||
}
|
||||
|
||||
void setup(WebServerTemplate<ServerType, ServerPort> *server, const String& path, const String& username, const String& password);
|
||||
|
||||
void updateCredentials(const String& username, const String& password) {
|
||||
_username = username;
|
||||
_password = password;
|
||||
}
|
||||
|
||||
protected:
|
||||
void _setUpdaterError();
|
||||
|
||||
private:
|
||||
bool _serial_output;
|
||||
WebServerTemplate<ServerType, ServerPort> *_server;
|
||||
String _username;
|
||||
String _password;
|
||||
bool _authenticated;
|
||||
String _updaterError;
|
||||
};
|
||||
|
||||
#include "HTTPUpdateServer-impl.h"
|
||||
|
||||
using HTTPUpdateServer = HTTPUpdateServerTemplate<WiFiServer, 80>;
|
||||
using HTTPUpdateServerSecure = HTTPUpdateServerTemplate<WiFiServerSecure, 443>;
|
||||
Reference in New Issue
Block a user