26#include "../../Defines.h"
38#define HTTP_DOWNLOAD_UNIT_SIZE 1460
39#define HTTP_UPLOAD_BUFLEN 2048
40#define HTTP_MAX_DATA_WAIT 1000
41#define HTTP_MAX_POST_WAIT 1000
42#define HTTP_MAX_SEND_WAIT 5000
43#define HTTP_MAX_CLOSE_WAIT 2000
45#define CONTENT_LENGTH_UNKNOWN ((size_t) -1)
46#define CONTENT_LENGTH_NOT_SET ((size_t) -2)
79 bool authenticate(
const char * username,
const char * password);
87 void serveStatic(
const char*
uri, fs::FS&
fs,
const char* path,
const char* cache_header = NULL );
96 String
arg(String name);
101 void collectHeaders(
const char* headerKeys[],
const size_t headerKeysCount);
102 String
header(String name);
114 void send(
int code,
const char* content_type = NULL,
const String& content = String(
""));
115 void send(
int code,
char* content_type,
const String& content);
116 void send(
int code,
const String& content_type,
const String& content);
117 void send_P(
int code, PGM_P content_type, PGM_P content);
118 void send_P(
int code, PGM_P content_type, PGM_P content,
size_t contentLength);
121 void sendHeader(
const String& name,
const String& value,
bool first =
false);
126 static String
urlDecode(
const String& text);
128template<
typename T>
size_t streamFile(T &file,
const String& contentType){
130 if (String(file.name()).endsWith(
".gz") &&
131 contentType !=
"application/x-gzip" &&
132 contentType !=
"application/octet-stream"){
135 send(200, contentType,
"");
149 void _prepareHeader(String& response,
int code,
const char* content_type,
size_t contentLength);
#define HTTP_UPLOAD_BUFLEN
bool authenticate(const char *username, const char *password)
static String urlDecode(const String &text)
bool hasHeader(String name)
void _prepareHeader(String &response, int code, const char *content_type, size_t contentLength)
RequestHandler * _currentHandler
void on(const String &uri, THandlerFunction handler)
RequestArgument * _currentArgs
static String _responseCodeToString(int code)
void sendContent(const String &content)
void _parseArguments(String data)
void requestAuthentication()
HTTPMethod _currentMethod
HTTPClientStatus _currentStatus
WiFiClient _currentClient
void _addRequestHandler(RequestHandler *handler)
size_t streamFile(T &file, const String &contentType)
void addHandler(RequestHandler *handler)
RequestHandler * _firstHandler
void collectHeaders(const char *headerKeys[], const size_t headerKeysCount)
void send(int code, const char *content_type=NULL, const String &content=String(""))
unsigned long _statusChange
String header(String name)
void sendHeader(const String &name, const String &value, bool first=false)
void onNotFound(THandlerFunction fn)
WebServer(IPAddress addr, int port=80)
bool _parseRequest(WiFiClient &client)
void setContentLength(size_t contentLength)
THandlerFunction _fileUploadHandler
THandlerFunction _notFoundHandler
RequestHandler * _lastHandler
RequestArgument * _currentHeaders
bool _collectHeader(const char *headerName, const char *headerValue)
HTTPUpload _currentUpload
void onFileUpload(THandlerFunction fn)
void send_P(int code, PGM_P content_type, PGM_P content)
void sendContent_P(PGM_P content)
bool _parseFormUploadAborted()
void serveStatic(const char *uri, fs::FS &fs, const char *path, const char *cache_header=NULL)
bool _parseForm(WiFiClient &client, String boundary, uint32_t len)
uint8_t _uploadReadByte(WiFiClient &client)
void _uploadWriteByte(uint8_t b)
std::function< void(void)> THandlerFunction