THttpServer Online http server for arbitrary ROOT application Idea of THttpServer - provide remote http access to running ROOT application and enable HTML/JavaScript user interface. Any registered object can be requested and displayed in the browser. There are many benefits of such approach: * standard http interface to ROOT application * no any temporary ROOT files when access data * user interface running in all browsers Starting HTTP server To start http server, at any time create instance of the THttpServer class like: serv = new THttpServer("http:8080"); This will starts civetweb-based http server with http port 8080. Than one should be able to open address "http://localhost:8080" in any modern browser (IE, Firefox, Chrome) and browse objects, created in application. By default, server can access files, canvases and histograms via gROOT pointer. All such objects can be displayed with JSROOT graphics. At any time one could register other objects with the command: TGraph* gr = new TGraph(10); gr->SetName("gr1"); serv->Register("graphs/subfolder", gr); If objects content is changing in the application, one could enable monitoring flag in the browser - than objects view will be regularly updated. More information: http://root.cern.ch/drupal/content/users-guide
THttpServer(const char* engine = "civetweb:8080") | |
virtual | ~THttpServer() |
void | TObject::AbstractMethod(const char* method) const |
void | AddLocation(const char* prefix, const char* path) |
virtual void | TObject::AppendPad(Option_t* option = "") |
virtual void | TObject::Browse(TBrowser* b) |
static TClass* | Class() |
virtual const char* | TObject::ClassName() const |
virtual void | TNamed::Clear(Option_t* option = "") |
virtual TObject* | TNamed::Clone(const char* newname = "") const |
virtual Int_t | TNamed::Compare(const TObject* obj) const |
virtual void | TNamed::Copy(TObject& named) const |
Bool_t | CreateEngine(const char* engine) |
Bool_t | CreateItem(const char* fullname, const char* title) |
virtual void | TObject::Delete(Option_t* option = "")MENU |
virtual Int_t | TObject::DistancetoPrimitive(Int_t px, Int_t py) |
virtual void | TObject::Draw(Option_t* option = "") |
virtual void | TObject::DrawClass() constMENU |
virtual TObject* | TObject::DrawClone(Option_t* option = "") constMENU |
virtual void | TObject::Dump() constMENU |
virtual void | TObject::Error(const char* method, const char* msgfmt) const |
virtual void | TObject::Execute(const char* method, const char* params, Int_t* error = 0) |
virtual void | TObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0) |
virtual void | TObject::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
Bool_t | ExecuteHttp(THttpCallArg* arg) |
virtual void | TObject::Fatal(const char* method, const char* msgfmt) const |
virtual void | TNamed::FillBuffer(char*& buffer) |
virtual TObject* | TObject::FindObject(const char* name) const |
virtual TObject* | TObject::FindObject(const TObject* obj) const |
virtual Option_t* | TObject::GetDrawOption() const |
static Long_t | TObject::GetDtorOnly() |
virtual const char* | TObject::GetIconName() const |
const char* | GetItemField(const char* fullname, const char* name) |
static const char* | GetMimeType(const char* path) |
virtual const char* | TNamed::GetName() const |
virtual char* | TObject::GetObjectInfo(Int_t px, Int_t py) const |
static Bool_t | TObject::GetObjectStat() |
virtual Option_t* | TObject::GetOption() const |
TRootSniffer* | GetSniffer() const |
virtual const char* | TNamed::GetTitle() const |
const char* | GetTopName() const |
virtual UInt_t | TObject::GetUniqueID() const |
virtual Bool_t | TObject::HandleTimer(TTimer* timer) |
virtual ULong_t | TNamed::Hash() const |
Bool_t | Hide(const char* fullname, Bool_t hide = kTRUE) |
virtual void | TObject::Info(const char* method, const char* msgfmt) const |
virtual Bool_t | TObject::InheritsFrom(const char* classname) const |
virtual Bool_t | TObject::InheritsFrom(const TClass* cl) const |
virtual void | TObject::Inspect() constMENU |
void | TObject::InvertBit(UInt_t f) |
virtual TClass* | IsA() const |
Bool_t | IsAnyEngine() const |
virtual Bool_t | TObject::IsEqual(const TObject* obj) const |
Bool_t | IsFileRequested(const char* uri, TString& res) const |
virtual Bool_t | TObject::IsFolder() const |
Bool_t | TObject::IsOnHeap() const |
Bool_t | IsReadOnly() const |
virtual Bool_t | TNamed::IsSortable() const |
Bool_t | TObject::IsZombie() const |
virtual void | TNamed::ls(Option_t* option = "") const |
void | TObject::MayNotUse(const char* method) const |
virtual Bool_t | TObject::Notify() |
void | TObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const |
static void | TObject::operator delete(void* ptr) |
static void | TObject::operator delete(void* ptr, void* vp) |
static void | TObject::operator delete[](void* ptr) |
static void | TObject::operator delete[](void* ptr, void* vp) |
void* | TObject::operator new(size_t sz) |
void* | TObject::operator new(size_t sz, void* vp) |
void* | TObject::operator new[](size_t sz) |
void* | TObject::operator new[](size_t sz, void* vp) |
TNamed& | TNamed::operator=(const TNamed& rhs) |
virtual void | TObject::Paint(Option_t* option = "") |
virtual void | TObject::Pop() |
virtual void | TNamed::Print(Option_t* option = "") const |
void | ProcessRequests() |
virtual Int_t | TObject::Read(const char* name) |
static char* | ReadFileContent(const char* filename, Int_t& len) |
virtual void | TObject::RecursiveRemove(TObject* obj) |
Bool_t | Register(const char* subfolder, TObject* obj) |
Bool_t | RegisterCommand(const char* cmdname, const char* method, const char* icon = 0) |
void | TObject::ResetBit(UInt_t f) |
void | Restrict(const char* path, const char* options) |
virtual void | TObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU |
virtual void | TObject::SavePrimitive(ostream& out, Option_t* option = "") |
void | TObject::SetBit(UInt_t f) |
void | TObject::SetBit(UInt_t f, Bool_t set) |
void | SetDefaultPage(const char* filename) |
virtual void | TObject::SetDrawOption(Option_t* option = "")MENU |
void | SetDrawPage(const char* filename) |
static void | TObject::SetDtorOnly(void* obj) |
Bool_t | SetIcon(const char* fullname, const char* iconname) |
Bool_t | SetItemField(const char* fullname, const char* name, const char* value) |
void | SetJSROOT(const char* location) |
virtual void | TNamed::SetName(const char* name)MENU |
virtual void | TNamed::SetNameTitle(const char* name, const char* title) |
static void | TObject::SetObjectStat(Bool_t stat) |
void | SetReadOnly(Bool_t readonly) |
void | SetSniffer(TRootSniffer* sniff) |
void | SetTimer(Long_t milliSec = 100, Bool_t mode = kTRUE) |
virtual void | TNamed::SetTitle(const char* title = "")MENU |
void | SetTopName(const char* top) |
virtual void | TObject::SetUniqueID(UInt_t uid) |
virtual void | ShowMembers(TMemberInspector&) |
virtual Int_t | TNamed::Sizeof() const |
virtual void | Streamer(TBuffer&) |
void | StreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b) |
virtual void | TObject::SysError(const char* method, const char* msgfmt) const |
Bool_t | TObject::TestBit(UInt_t f) const |
Int_t | TObject::TestBits(UInt_t f) const |
Bool_t | Unregister(TObject* obj) |
virtual void | TObject::UseCurrentStyle() |
virtual void | TObject::Warning(const char* method, const char* msgfmt) const |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const |
virtual void | TObject::DoError(int level, const char* location, const char* fmt, va_list va) const |
void | TObject::MakeZombie() |
virtual void | ProcessRequest(THttpCallArg* arg) |
static Bool_t | VerifyFilePath(const char* fname) |
enum TObject::EStatusBits { | kCanDelete | |
kMustCleanup | ||
kObjInCanvas | ||
kIsReferenced | ||
kHasUUID | ||
kCannotPick | ||
kNoContextMenu | ||
kInvalidObject | ||
}; | ||
enum TObject::[unnamed] { | kIsOnHeap | |
kNotDeleted | ||
kZombie | ||
kBitMask | ||
kSingleKey | ||
kOverwrite | ||
kWriteDelete | ||
}; |
TList | fCallArgs | ! submitted arguments |
TString | fDefaultPage | ! file name for default page name |
TString | fDefaultPageCont | ! content of the file content |
TString | fDrawPage | ! file name for drawing of single element |
TString | fDrawPageCont | ! content of draw page |
TList | fEngines | ! engines which runs http server |
TString | fJSROOT | ! location of external JSROOT files |
TString | fJSROOTSYS | ! location of local JSROOT files |
TList | fLocations | ! list of local directories, which could be accessed via server |
Long_t | fMainThrdId | ! id of the main ROOT process |
TMutex | fMutex | ! mutex to protect list with arguments |
TString | TNamed::fName | object identifier |
TRootSniffer* | fSniffer | ! sniffer provides access to ROOT objects hierarchy |
THttpTimer* | fTimer | ! timer used to access main thread |
TString | TNamed::fTitle | object title |
TString | fTopName | ! name of top folder, default - "ROOT" |
Set TRootSniffer to the server Server takes ownership over sniffer
Set read-only mode for the server (default on) In read-only server is not allowed to change any ROOT object, registered to the server Server also cannot execute objects method via exe.json request
add files location, which could be used in the server one could map some system folder to the server like AddLocation("mydir/","/home/user/specials"); Than files from this directory could be addressed via server like http://localhost:8080/mydir/myfile.root
Set location of JSROOT to use with the server One could specify address like: https://root.cern.ch/js/3.3 http://web-docs.gsi.de/~linev/js/3.3 This allows to get new JSROOT features with old server, reduce load on THttpServer instance, also startup time can be improved When empty string specified (default), local copy of JSROOT is used (distributed with ROOT)
Set file name of HTML page, delivered by the server when http address is opened in the browser. By default, $ROOTSYS/etc/http/files/online.htm page is used When empty filename is specified, default page will be used
Set file name of HTML page, delivered by the server when objects drawing page is requested from the browser By default, $ROOTSYS/etc/http/files/draw.htm page is used When empty filename is specified, default page will be used
factory method to create different http engines At the moment two engine kinds are supported: civetweb (default) and fastcgi Examples: "civetweb:8080" or "http:8080" or ":8080" - creates civetweb web server with http port 8080 "fastcgi:9000" - creates fastcgi server with port 9000 "dabc:1237" - create DABC server with port 1237 (only available with DABC installed) "dabc:master_host:port" - attach to DABC master, running on master_host:port (only available with DABC installed)
create timer which will invoke ProcessRequests() function periodically Timer is required to perform all actions in main ROOT thread Method arguments are the same as for TTimer constructor By default, sync timer with 100 ms period is created If milliSec == 0, no timer will be created. In this case application should regularly call ProcessRequests() method.
Checked that filename does not contains relative path below current directory Used to prevent access to files below current directory
Verifies that request is just file name File names typically contains prefix like "jsrootsys/" If true, method returns real name of the file, which should be delivered to the client Method is thread safe and can be called from any thread
Executes http request, specified in THttpCallArg structure Method can be called from any thread Actual execution will be done in main ROOT thread, where analysis code is running.
Process requests, submitted for execution Regularly invoked by THttpTimer, when somewhere in the code gSystem->ProcessEvents() is called. User can call serv->ProcessRequests() directly, but only from main analysis thread.
Process single http request Depending from requested path and filename different actions will be performed. In most cases information is provided by TRootSniffer class
Register object in folders hierarchy See TRootSniffer::RegisterObject() for more details
Unregister object in folders hierarchy See TRootSniffer::UnregisterObject() for more details
Restrict access to specified object See TRootSniffer::Restrict() for more details
Register command which can be executed from web interface As method one typically specifies string, which is executed with gROOT->ProcessLine() method. For instance serv->RegisterCommand("Invoke","InvokeFunction()"); Or one could specify any method of the object which is already registered to the server. For instance: serv->Register("/", hpx); serv->RegisterCommand("/ResetHPX", "/hpx/->Reset()"); Here symbols '/->' separates item name from method to be executed One could specify additional arguments in the command with syntax like %arg1%, %arg2% and so on. For example: serv->RegisterCommand("/ResetHPX", "/hpx/->SetTitle(\"%arg1%\")"); serv->RegisterCommand("/RebinHPXPY", "/hpxpy/->Rebin2D(%arg1%,%arg2%)"); Such parameter(s) will be requested when command clicked in the browser. Once command is registered, one could specify icon which will appear in the browser: serv->SetIcon("/ResetHPX", "rootsys/icons/ed_execute.png"); One also can set extra property '_fastcmd', that command appear as tool button on the top of the browser tree: serv->SetItemField("/ResetHPX", "_fastcmd", "true"); Or it is equivalent to specifying extra argument when register command: serv->RegisterCommand("/ResetHPX", "/hpx/->Reset()", "button;rootsys/icons/ed_delete.png");
set name of icon, used in browser together with the item One could use images from $ROOTSYS directory like: serv->SetIcon("/ResetHPX","/rootsys/icons/ed_execute.png");