22#include "RConfigure.h"
164 jsrootsys =
gEnv->
GetValue(
"HttpServ.JSRootPath", jsrootsys);
166 if (jsrootsys && *jsrootsys) {
167 if ((strncmp(jsrootsys,
"http://", 7)==0) || (strncmp(jsrootsys,
"https://", 8)==0))
176 ::Warning(
"THttpServer::THttpServer",
"problems resolving '%s', set JSROOTSYS to proper JavaScript ROOT location",
184 Bool_t basic_sniffer = strstr(engine,
"basic_sniffer") !=
nullptr;
188 if (!basic_sniffer) {
211 if (strchr(engine,
';') == 0) {
218 if ((strcmp(opt,
"readonly") == 0) || (strcmp(opt,
"ro") == 0)) {
220 }
else if ((strcmp(opt,
"readwrite") == 0) || (strcmp(opt,
"rw") == 0)) {
222 }
else if (strcmp(opt,
"global") == 0) {
224 }
else if (strcmp(opt,
"noglobal") == 0) {
226 }
else if (strncmp(opt,
"cors=", 5) == 0) {
228 }
else if (strcmp(opt,
"cors") == 0) {
249 while (
auto engine =
dynamic_cast<THttpEngine *
>(iter()))
332 if (!prefix || (*prefix == 0))
355 fJSROOT = location ? location :
"";
422 const char *arg = strchr(engine,
':');
428 clname.
Append(engine, arg - engine);
433 if ((clname.
Length() == 0) || (clname ==
"http") || (clname ==
"civetweb")) {
436 }
else if (clname ==
"socket") {
442 }
else if (clname ==
"https") {
444 }
else if (clname ==
"fastcgi") {
496 Error(
"SetTimer",
"Server runs already in special thread, therefore no any timer can be created");
498 fTimer = std::make_unique<THttpTimer>(milliSec,
mode, *
this);
522 std::thread thrd([
this] {
532 std::this_thread::sleep_for(std::chrono::milliseconds(1));
537 fThrd = std::move(thrd);
562 if (!fname || (*fname == 0))
570 const char *next = strpbrk(fname,
"/\\");
575 if ((next == fname + 2) && (*fname ==
'.') && (*(fname + 1) ==
'.')) {
584 if ((next == fname + 1) && (*fname ==
'.')) {
612 if (!uri || (*uri == 0))
621 fname.
Remove(0, pos + (entry.first.length() - 1));
624 res = entry.second.c_str();
625 if ((fname[0] ==
'/') && (res[res.
Length() - 1] ==
'/'))
657 std::unique_lock<std::mutex> lk(
fMutex);
686 arg->NotifyCondition();
691 std::unique_lock<std::mutex> lk(
fMutex);
712 Warning(
"ProcessRequests",
"Changing main thread to %ld", (
long)
id);
732 std::unique_lock<std::mutex> lk(
fMutex, std::defer_lock);
736 std::shared_ptr<THttpCallArg> arg;
739 if (!
fArgs.empty()) {
748 if (arg->fFileName ==
"root_batch_holder.js") {
753 auto prev =
fSniffer->SetCurrentCallArg(arg.get());
763 arg->NotifyCondition();
768 while (
auto engine =
static_cast<THttpEngine *
>(iter())) {
799 auto wsptr =
FindWS(arg->GetPathName());
801 if (!wsptr || !wsptr->ProcessBatchHolder(arg)) {
803 arg->NotifyCondition();
813 std::string arr =
"[";
816 std::lock_guard<std::mutex> grd(
fWSMutex);
818 if (arr.length() > 1)
821 arr.append(
TString::Format(
"{ name: \"%s\", title: \"%s\" }", ws->GetName(), ws->GetTitle()).
Data());
829 std::string arg =
"\"$$$wslist$$$\"";
831 auto pos = res.find(arg);
832 if (pos != std::string::npos)
833 res.replace(pos, arg.length(), arr);
847 const std::string place_holder =
"<!--jsroot_importmap-->";
849 auto p = arg->fContent.find(place_holder);
851 bool old_format = (
p == std::string::npos);
855 if (arg->fPathName.Length() > 0)
857 for (
Int_t n = 1;
n < arg->fPathName.Length()-1; ++
n)
858 if (arg->fPathName[
n] ==
'/') {
859 if (arg->fPathName[
n-1] !=
'/') {
871 if (!version.empty()) {
873 std::string search =
"from './jsrootsys/";
874 std::string replace =
"from './" + version +
"/jsrootsys/";
875 arg->ReplaceAllinContent(search, replace);
877 search =
"from './rootui5sys/";
878 replace =
"from './" + version +
"/rootui5sys/";
879 arg->ReplaceAllinContent(search, replace);
881 search =
"jsrootsys/scripts/JSRoot.core.";
882 replace = version +
"/jsrootsys/scripts/JSRoot.core.";
883 arg->ReplaceAllinContent(search, replace,
true);
884 arg->AddNoCacheHeader();
892 if (repl.back() !=
'/')
897 while (slash_cnt-- > 0) repl.append(
"../");
898 repl.append(
"jsrootsys/");
903 arg->ReplaceAllinContent(
"=\"jsrootsys/", repl);
904 arg->ReplaceAllinContent(
"from './jsrootsys/",
TString::Format(
"from '%s", repl.substr(2).c_str()).
Data());
909 std::string path_prefix, jsroot_prefix;
912 while (slash_cnt-- > 0)
913 path_prefix.append(
"../");
918 if (!version.empty())
919 path_prefix.append(version +
"/");
923 if (jsroot_prefix.back() !=
'/')
924 jsroot_prefix.append(
"/");
926 jsroot_prefix = path_prefix +
"jsrootsys/";
929 static std::map<std::string, std::string> modules = {
930 {
"jsroot",
"main.mjs"}, {
"jsroot/core",
"core.mjs"}, {
"jsroot/io",
"io.mjs"}, {
"jsroot/tree",
"tree.mjs"},
931 {
"jsroot/draw",
"draw.mjs"}, {
"jsroot/geom",
"geom.mjs"}, {
"jsroot/gui",
"gui.mjs"}, {
"jsroot/webwindow",
"webwindow.mjs"}
935 TString importmap =
"<script type=\"importmap\">\n{\n \"imports\": ";
936 for (
auto &entry : modules) {
937 importmap.
Append(
TString::Format(
"%s\n \"%s\": \"%smodules/%s\"", first ?
"{" :
",", entry.first.c_str(), jsroot_prefix.c_str(), entry.second.c_str()));
943 if (entry.first !=
"jsrootsys/")
944 importmap.
Append(
TString::Format(
",\n \"%s\": \"%s%s\"", entry.first.c_str(), path_prefix.c_str(), entry.first.c_str()));
945 importmap.
Append(
"\n }\n}\n</script>\n");
947 arg->fContent.erase(
p, place_holder.length());
949 arg->fContent.insert(
p, importmap.
Data());
966 if ((arg->fFileName ==
"root.websocket") || (arg->fFileName ==
"root.longpoll")) {
971 if (arg->fFileName.IsNull() || (arg->fFileName ==
"index.htm") || (arg->fFileName ==
"default.htm")) {
975 if (arg->fFileName ==
"default.htm") {
981 auto wsptr =
FindWS(arg->GetPathName());
983 auto handler = wsptr.get();
992 if (arg->fContent.find(
"file:") == 0) {
993 const char *fname = arg->fContent.c_str() + 5;
999 version = handler->GetCodeVersion();
1001 handler->VerifyDefaultPageContent(arg);
1005 if (arg->fContent.empty() && arg->fFileName.IsNull() && arg->fPathName.IsNull() &&
IsWSOnly()) {
1010 arg->SetContent(
"refused");
1014 if (arg->fContent.empty() && !
IsWSOnly()) {
1022 if (arg->fContent.empty()) {
1025 }
else if (!arg->Is404()) {
1029 const char *hjsontag =
"\"$$$h.json$$$\"";
1032 if (arg->fContent.find(hjsontag) != std::string::npos) {
1036 if (arg->fTopName.Length() > 0)
1037 topname = arg->fTopName.Data();
1038 fSniffer->ScanHierarchy(topname, arg->fPathName.Data(), &store);
1040 arg->ReplaceAllinContent(hjsontag, h_json.
Data());
1042 arg->AddNoCacheHeader();
1044 if (arg->fQuery.Index(
"nozip") ==
kNPOS)
1047 arg->SetContentType(
"text/html");
1052 if ((arg->fFileName ==
"draw.htm") && !
IsWSOnly()) {
1059 const char *rootjsontag =
"\"$$$root.json$$$\"";
1060 const char *hjsontag =
"\"$$$h.json$$$\"";
1066 if ((arg->fQuery.Index(
"no_h_json") ==
kNPOS) && (arg->fQuery.Index(
"webcanvas") ==
kNPOS) &&
1067 (arg->fContent.find(hjsontag) != std::string::npos)) {
1071 if (arg->fTopName.Length() > 0)
1072 topname = arg->fTopName.Data();
1073 fSniffer->ScanHierarchy(topname, arg->fPathName.Data(), &store,
kTRUE);
1075 arg->ReplaceAllinContent(hjsontag, h_json.
Data());
1078 if ((arg->fQuery.Index(
"no_root_json") ==
kNPOS) && (arg->fQuery.Index(
"webcanvas") ==
kNPOS) &&
1079 (arg->fContent.find(rootjsontag) != std::string::npos)) {
1081 if (
fSniffer->Produce(arg->fPathName.Data(),
"root.json",
"compact=23", str))
1082 arg->ReplaceAllinContent(rootjsontag, str);
1084 arg->AddNoCacheHeader();
1085 if (arg->fQuery.Index(
"nozip") ==
kNPOS)
1087 arg->SetContentType(
"text/html");
1092 if ((arg->fFileName ==
"favicon.ico") && arg->fPathName.IsNull()) {
1093 arg->SetFile(
fJSROOTSYS +
"/img/RootIcon.ico");
1104 if (!arg->fPathName.IsNull() && !arg->fFileName.IsNull()) {
1105 TString wsname = arg->fPathName, fname;
1106 auto pos = wsname.
First(
'/');
1108 wsname = arg->fPathName;
1110 wsname = arg->fPathName(0, pos);
1111 fname = arg->fPathName(pos + 1, arg->fPathName.Length() - pos);
1115 fname.
Append(arg->fFileName);
1121 if (ws && ws->CanServeFiles()) {
1122 TString fdir = ws->GetDefaultPageContent();
1124 if (fdir.
Index(
"file:") == 0) {
1126 auto separ = fdir.
Last(
'/');
1149 if (arg->fContent.empty())
1153 Bool_t compact = arg->fQuery.Index(
"compact") !=
kNPOS;
1157 res.
Form(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
1167 if (arg->fTopName.Length() > 0)
1168 topname = arg->fTopName.Data();
1169 fSniffer->ScanHierarchy(topname, arg->fPathName.Data(), &store,
filename ==
"get.xml");
1176 arg->SetContent(std::string(res.
Data()));
1183 if (arg->fTopName.Length() > 0)
1184 topname = arg->fTopName.Data();
1185 fSniffer->ScanHierarchy(topname, arg->fPathName.Data(), &store);
1186 arg->SetContent(std::string(res.
Data()));
1188 }
else if (
fSniffer->Produce(arg->fPathName.Data(),
filename.Data(), arg->fQuery.Data(), arg->fContent)) {
1205 const char *parname =
fSniffer->IsStreamerInfoItem(arg->fPathName.Data()) ?
"BVersion" :
"MVersion";
1210 arg->AddNoCacheHeader();
1214 arg->AddHeader(
"Access-Control-Allow-Origin",
GetCors());
1226 return fSniffer->RegisterObject(subfolder, obj);
1236 return fSniffer->UnregisterObject(obj);
1246 std::lock_guard<std::mutex> grd(
fWSMutex);
1255 std::lock_guard<std::mutex> grd(
fWSMutex);
1268 std::lock_guard<std::mutex> grd(
fWSMutex);
1270 if (strcmp(
name, ws->GetName()) == 0)
1287 auto wsptr =
FindWS(arg->GetPathName());
1289 auto handler = wsptr.get();
1291 if (!handler && !external_thrd)
1294 if (external_thrd && (!handler || !handler->AllowMTProcess())) {
1299 std::unique_lock<std::mutex> lk(
fMutex);
1303 arg->fCond.wait(lk);
1313 if (arg->fFileName ==
"root.websocket") {
1315 process = handler->HandleWS(arg);
1316 }
else if (arg->fFileName ==
"root.longpoll") {
1318 if (arg->fQuery.BeginsWith(
"raw_connect") || arg->fQuery.BeginsWith(
"txt_connect")) {
1321 arg->SetMethod(
"WS_CONNECT");
1323 bool israw = arg->fQuery.BeginsWith(
"raw_connect");
1328 if (handler->HandleWS(arg)) {
1329 arg->SetMethod(
"WS_READY");
1331 if (handler->HandleWS(arg))
1332 arg->SetTextContent(std::string(israw ?
"txt:" :
"") + std::to_string(arg->GetWSId()));
1334 arg->TakeWSEngine();
1337 process = arg->IsText();
1344 arg->SetWSId(std::stoul(connid));
1346 arg->SetMethod(
"WS_CLOSE");
1347 arg->SetTextContent(
"OK");
1349 arg->SetMethod(
"WS_DATA");
1352 process = handler->HandleWS(arg);
1411 return fSniffer->RegisterCommand(cmdname, method, icon);
1419 return SetItemField(foldername,
"_hidden", hide ?
"true" : (
const char *)0);
1438 return fSniffer->CreateItem(fullname, title);
1462 static const struct {
1467 {
".json", 5,
"application/json"},
1468 {
".bin", 4,
"application/x-binary"},
1469 {
".gif", 4,
"image/gif"},
1470 {
".jpg", 4,
"image/jpeg"},
1471 {
".png", 4,
"image/png"},
1472 {
".html", 5,
"text/html"},
1473 {
".htm", 4,
"text/html"},
1474 {
".shtm", 5,
"text/html"},
1475 {
".shtml", 6,
"text/html"},
1476 {
".css", 4,
"text/css"},
1477 {
".js", 3,
"application/x-javascript"},
1478 {
".mjs", 4,
"text/javascript"},
1479 {
".ico", 4,
"image/x-icon"},
1480 {
".jpeg", 5,
"image/jpeg"},
1481 {
".svg", 4,
"image/svg+xml"},
1482 {
".txt", 4,
"text/plain"},
1483 {
".torrent", 8,
"application/x-bittorrent"},
1484 {
".wav", 4,
"audio/x-wav"},
1485 {
".mp3", 4,
"audio/x-mp3"},
1486 {
".mid", 4,
"audio/mid"},
1487 {
".m3u", 4,
"audio/x-mpegurl"},
1488 {
".ogg", 4,
"application/ogg"},
1489 {
".ram", 4,
"audio/x-pn-realaudio"},
1490 {
".xslt", 5,
"application/xml"},
1491 {
".xsl", 4,
"application/xml"},
1492 {
".ra", 3,
"audio/x-pn-realaudio"},
1493 {
".doc", 4,
"application/msword"},
1494 {
".exe", 4,
"application/octet-stream"},
1495 {
".zip", 4,
"application/x-zip-compressed"},
1496 {
".xls", 4,
"application/excel"},
1497 {
".tgz", 4,
"application/x-tar-gz"},
1498 {
".tar", 4,
"application/x-tar"},
1499 {
".gz", 3,
"application/x-gunzip"},
1500 {
".arj", 4,
"application/x-arj-compressed"},
1501 {
".rar", 4,
"application/x-arj-compressed"},
1502 {
".rtf", 4,
"application/rtf"},
1503 {
".pdf", 4,
"application/pdf"},
1504 {
".swf", 4,
"application/x-shockwave-flash"},
1505 {
".mpg", 4,
"video/mpeg"},
1506 {
".webm", 5,
"video/webm"},
1507 {
".mpeg", 5,
"video/mpeg"},
1508 {
".mov", 4,
"video/quicktime"},
1509 {
".mp4", 4,
"video/mp4"},
1510 {
".m4v", 4,
"video/x-m4v"},
1511 {
".asf", 4,
"video/x-ms-asf"},
1512 {
".avi", 4,
"video/x-msvideo"},
1513 {
".bmp", 4,
"image/bmp"},
1514 {
".ttf", 4,
"application/x-font-ttf"},
1515 {
".woff", 5,
"font/woff"},
1516 {
".woff2", 6,
"font/woff2"},
1519 int path_len = strlen(path);
1530 return "text/plain";
1542 std::ifstream is(
filename, std::ios::in | std::ios::binary);
1546 is.seekg(0, is.end);
1548 is.seekg(0, is.beg);
1566 std::ifstream is(
filename, std::ios::in | std::ios::binary);
1569 is.seekg(0, std::ios::end);
1570 res.resize(is.tellg());
1571 is.seekg(0, std::ios::beg);
1572 is.read((
char *)res.data(), res.length());
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
R__EXTERN TSystem * gSystem
static const struct @142 builtin_mime_types[]
THttpEngine implementation, based on civetweb embedded server.
TClass instances represent classes, structs and namespaces in the ROOT type system.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
static TClass * LoadClass(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
THttpEngine implementation, based on fastcgi package.
Contains arguments for single HTTP call.
void Set404()
mark reply as 404 error - page/request not exists or refused
Abstract class for implementing http protocol for THttpServer.
void SetServer(THttpServer *serv)
virtual Bool_t Create(const char *)
Method to create all components of engine.
Emulation of websocket with long poll requests.
Online http server for arbitrary ROOT application.
Bool_t IsReadOnly() const
returns read-only mode
Bool_t RegisterCommand(const char *cmdname, const char *method, const char *icon=nullptr)
Register command which can be executed from web interface.
TString fJSROOT
! location of external JSROOT files
virtual void ProcessRequest(std::shared_ptr< THttpCallArg > arg)
Process single http request.
std::shared_ptr< THttpWSHandler > FindWS(const char *name)
Find web-socket handler with given name.
std::unique_ptr< TRootSniffer > fSniffer
! sniffer provides access to ROOT objects hierarchy
void SetTimer(Long_t milliSec=100, Bool_t mode=kTRUE)
Create timer which will invoke ProcessRequests() function periodically.
virtual void ProcessBatchHolder(std::shared_ptr< THttpCallArg > &arg)
Process special http request for root_batch_holder.js script.
std::vector< std::shared_ptr< THttpWSHandler > > fWSHandlers
! list of WS handlers
virtual ~THttpServer()
destructor
void SetTerminate()
set termination flag, no any further requests will be processed
virtual void MissedRequest(THttpCallArg *arg)
Method called when THttpServer cannot process request.
Bool_t fOwnThread
! true when specialized thread allocated for processing requests
void SetSniffer(TRootSniffer *sniff)
Set TRootSniffer to the server.
Bool_t IsFileRequested(const char *uri, TString &res) const
Check if file is requested, thread safe.
void SetReadOnly(Bool_t readonly=kTRUE)
Set read-only mode for the server (default on)
const char * GetItemField(const char *fullname, const char *name)
Get item field from sniffer.
const char * GetCors() const
Returns specified CORS domain.
std::thread fThrd
! own thread
void StopServerThread()
Stop server thread.
Int_t ProcessRequests()
Process submitted requests, must be called from appropriate thread.
Bool_t ExecuteWS(std::shared_ptr< THttpCallArg > &arg, Bool_t external_thrd=kFALSE, Bool_t wait_process=kFALSE)
Execute WS request.
void RegisterWS(std::shared_ptr< THttpWSHandler > ws)
Register WS handler.
Long_t fProcessingThrdId
! id of the thread where events are recently processing
TString fTopName
! name of top folder, default - "ROOT"
void SetDrawPage(const std::string &filename="")
Set drawing HTML page.
Bool_t CreateItem(const char *fullname, const char *title)
Create item in sniffer.
Bool_t ExecuteHttp(std::shared_ptr< THttpCallArg > arg)
Execute HTTP request.
Bool_t Hide(const char *fullname, Bool_t hide=kTRUE)
Hides folder or element from web gui.
Bool_t IsCorsCredentials() const
Returns kTRUE if Access-Control-Allow-Credentials header should be used.
void AddLocation(const char *prefix, const char *path)
Add files location, which could be used in the server.
std::map< std::string, std::string > fLocations
! list of local directories, which could be accessed via server
Bool_t SubmitHttp(std::shared_ptr< THttpCallArg > arg, Bool_t can_run_immediately=kFALSE)
Submit HTTP request.
Long_t fMainThrdId
! id of the thread for processing requests
TString fJSROOTSYS
! location of local JSROOT files
std::unique_ptr< THttpTimer > fTimer
! timer used to access main thread
Bool_t fWSOnly
! when true, handle only websockets / longpoll engine
Bool_t Register(const char *subfolder, TObject *obj)
Register object in subfolder.
TList fEngines
! engines which runs http server
void SetCors(const std::string &domain="*")
Enable CORS header to ProcessRequests() responses Specified location (typically "*") add as "Access-C...
Bool_t IsCors() const
Returns kTRUE if CORS was configured.
const char * GetCorsCredentials() const
Returns specified CORS credentials value - if any.
std::queue< std::shared_ptr< THttpCallArg > > fArgs
! submitted arguments
void SetDefaultPage(const std::string &filename="")
Set default HTML page.
THttpServer(const THttpServer &)=delete
static char * ReadFileContent(const char *filename, Int_t &len)
Reads content of file from the disk.
void CreateServerThread()
Creates special thread to process all requests, directed to http server.
std::string fDrawPageCont
! content of draw html page
Bool_t Unregister(TObject *obj)
Unregister object.
void SetWSOnly(Bool_t on=kTRUE)
Set websocket-only mode.
std::string BuildWSEntryPage()
Create summary page with active WS handlers.
Bool_t IsWSOnly() const
returns true if only websockets are handled by the server
std::mutex fWSMutex
! mutex to protect WS handler lists
Bool_t CreateEngine(const char *engine)
Factory method to create different http engines.
Bool_t SetIcon(const char *fullname, const char *iconname)
Set name of icon, used in browser together with the item.
std::string fDrawPage
! file name for drawing of single element
std::string fDefaultPageCont
! content of default html page
static Bool_t VerifyFilePath(const char *fname)
Checked that filename does not contains relative path below current directory.
Bool_t SetItemField(const char *fullname, const char *name, const char *value)
Set item field in sniffer.
void SetJSROOT(const char *location)
Set location of JSROOT to use with the server.
std::mutex fMutex
! mutex to protect list with arguments
std::string fDefaultPage
! file name for default page name
void UnregisterWS(std::shared_ptr< THttpWSHandler > ws)
Unregister WS handler.
static const char * GetMimeType(const char *path)
Guess mime type base on file extension.
TRootSniffer * GetSniffer() const
returns pointer on objects sniffer
void ReplaceJSROOTLinks(std::shared_ptr< THttpCallArg > &arg, const std::string &version="")
Replaces all references like "jsrootsys/..." or other pre-configured pathes.
Bool_t fTerminated
! termination flag, disables all requests processing
void Restrict(const char *path, const char *options)
Restrict access to specified object.
void Timeout() override
timeout handler used to process http requests in main ROOT thread
void SetSlow(Bool_t flag)
THttpTimer(Long_t milliSec, Bool_t mode, THttpServer &serv)
!< server processing requests
Class for user-side handling of websocket with THttpServer.
virtual TString GetDefaultPageContent()
Provides content of default web page for registered web-socket handler Can be content of HTML page or...
void Add(TObject *obj) override
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
The TNamed class is the base class for all named ROOT classes.
TObject * At(Int_t idx) const override
Int_t GetLast() const override
Return index of last object in array.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
static const TString & GetRootSys()
Get the rootsys directory in the installation. Static utility function.
static const TString & GetDataDir()
Get the data directory in the installation. Static utility function.
Storage of hierarchy scan in TRootSniffer in JSON format.
Storage of hierarchy scan in TRootSniffer in XML format.
Sniffer of ROOT objects, data provider for THttpServer.
void CreateOwnTopFolder()
Create own TFolder structures independent from gROOT This allows to have many independent TRootSniffe...
void SetReadOnly(Bool_t on=kTRUE)
When readonly on (default), sniffer is not allowed to change ROOT structures For instance,...
void SetScanGlobalDir(Bool_t on=kTRUE)
When enabled (default), sniffer scans gROOT for files, canvases, histograms.
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Data() const
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Ssiz_t Last(char c) const
Find last occurrence of a character c.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual const char * Getenv(const char *env)
Get environment variable.
static Long_t SelfId()
Static method returning the id for the current thread.
Handles synchronous and a-synchronous timer events.
void SetTime(Long_t milliSec)
This class represents a WWW compatible URL.
const char * GetValueFromOptions(const char *key) const
Return a value for a given key from the URL options.
void SetOptions(const char *opt)
void ParseOptions() const
Parse URL options into a key/value map.
Bool_t HasOption(const char *key) const
Returns true if the given key appears in the URL options list.