Open
Description
I moved the file read/send part from HttpServerTask::processRequest
to:
void HttpResponse::sendFile(std::string fileName, size_t bufSize=4*1024)
so in the handler of my code im currently using:
static void webUiHandler(HttpRequest* pRequest, HttpResponse* pResponse) {
if (pRequest->isWebsocket()){
pRequest->getWebSocket()->close(HttpResponse::HTTP_STATUS_METHOD_NOT_ALLOWED, "NOT_ALLOWED");
} else {
pResponse->setStatus(HttpResponse::HTTP_STATUS_OK, "OK");
pResponse->addHeader(HttpRequest::HTTP_HEADER_CONTENT_TYPE, "text/html");
pResponse->sendFile("/spiffs/index.html");
pResponse->close();
}
}
.....
pHttpServer->addPathHandler(HttpRequest::HTTP_METHOD_GET, "/", webUiHandler);
Its some kind of redirect and i didnt find any other way to do it. I prepared a pull request