1docs::api::Apache2::SerUvseerrReCco(n3t)ributed Perl Docduomcesn:t:aatpiio:n:Apache2::ServerRec(3)
2
3
4

NAME

6       Apache2::ServerRec - Perl API for Apache server record accessors
7

Synopsis

9         use Apache2::ServerRec ();
10
11         $error_fname = $s->error_fname();
12
13         $is_virtual = $s->is_virtual();
14
15         $keep_alive         = $s->keep_alive();
16         $keep_alive_max     = $s->keep_alive_max();
17         $keep_alive_timeout = $s->keep_alive_timeout();
18
19         $limit_req_fields    = $s->limit_req_fields();
20         $limit_req_fieldsize = $s->limit_req_fieldsize();
21         $limit_req_line      = $s->limit_req_line();
22
23         $path = $s->path();
24
25         $hostname = $s->server_hostname();
26         $port     = $s->port();
27
28         $server_admin = $s->server_admin();
29
30         $proc = $s->process();
31
32         $timeout  = $s->timeout();
33         $loglevel = $s->loglevel();
34
35         my $server = Apache2::ServerUtil->server;
36         my $vhosts = 0;
37         for (my $s = $server->next; $s; $s = $s->next) {
38             $vhosts++;
39         }
40         print "There are $vhosts virtual hosts";
41

Description

43       "Apache2::ServerRec" provides the Perl API for Apache server_rec
44       object.
45
46       "Apache2::ServerUtil" provides an extra functionality.
47

API

49       "Apache2::ServerRec" provides the following functions and/or methods:
50
51       "error_fname"
52
53       Get/set the "ErrorLog" file value (e.g. logs/error_log)
54
55         $error_fname      = $s->error_fname();
56         $prev_error_fname = $s->error_fname($new_error_fname);
57
58       obj: $s ( "Apache2::ServerRec object" )
59       opt arg1: $new_error_fname ( string )
60           If passed, sets the new value for "ErrorLog"
61
62           Note the limited functionality under threaded MPMs.
63
64       ret: $error_fname ( string )
65           Returns the "ErrorLog" value setting.
66
67           If $new_error_fname is passed returns the setting before the
68           change.
69
70       since: 2.0.00
71
72       "is_virtual"
73
74       Test whether $s is a virtual host object
75
76         $is_virtual = $s->is_virtual();
77
78       obj: $s ( "Apache2::ServerRec object" )
79       ret: $is_virtual ( boolean )
80           Returns the is_virtual setting.
81
82           If $new_is_virtual is passed, returns the setting before the
83           change.
84
85       since: 2.0.00
86
87       Example:
88
89         print "This is a virtual host" if $s->is_virtual();
90
91       "keep_alive"
92
93       Get/set the "KeepAlive" setting, which specifies whether Apache should
94       accept more than one request over the same connection from the same
95       client.
96
97         $keep_alive      = $s->keep_alive();
98         $prev_keep_alive = $s->keep_alive($new_keep_alive);
99
100       obj: $s ( "Apache2::ServerRec object" )
101       opt arg1: $new_keep_alive ( boolean )
102           If passed, sets the new keep_alive.
103
104           Note the limited functionality under threaded MPMs.
105
106       ret: $keep_alive ( boolean )
107           Returns the "KeepAlive" setting.
108
109           If $new_keep_alive is passed, returns the setting before the
110           change.
111
112       since: 2.0.00
113
114       "keep_alive_max"
115
116       Get/set the "MaxKeepAliveRequest" setting, which specifies the maximum
117       number of requests Apache will serve over a "KeepAlive" connection.
118
119         $keep_alive_max      = $s->keep_alive_max();
120         $prev_keep_alive_max = $s->keep_alive_max($new_keep_alive_max);
121
122       obj: $s ( "Apache2::ServerRec object" )
123       opt arg1: $new_keep_alive_max ( integer )
124           If passed, sets the new keep_alive_max.
125
126           Note the limited functionality under threaded MPMs.
127
128       ret: $keep_alive_max ( integer )
129           Returns the keep_alive_max setting.
130
131           If $new_keep_alive_max is passed, returns the setting before the
132           change.
133
134       since: 2.0.00
135
136       "keep_alive_timeout"
137
138       Get/set the "KeepAliveTimeout" setting (in microsecs), which specifies
139       how long Apache will wait for another request before breaking a
140       "KeepAlive" connection.
141
142         $keep_alive_timeout      = $s->keep_alive_timeout();
143         $prev_keep_alive_timeout = $s->keep_alive_timeout($new_timeout);
144
145       obj: $s ( "Apache2::ServerRec object" )
146       opt arg1: $new_keep_alive_timeout ( integer )
147           The expected value is in microsecs.
148
149           If passed, sets the new "KeepAlive" timeout.
150
151           Note the limited functionality under threaded MPMs.
152
153       ret: $keep_alive_timeout ( integer )
154           Returns the "KeepAlive" timeout value (in microsecs).
155
156           If $new_timeout is passed, returns the setting before the change.
157
158       since: 2.0.00
159
160       "limit_req_fields"
161
162       Get/set limit on number of request header fields
163
164         $limit_req_fields      = $s->limit_req_fields();
165         $prev_limit_req_fields = $s->limit_req_fields($new_limit_req_fields);
166
167       obj: $s ( "Apache2::ServerRec object" )
168       opt arg1: $new_limit_req_fields ( integer )
169           If passed, sets the new request headers number limit.
170
171           Note the limited functionality under threaded MPMs.
172
173       ret: $limit_req_fields ( integer )
174           Returns the request headers number limit.
175
176           If $new_limit_req_fields is passed, returns the setting before the
177           change.
178
179       since: 2.0.00
180
181       "limit_req_fieldsize"
182
183       Get/set limit on size of any request header field
184
185         $limit_req_fieldsize = $s->limit_req_fieldsize();
186         $prev_limit          = $s->limit_req_fieldsize($new_limit);
187
188       obj: $s ( "Apache2::ServerRec object" )
189       opt arg1: $new_limit_req_fieldsize ( integer )
190           If passed, sets the new request header size limit.
191
192           Note the limited functionality under threaded MPMs.
193
194       ret: $limit_req_fieldsize ( integer )
195           Returns the request header size limit.
196
197           If $new_limit is passed, returns the setting before the change.
198
199       since: 2.0.00
200
201       "limit_req_line"
202
203       Get/set limit on size of the HTTP request line
204
205         $limit_req_line      = $s->limit_req_line();
206         $prev_limit_req_line = $s->limit_req_line($new_limit_req_line);
207
208       obj: $s ( "Apache2::ServerRec object" )
209       opt arg1: $new_limit_req_line ( integer )
210           If passed, sets the new request line limit value.
211
212           Note the limited functionality under threaded MPMs.
213
214       ret: $limit_req_line ( integer )
215           Returns the request line limit value
216
217           If $new_limit_req_line is passed, returns the setting before the
218           change.
219
220       since: 2.0.00
221
222       "loglevel"
223
224       Get/set the "LogLevel" directive value
225
226         $loglevel      = $s->loglevel();
227         $prev_loglevel = $s->loglevel($new_loglevel);
228
229       obj: $s ( "Apache2::ServerRec object" )
230       opt arg1: $new_loglevel ( "Apache2::Const :log constant" )
231           If passed, sets a new "LogLevel" value
232
233           Note the limited functionality under threaded MPMs.
234
235       ret: $loglevel ( "Apache2::Const :log constant" )
236           Returns the "LogLevel" value as a constant.
237
238           If $new_loglevel is passed, returns the setting before the change.
239
240       since: 2.0.00
241
242       For example, to set the "LogLevel" value to "info":
243
244         use Apache2::Const -compile => qw(LOG_INFO);
245         $s->loglevel(Apache2::Const::LOG_INFO);
246
247       "next"
248
249       The next server record in the list (if there are vhosts)
250
251         $s_next = $s->next();
252
253       obj: $s ( "Apache2::ServerRec object" )
254       ret: $s_next ( "Apache2::ServerRec object" )
255       since: 2.0.00
256
257       For example the following code traverses all the servers, starting from
258       the base server and continuing to vhost servers, counting all available
259       vhosts:
260
261         use Apache2::ServerRec ();
262         use Apache2::ServerUtil ();
263         my $server = Apache2::ServerUtil->server;
264         my $vhosts = 0;
265         for (my $s = $server->next; $s; $s = $s->next) {
266             $vhosts++;
267         }
268         print "There are $vhosts virtual hosts";
269
270       "path"
271
272       Get/set pathname for the "ServerPath" setting
273
274         $path      = $s->path();
275         $prev_path = $s->path($new_path);
276
277       obj: $s ( "Apache2::ServerRec object" )
278       opt arg1: $new_path ( string )
279           If passed, sets the new path.
280
281           Note the limited functionality under threaded MPMs.
282
283       ret: $path ( string )
284           Returns the path setting.
285
286           If $new_path is passed, returns the setting before the change.
287
288       since: 2.0.00
289
290       "port"
291
292       Get/set the port value
293
294         $port      = $s->port();
295         $prev_port = $s->port($new_port);
296
297       obj: $s ( "Apache2::ServerRec object" )
298       opt arg1: $new_port ( integer )
299           If passed, sets the new port.
300
301           Note the limited functionality under threaded MPMs.
302
303           META: I don't think one should be allowed to change port number
304           after the server has started.
305
306       ret: $port ( integer )
307           Returns the port setting.
308
309           If $new_port is passed returns the setting before the change.
310
311       since: 2.0.00
312
313       "process"
314
315       The process this server is running in
316
317         $proc = $s->process();
318
319       obj: $s ( "Apache2::ServerRec object" )
320       ret: $proc ( "Apache2::Process object" )
321       since: 2.0.00
322
323       "server_admin"
324
325       Get/set the "ServerAdmin" value
326
327         $server_admin      = $s->server_admin();
328         $prev_server_admin = $s->server_admin($new_server_admin);
329
330       obj: $s ( "Apache2::ServerRec object" )
331       opt arg1: $new_server_admin ( string )
332           If passed, sets the new "ServerAdmin" value.
333
334           Note the limited functionality under threaded MPMs.
335
336       ret: $server_admin ( string )
337           Returns the "ServerAdmin" value.
338
339           If $new_server_admin is passed, returns the setting before the
340           change.
341
342       since: 2.0.00
343
344       "server_hostname"
345
346       Get/set the "ServerName" value
347
348         $server_hostname      = $s->server_hostname();
349         $prev_server_hostname = $s->server_hostname($new_server_hostname);
350
351       obj: $s ( "Apache2::ServerRec object" )
352       opt arg1: $new_server_hostname ( string )
353           If passed, sets the "ServerName" value
354
355           Note the limited functionality under threaded MPMs.
356
357       ret: $server_hostname ( string )
358           Returns the "ServerName" value
359
360           If $new_server_hostname is passed, returns the setting before the
361           change.
362
363       since: 2.0.00
364
365       "timeout"
366
367       Get/set the timeout ("TimeOut") (in microsecs), which Apache will wait
368       for before it gives up doing something
369
370         $timeout      = $s->timeout();
371         $prev_timeout = $s->timeout($new_timeout);
372
373       obj: $s ( "Apache2::ServerRec object" )
374       opt arg1: $new_timeout ( integer )
375           If passed, sets the new timeout (the value should be in microsec‐
376           onds).
377
378           Note the limited functionality under threaded MPMs.
379
380       ret: $timeout ( integer )
381           Returns the timeout setting in microseconds.
382
383           If $new_timeout is passed, returns the setting before the change.
384
385       since: 2.0.00
386
387       Let us repeat again: the timeout values is microseconds. For example to
388       set the timeout to 20 secs:
389
390         $s->timeout(20_000_000);
391

Notes

393       Limited Functionality under Threaded MPMs
394
395       Note that under threaded MPMs, some of the read/write accessors, will
396       be able to set values only before threads are spawned (i.e. before the
397       "ChildInit phase").  Therefore if you are developing your application
398       on the non-threaded MPM, but planning to have it run under threaded
399       mpm, you should not use those methods to set values after the ChildInit
400       phase.
401
402       The affected accessor methods are marked as such in their respective
403       documentation entries.
404

Unsupported API

406       "Apache2::ServerRec" also provides auto-generated Perl interface for a
407       few other methods which aren't tested at the moment and therefore their
408       API is a subject to change. These methods will be finalized later as a
409       need arises. If you want to rely on any of the following methods please
410       contact the the mod_perl development mailing list so we can help each
411       other take the steps necessary to shift the method to an officially
412       supported API.
413
414       "addrs"
415
416       Get the addrs value
417
418         $addrs = $s->addrs();
419
420       obj: $s ( "Apache2::ServerRec object" )
421       ret: $addrs ( "Apache2::ServerAddr" )
422           Returns the addrs setting.
423
424       since: subject to change
425
426       META: this methods returns a vhost-specific Apache2::ServerAddr object,
427       which is not implemented at the moment. See the struct server_addr_rec
428       entry in httpd-2.0/include/httpd.h for more information. It seems that
429       most (all?) of the information in that record is available through
430       other APIs.
431
432       "lookup_defaults"
433
434       Get the lookup_defaults value.  MIME type info, etc., before we start
435       checking per-directory info.
436
437         $lookup_defaults = $s->lookup_defaults();
438
439       obj: $s ( "Apache2::ServerRec object" )
440       ret: $lookup_defaults ( "Apache2::ConfVector" )
441           Returns the lookup_defaults setting.
442
443       since: subject to change
444
445       "module_config"
446
447       Get config vector containing pointers to modules' per-server config
448       structures.
449
450         $module_config = $s->module_config();
451
452       obj: $s ( "Apache2::ServerRec object" )
453       ret: $module_config ( "Apache2::ConfVector" )
454           Returns the module_config setting.
455
456       since: subject to change
457
458       "names"
459
460       Get/set the value(s) for the "ServerAlias" setting
461
462         $names      = $s->names();
463         $prev_names = $s->names($new_names);
464
465       obj: $s ( "Apache2::ServerRec object" )
466       opt arg1: $new_names ( "APR::ArrayHeader" )
467           If passed, sets the new names.
468
469           Note the limited functionality under threaded MPMs.
470
471       ret: $names ( "APR::ArrayHeader" )
472           Returns the names setting.
473
474           If $new_names is passed, returns the setting before the change.
475
476       since: 2.0.00
477
478       META: we don't have "APR::ArrayHeader" yet
479
480       "wild_names"
481
482       Wildcarded names for ServerAlias servers
483
484         $wild_names      = $s->wild_names();
485         $prev_wild_names = $s->wild_names($new_wild_names);
486
487       obj: $s ( "Apache2::ServerRec object" )
488       opt arg1: $new_wild_names ( "APR::ArrayHeader" )
489           If passed, sets the new wild_names.
490
491           Note the limited functionality under threaded MPMs.
492
493       ret: $wild_names ( "APR::ArrayHeader" )
494           Returns the wild_names setting.
495
496           If $new_wild_names is passed, returns the setting before the
497           change.
498
499       since: 2.0.00
500
501       META: we don't have "APR::ArrayHeader" yet
502

See Also

504       mod_perl 2.0 documentation.
505
507       mod_perl 2.0 and its core modules are copyrighted under The Apache
508       Software License, Version 2.0.
509

Authors

511       The mod_perl development team and numerous contributors.
512
513
514
515perl v5.8.8                       2006-11-19  docs::api::Apache2::ServerRec(3)
Impressum