23#include <QWebEngineUrlRequestJob>
87 const char *
GetWSKind()
const override {
return "rawlongpoll"; }
96 QBuffer *buffer =
new QBuffer;
99 buffer->open(QIODevice::WriteOnly);
100 if (
file.open(QIODevice::ReadOnly)) {
101 QByteArray arr =
file.readAll();
102 if (strstr(fname,
".mjs") && !strcmp(mime,
"text/javascript")) {
103 const char *mark1 =
"///_begin_exclude_in_qt5web_", *mark2 =
"///_end_exclude_in_qt5web_";
104 auto p1 = arr.indexOf(mark1);
105 auto p2 = arr.indexOf(mark2);
106 if ((p1 > 0) && (p2 > p1)) arr.remove(p1, p2 - p1 + strlen(mark2));
117 buffer->connect(req, &QObject::destroyed, buffer, &QObject::deleteLater);
118 req->reply(mime, buffer);
137 req->fail(QWebEngineUrlRequestJob::UrlNotFound);
144 QBuffer *buffer =
new QBuffer;
146 buffer->open(QIODevice::WriteOnly);
152 buffer->connect(req, &QObject::destroyed, buffer, &QObject::deleteLater);
170 QString res =
"rootscheme://root.server1";
182 QUrl url = request->requestUrl();
186 request->fail(QWebEngineUrlRequestJob::UrlNotFound);
190 QString inp_path = url.path();
191 QString inp_query = url.query();
192 QString inp_method = request->requestMethod();
196 auto arg = std::make_shared<TWebGuiCallArg>(request);
202 arg->SendFile(fname.
Data());
207 TString query = inp_query.toLatin1().data();
211 arg->SetPostData(std::string(buf.
Data()));
215 arg->SetPathAndFileName(inp_path.toLatin1().data());
216 arg->SetQuery(query.
Data());
217 arg->SetMethod(inp_method.toLatin1().data());
218 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.
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
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 Normally condition is notified and wai...
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()