Add example chunked encoding response

This commit is contained in:
2022-06-30 02:08:09 +02:00
parent 7b93dfa6cf
commit fb84784d1c
14 changed files with 216 additions and 11 deletions
+12 -1
View File
@@ -1,9 +1,18 @@
#include "examplewebserver.h"
// esp-idf includes
#include <esp_log.h>
// local includes
#include "rootresponsehandler.h"
#include "debugresponsehandler.h"
#include "chunkedresponsehandler.h"
#include "errorresponsehandler.h"
namespace {
constexpr const char * const TAG = "ASIO_WEBSERVER";
} // namespace
std::unique_ptr<ResponseHandler> ExampleWebserver::makeResponseHandler(ClientConnection &clientConnection, std::string_view method, std::string_view path, std::string_view protocol)
{
const std::string_view processedPath{[&](){
@@ -14,8 +23,10 @@ std::unique_ptr<ResponseHandler> ExampleWebserver::makeResponseHandler(ClientCon
if (processedPath.empty() || processedPath == "/")
return std::make_unique<RootResponseHandler>(clientConnection);
else if (processedPath == "/debug" || processedPath.starts_with("/debug/") )
else if (processedPath == "/debug" || processedPath.starts_with("/debug/"))
return std::make_unique<DebugResponseHandler>(clientConnection, method, path, protocol);
else if (processedPath == "/chunked")
return std::make_unique<ChunkedResponseHandler>(clientConnection);
else
return std::make_unique<ErrorResponseHandler>(clientConnection, path);
}