22#include <QWebEngineUrlRequestJob>
86 const char *
GetWSKind()
const override {
return "rawlongpoll"; }
95 QBuffer *buffer =
new QBuffer;
98 buffer->open(QIODevice::WriteOnly);
99 if (file.open(QIODevice::ReadOnly)) {
100 auto arr = file.readAll();
109 buffer->connect(req, &QObject::destroyed, buffer, &QObject::deleteLater);
110 req->reply(mime, buffer);
129 req->fail(QWebEngineUrlRequestJob::UrlNotFound);
136 QBuffer *buffer =
new QBuffer;
138 buffer->open(QIODevice::WriteOnly);
144 buffer->connect(req, &QObject::destroyed, buffer, &QObject::deleteLater);
162 QString res =
"rootscheme://root.server1";
174 QUrl url = request->requestUrl();
178 request->fail(QWebEngineUrlRequestJob::UrlNotFound);
182 QString inp_path = url.path();
183 QString inp_query = url.query();
184 QString inp_method = request->requestMethod();
188 auto arg = std::make_shared<TWebGuiCallArg>(request);
194 arg->SendFile(fname.
Data());
199 TString query = inp_query.toLatin1().data();
203 arg->SetPostData(std::string(buf.
Data()));
207 arg->SetPathAndFileName(inp_path.toLatin1().data());
208 arg->SetQuery(query.
Data());
209 arg->SetMethod(inp_method.toLatin1().data());
210 arg->SetTopName(
"webgui");
#define R__LOG_ERROR(...)
THttpServer * fServer
server instance which should handle requests
QString MakeFullUrl(THttpServer *serv, const QString &url)
Returns fully qualified URL, required to open in QWindow.
void requestStarted(QWebEngineUrlRequestJob *request) override
Start processing of emulated HTTP request in WebEngine scheme handler Either one reads file or redire...
static TString Decode(const char *data)
Decode a base64 string date into a generic TString.
Contains arguments for single HTTP call.
Long_t GetContentLength() const
const void * GetContent() const
const char * GetPathName() const
returns path name from request URL
const char * GetContentType() const
const char * GetFileName() const
returns file name from request URL
Online http server for arbitrary ROOT application.
Bool_t IsFileRequested(const char *uri, TString &res) const
Check if file is requested, thread safe.
Bool_t SubmitHttp(std::shared_ptr< THttpCallArg > arg, Bool_t can_run_immediately=kFALSE)
Submit HTTP request.
static const char * GetMimeType(const char *path)
Guess mime type base on file extension.
const char * Data() const
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Class TWebGuiCallArg Specialized handler of requests in THttpServer with QWebEngine.
UrlRequestJobHolder fRequest
TWebGuiCallArg(QWebEngineUrlRequestJob *req=nullptr)
void SendFile(const char *fname)
void HttpReplied() override
virtual method to inform object that http request is processed
const char * GetWSKind() const override
provide WS kind
virtual ~TWebGuiCallArg()
const char * GetWSPlatform() const override
provide WS platform, intentionally keep qt5 here while it only used on client side
Class UrlRequestJobHolder Required to monitor state of QWebEngineUrlRequestJob Qt can delete object a...
QWebEngineUrlRequestJob * req() const
void onRequestDeleted(QObject *obj)
destroyed signal handler
void reset()
Reset holder.
UrlRequestJobHolder(QWebEngineUrlRequestJob *req)
Constructor.
QWebEngineUrlRequestJob * fRequest
ROOT::Experimental::RLogChannel & QtWebDisplayLog()