1#ifndef REQUESTHANDLERSIMPL_H
2#define REQUESTHANDLERSIMPL_H
4#include "../../Defines.h"
21 if (requestUri !=
_uri)
36 if (!
canHandle(requestMethod, requestUri))
81 if (!
canHandle(requestMethod, requestUri))
91 if (requestUri.endsWith(
"/")) requestUri +=
"index.htm";
102 if (!path.endsWith(
".gz") && !
_fs.exists(path)) {
103 String pathWithGz = path +
".gz";
104 if(
_fs.exists(pathWithGz))
108 File f =
_fs.open(path,
"r");
120 if (path.endsWith(
".html"))
return "text/html";
121 else if (path.endsWith(
".htm"))
return "text/html";
122 else if (path.endsWith(
".css"))
return "text/css";
123 else if (path.endsWith(
".txt"))
return "text/plain";
124 else if (path.endsWith(
".js"))
return "application/javascript";
125 else if (path.endsWith(
".png"))
return "image/png";
126 else if (path.endsWith(
".gif"))
return "image/gif";
127 else if (path.endsWith(
".jpg"))
return "image/jpeg";
128 else if (path.endsWith(
".ico"))
return "image/x-icon";
129 else if (path.endsWith(
".svg"))
return "image/svg+xml";
130 else if (path.endsWith(
".ttf"))
return "application/x-font-ttf";
131 else if (path.endsWith(
".otf"))
return "application/x-font-opentype";
132 else if (path.endsWith(
".woff"))
return "application/font-woff";
133 else if (path.endsWith(
".woff2"))
return "application/font-woff2";
134 else if (path.endsWith(
".eot"))
return "application/vnd.ms-fontobject";
135 else if (path.endsWith(
".sfnt"))
return "application/font-sfnt";
136 else if (path.endsWith(
".xml"))
return "text/xml";
137 else if (path.endsWith(
".pdf"))
return "application/pdf";
138 else if (path.endsWith(
".zip"))
return "application/zip";
139 else if(path.endsWith(
".gz"))
return "application/x-gzip";
140 else if (path.endsWith(
".appcache"))
return "text/cache-manifest";
141 return "application/octet-stream";
FunctionRequestHandler(WebServer::THandlerFunction fn, WebServer::THandlerFunction ufn, const String &uri, HTTPMethod method)
bool canUpload(String requestUri) override
WebServer::THandlerFunction _fn
bool handle(WebServer &server, HTTPMethod requestMethod, String requestUri) override
void upload(WebServer &server, String requestUri, HTTPUpload &upload) override
WebServer::THandlerFunction _ufn
bool canHandle(HTTPMethod requestMethod, String requestUri) override
bool handle(WebServer &server, HTTPMethod requestMethod, String requestUri) override
bool canHandle(HTTPMethod requestMethod, String requestUri) override
StaticRequestHandler(FS &fs, const char *path, const char *uri, const char *cache_header)
static String getContentType(const String &path)
size_t streamFile(T &file, const String &contentType)
void sendHeader(const String &name, const String &value, bool first=false)
std::function< void(void)> THandlerFunction