1
1
# HTTP server in ROOT
2
2
3
- Idea of such server – provide direct access to the different data
4
- from running ROOT application. Any object can be streamed at the moment
5
- when request is coming and delivered to the browser.
6
- Main benefit of such approach – one do not need to create any temporary ROOT files for such task.
3
+ Idea of such server – provide direct access to the different data
4
+ from running ROOT application. Any object can be streamed at the moment
5
+ when request is coming and delivered to the browser.
6
+ Main benefit of such approach – one do not need to create any temporary ROOT files for such task.
7
7
8
8
## Starting HTTP server
9
9
10
10
To start http server, at any time create instance
11
- of the ** ` THttpServer ` ** class like:
11
+ of the ** ` THttpServer ` ** class like:
12
12
13
13
``` {.cpp}
14
14
serv = new THttpServer("http:8080");
@@ -17,9 +17,9 @@ serv = new THttpServer("http:8080");
17
17
This will starts civetweb-based http server with http port 8080.
18
18
Than one should be able to open address "http://localhost:8080 "
19
19
in any modern browser (IE, Firefox, Chrome, Opera) and browse objects,
20
- created in application. By default, server can access files, canvases
20
+ created in application. By default, server can access files, canvases
21
21
and histograms via gROOT pointer. All such objects can be displayed with
22
- JSRootIO graphics.
22
+ JSRootIO graphics.
23
23
24
24
At any time one could register other objects with the command:
25
25
@@ -31,13 +31,13 @@ serv->Register("graphs/subfolder", gr);
31
31
32
32
If objects content is changing in the applicaion, one could
33
33
enable monitoring flag in the browser - than objects view will be regularly updated.
34
-
34
+
35
35
36
36
## Configuring user access
37
37
38
- By default http server is open for anonymous access.
38
+ By default http server is open for anonymous access.
39
39
One could restrict access to the server only for authenticated users.
40
- First of all, one should create password file, using ** htdigest** utility.
40
+ First of all, one should create password file, using ** htdigest** utility.
41
41
42
42
``` {.sh}
43
43
[shell] htdigest -c .htdigest domain_name user_name
@@ -56,7 +56,7 @@ After that browser will automatically request to input name/password for domain
56
56
57
57
## Using FastCGI interface
58
58
59
- FastCGI is a protocol for interfacing interactive programs with a web server like
59
+ FastCGI is a protocol for interfacing interactive programs with a web server like
60
60
Apache, lighttpd, Microsoft ISS and many others.
61
61
62
62
When starting THttpServer, one could specify:
@@ -79,12 +79,12 @@ Example of configuration file for lighttpd server is:
79
79
)
80
80
```
81
81
82
- In this case, to access running ROOT application, one should open
82
+ In this case, to access running ROOT application, one should open
83
83
following address in the browser:
84
84
http://lighttpd_hostname/remote_scripts/root.cgi/
85
85
86
86
In fact, FastCGI interface can run in parallel to http server.
87
- One just call:
87
+ One just call:
88
88
89
89
``` {.cpp}
90
90
serv = new THttpServer("http:8080");
@@ -96,9 +96,9 @@ One could specify debug parameter to be able adjust FastCGI configuration on the
96
96
``` {.cpp}
97
97
serv->CreateEngine("fastcgi:9000/none?debug=1");
98
98
```
99
-
100
- All user access will be ruled by web server -
101
- for the moment one cannot restrict with fastcgi engine.
99
+
100
+ All user access will be ruled by web server -
101
+ for the moment one cannot restrict with fastcgi engine.
102
102
103
103
104
104
## Integrate with existing applications
@@ -112,8 +112,8 @@ Central point of integration - when and how THttpServer get access to data from
112
112
By default it is done during gSystem->ProcessEvents() call - THttpServer uses synchronous timer,
113
113
which is activated every 100 ms. Such approach works perfectely when running macros in interactive ROOT shell.
114
114
115
- If application runs in compiled code and does not contains gSystem->ProcessEvents() calls,
116
- two method are available.
115
+ If application runs in compiled code and does not contains gSystem->ProcessEvents() calls,
116
+ two method are available.
117
117
118
118
### Asynchrounous timer
119
119
@@ -123,7 +123,7 @@ First method is to configure asynchronous timer for the server like:
123
123
serv->SetTimer(100, kFALSE);
124
124
```
125
125
126
- Than timer will be activated even without gSystem->ProcessEvents() method call.
126
+ Than timer will be activated even without gSystem->ProcessEvents() method call.
127
127
Main advantage of such method that application code can be used as it is.
128
128
Disadvantage - there is no control when communication between server and application is performed.
129
129
It could happen just in-between of ** ` TH1::Fill() ` ** call and histogram object may be incomplete.
@@ -132,7 +132,7 @@ It could happen just in-between of **`TH1::Fill()`** call and histogram object m
132
132
### Explicit call of THttpServer::ProcessRequests() method
133
133
134
134
Second method is preferable - one just insert in the application
135
- regular calls of the THttpServer::ProcessRequests() method. Like:
135
+ regular calls of the THttpServer::ProcessRequests() method. Like:
136
136
137
137
``` {.cpp}
138
138
serv->ProcessRequests();
@@ -148,10 +148,10 @@ serv->SetTimer(0, kTRUE);
148
148
149
149
## Data access from command shell
150
150
151
- Big advantage of http protocol that it supported not only in web browsers
152
- but also in many other applications.
153
- One could directly use http requests to access
154
- ROOT objects and data members from any kind of scripts.
151
+ Big advantage of http protocol that it supported not only in web browsers
152
+ but also in many other applications.
153
+ One could directly use http requests to access
154
+ ROOT objects and data members from any kind of scripts.
155
155
156
156
If one starts server and register object like:
157
157
@@ -185,7 +185,7 @@ One could access also class members of object like:
185
185
``` {.sh}
186
186
[shell] wget http://localhost:8080/Objects/subfolder/obj/fTitle/root.json
187
187
```
188
-
188
+
189
189
Result will be: "title".
190
190
191
191
If access to the server restricted with htdigest method,
@@ -199,10 +199,10 @@ Command will look like:
199
199
Following requests can be performed:
200
200
* root.bin - 20-byte header and zipped binary TBuffer content
201
201
* root.json - ROOT JSON representation for object and objects members
202
- * root.xml - ROOT XML representation
203
- * root.png - PNG image
204
- * root.gif - GIF image
205
- * root.jpeg - JPEG image
202
+ * root.xml - ROOT XML representation
203
+ * root.png - PNG image
204
+ * root.gif - GIF image
205
+ * root.jpeg - JPEG image
206
206
207
207
For images one could specify h (height), w (width) and opt (draw) options. Like:
208
208
0 commit comments