This macro shows implementation of chunked requests These are special kind of user-defined requests which let split large http reply on many chunks so that server do not need to allocate such memory at once.
After macro started, try to execute request with
CAUTION: Example is not able to handle multiple requests at the same time For this one should create counter for each THttpCallArg instance
#include <cstring>
protected:
int fCounter = 0;
{
return;
std::string content = "line" + std::to_string(fCounter++) + " ";
for (
int n = 0;
n < 2000;
n++)
content.append("-");
content.append("\n");
if (fCounter >= 1000) {
fCounter = 0;
}
}
public:
TChunkedHttpServer(const char *engine) : THttpServer(engine) {}
};
void httpchunked()
{
auto serv = new TChunkedHttpServer("http:8080");
serv->SetTimer(1);
}
#define ClassDefOverride(name, id)
Contains arguments for single HTTP call.
void SetTextContent(std::string &&txt)
Set content type as "text/plain" and also assigns content.
void SetChunked(Bool_t on=kTRUE)
Mark as chunked.
const char * GetFileName() const
returns file name from request URL
Online http server for arbitrary ROOT application.
virtual void MissedRequest(THttpCallArg *arg)
Method called when THttpServer cannot process request.
- Author
- Sergey Linev
Definition in file httpchunked.C.