22#include <QWebEngineUrlRequestJob>
86 const char *
GetWSKind()
const override {
return "rawlongpoll"; }
91 #if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
102 QBuffer *buffer =
new QBuffer;
105 buffer->open(QIODevice::WriteOnly);
106 if (file.open(QIODevice::ReadOnly)) {
107 auto arr = file.readAll();
116 buffer->connect(req, &QObject::destroyed, buffer, &QObject::deleteLater);
117 req->reply(mime, buffer);
136 req->fail(QWebEngineUrlRequestJob::UrlNotFound);
143 QBuffer *buffer =
new QBuffer;
145 buffer->open(QIODevice::WriteOnly);
151 buffer->connect(req, &QObject::destroyed, buffer, &QObject::deleteLater);
169 QString res =
"rootscheme://root.server1";
181 QUrl url = request->requestUrl();
185 request->fail(QWebEngineUrlRequestJob::UrlNotFound);
189 QString inp_path = url.path();
190 QString inp_query = url.query();
191 QString inp_method = request->requestMethod();
195 auto arg = std::make_shared<TWebGuiCallArg>(request);
201 arg->SendFile(fname.
Data());
206 TString query = inp_query.toLatin1().data();
210 arg->SetPostData(std::string(buf.
Data()));
214 arg->SetPathAndFileName(inp_path.toLatin1().data());
215 arg->SetQuery(query.
Data());
216 arg->SetMethod(inp_method.toLatin1().data());
217 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
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()