This file is indexed.

/usr/share/doc/libapache2-mod-perl2-doc/docs/2.0/api/Apache2/Response.html is in libapache2-mod-perl2-doc 2.0.8+httpd24-r1449661-6ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body style="background-color: white">



<ul id="index">
  <li><a href="#NAME">NAME</a></li>
  <li><a href="#Synopsis">Synopsis</a></li>
  <li><a href="#Description">Description</a></li>
  <li><a href="#API">API</a>
    <ul>
      <li><a href="#custom_response">custom_response</a></li>
      <li><a href="#make_etag">make_etag</a></li>
      <li><a href="#meets_conditions">meets_conditions</a></li>
      <li><a href="#rationalize_mtime">rationalize_mtime</a></li>
      <li><a href="#send_cgi_header">send_cgi_header</a></li>
      <li><a href="#set_content_length">set_content_length</a></li>
      <li><a href="#set_etag">set_etag</a></li>
      <li><a href="#set_keepalive">set_keepalive</a></li>
      <li><a href="#set_last_modified">set_last_modified</a></li>
      <li><a href="#update_mtime">update_mtime</a></li>
    </ul>
  </li>
  <li><a href="#Unsupported-API">Unsupported API</a>
    <ul>
      <li><a href="#send_error_response">send_error_response</a></li>
      <li><a href="#send_mmap">send_mmap</a></li>
    </ul>
  </li>
  <li><a href="#See-Also">See Also</a></li>
  <li><a href="#Copyright">Copyright</a></li>
  <li><a href="#Authors">Authors</a></li>
</ul>

<h1 id="NAME">NAME</h1>

<p>Apache2::Response - Perl API for Apache HTTP request response methods</p>

<h1 id="Synopsis">Synopsis</h1>

<pre><code>  use Apache2::Response ();
  
  $r-&gt;custom_response(Apache2::Const::FORBIDDEN, &quot;No Entry today&quot;);
  
  $etag = $r-&gt;make_etag($force_weak);
  $r-&gt;set_etag();
  $status = $r-&gt;meets_conditions();
  
  $mtime_rat = $r-&gt;rationalize_mtime($mtime);
  $r-&gt;set_last_modified($mtime);
  $r-&gt;update_mtime($mtime);
  
  $r-&gt;send_cgi_header($buffer);
  
  $r-&gt;set_content_length($length);
  
  $ret = $r-&gt;set_keepalive();</code></pre>

<h1 id="Description">Description</h1>

<p><code>Apache2::Response</code> provides the <a>Apache request object</a> utilities API for dealing with HTTP response generation process.</p>

<h1 id="API">API</h1>

<p><code>Apache2::Response</code> provides the following functions and/or methods:</p>

<h2 id="custom_response"><code>custom_response</code></h2>

<p>Install a custom response handler for a given status</p>

<pre><code>  $r-&gt;custom_response($status, $string);</code></pre>

<dl>

<dt id="obj:-r-Apache2::RequestRec-object">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>

<p>The current request</p>

</dd>
<dt id="arg1:-status-Apache2::Const-constant">arg1: <code>$status</code> ( <code><a>Apache2::Const constant</a></code> )</dt>
<dd>

<p>The status for which the custom response should be used (e.g. <code>Apache2::Const::AUTH_REQUIRED</code>)</p>

</dd>
<dt id="arg2:-string-string">arg2: <code>$string</code> (string)</dt>
<dd>

<p>The custom response to use. This can be a static string, or a URL, full or just the uri path (<i>/foo/bar.txt</i>).</p>

</dd>
<dt id="ret:-no-return-value">ret: no return value</dt>
<dd>

</dd>
<dt id="since:-2.0.00">since: 2.0.00</dt>
<dd>

</dd>
</dl>

<p><code>custom_response()</code> doesn&#39;t alter the response code, but is used to replace the standard response body. For example, here is how to change the response body for the access handler failure:</p>

<pre><code>  package MyApache2::MyShop;
  use Apache2::Response ();
  use Apache2::Const -compile =&gt; qw(FORBIDDEN OK);
  sub access {
      my $r = shift;
   
      if (MyApache2::MyShop::tired_squirrels()) {
          $r-&gt;custom_response(Apache2::Const::FORBIDDEN,
              &quot;It&#39;s siesta time, please try later&quot;);
          return Apache2::Const::FORBIDDEN;
      }
  
      return Apache2::Const::OK;
  }
  ...

  # httpd.conf
  PerlModule MyApache2::MyShop
  &lt;Location /TestAPI__custom_response&gt;
      AuthName dummy
      AuthType none
      PerlAccessHandler   MyApache2::MyShop::access
      PerlResponseHandler MyApache2::MyShop::response
  &lt;/Location&gt;</code></pre>

<p>When squirrels can&#39;t run any more, the handler will return 403, with the custom message:</p>

<pre><code>  It&#39;s siesta time, please try later</code></pre>

<h2 id="make_etag"><code>make_etag</code></h2>

<p>Construct an entity tag from the resource information. If it&#39;s a real file, build in some of the file characteristics.</p>

<pre><code>  $etag = $r-&gt;make_etag($force_weak);</code></pre>

<dl>

<dt id="obj:-r-Apache2::RequestRec-object1">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>

<p>The current request</p>

</dd>
<dt id="arg1:-force_weak-number">arg1: <code>$force_weak</code> (number)</dt>
<dd>

<p>Force the entity tag to be weak - it could be modified again in as short an interval.</p>

</dd>
<dt id="ret:-etag-string">ret: <code>$etag</code> (string)</dt>
<dd>

<p>The entity tag</p>

</dd>
<dt id="since:-2.0.001">since: 2.0.00</dt>
<dd>

</dd>
</dl>

<h2 id="meets_conditions"><code>meets_conditions</code></h2>

<p>Implements condition <code>GET</code> rules for HTTP/1.1 specification. This function inspects the client headers and determines if the response fulfills the specified requirements.</p>

<pre><code>  $status = $r-&gt;meets_conditions();</code></pre>

<dl>

<dt id="obj:-r-Apache2::RequestRec-object2">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>

<p>The current request</p>

</dd>
<dt id="ret:-status-Apache2::Const-status-constant">ret: <code>$status</code> ( <code><a>Apache2::Const status constant</a></code> )</dt>
<dd>

<p><code>Apache2::Const::OK</code> if the response fulfills the condition GET rules. Otherwise some other status code (which should be returned to Apache).</p>

</dd>
<dt id="since:-2.0.002">since: 2.0.00</dt>
<dd>

</dd>
</dl>

<p>Refer to the <a>Generating Correct HTTP Headers</a> document for an indepth discussion of this method.</p>

<h2 id="rationalize_mtime"><code>rationalize_mtime</code></h2>

<p>Return the latest rational time from a request/mtime pair.</p>

<pre><code>  $mtime_rat = $r-&gt;rationalize_mtime($mtime);</code></pre>

<dl>

<dt id="obj:-r-Apache2::RequestRec-object3">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>

<p>The current request</p>

</dd>
<dt id="arg1:-mtime-time-in-seconds">arg1: <code>$mtime</code> ( time in seconds )</dt>
<dd>

<p>The last modified time</p>

</dd>
<dt id="ret:-mtime_rat-time-in-seconds">ret: <code>$mtime_rat</code> ( time in seconds )</dt>
<dd>

<p>the latest rational time from a request/mtime pair. Mtime is returned unless it&#39;s in the future, in which case we return the current time.</p>

</dd>
<dt id="since:-2.0.003">since: 2.0.00</dt>
<dd>

</dd>
</dl>

<h2 id="send_cgi_header"><code>send_cgi_header</code></h2>

<p>Parse the header</p>

<pre><code>  $r-&gt;send_cgi_header($buffer);</code></pre>

<dl>

<dt id="obj:-r-Apache2::RequestRec-object4">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>

</dd>
<dt id="arg1:-buffer-string">arg1: <code>$buffer</code> (string)</dt>
<dd>

<p>headers and optionally a response body</p>

</dd>
<dt id="ret:-no-return-value1">ret: no return value</dt>
<dd>

</dd>
<dt id="since:-2.0.004">since: 2.0.00</dt>
<dd>

</dd>
</dl>

<p>This method is really for back-compatibility with mod_perl 1.0. It&#39;s very inefficient to send headers this way, because of the parsing overhead.</p>

<p>If there is a response body following the headers it&#39;ll be handled too (as if it was sent via <code><a>print()</a></code>).</p>

<p>Notice that if only HTTP headers are included they won&#39;t be sent until some body is sent (again the &quot;send&quot; part is retained from the mod_perl 1.0 method).</p>

<h2 id="set_content_length"><code>set_content_length</code></h2>

<p>Set the content length for this request.</p>

<pre><code>  $r-&gt;set_content_length($length);</code></pre>

<dl>

<dt id="obj:-r-Apache2::RequestRec-object5">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>

<p>The current request</p>

</dd>
<dt id="arg1:-length-integer">arg1: <code>$length</code> (integer)</dt>
<dd>

<p>The new content length</p>

</dd>
<dt id="ret:-no-return-value2">ret: no return value</dt>
<dd>

</dd>
<dt id="since:-2.0.005">since: 2.0.00</dt>
<dd>

</dd>
</dl>

<h2 id="set_etag"><code>set_etag</code></h2>

<p>Set the E-tag outgoing header</p>

<pre><code>  $r-&gt;set_etag();</code></pre>

<dl>

<dt id="obj:-r-Apache2::RequestRec-object6">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>

</dd>
<dt id="ret:-no-return-value3">ret: no return value</dt>
<dd>

</dd>
<dt id="since:-2.0.006">since: 2.0.00</dt>
<dd>

</dd>
</dl>

<h2 id="set_keepalive"><code>set_keepalive</code></h2>

<p>Set the keepalive status for this request</p>

<pre><code>  $ret = $r-&gt;set_keepalive();</code></pre>

<dl>

<dt id="obj:-r-Apache2::RequestRec-object7">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>

<p>The current request</p>

</dd>
<dt id="ret:-ret-boolean">ret: <code>$ret</code> ( boolean )</dt>
<dd>

<p>true if keepalive can be set, false otherwise</p>

</dd>
<dt id="since:-2.0.007">since: 2.0.00</dt>
<dd>

</dd>
</dl>

<p>It&#39;s called by <code>ap_http_header_filter()</code>. For the complete complicated logic implemented by this method see <i>httpd-2.0/server/http_protocol.c</i>.</p>

<h2 id="set_last_modified"><code>set_last_modified</code></h2>

<p>sets the <code>Last-Modified</code> response header field to the value of the mtime field in the request structure -- rationalized to keep it from being in the future.</p>

<pre><code>  $r-&gt;set_last_modified($mtime);</code></pre>

<dl>

<dt id="obj:-r-Apache2::RequestRec-object8">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>

</dd>
<dt id="opt-arg1:-mtime-time-in-seconds">opt arg1: <code>$mtime</code> ( time in seconds )</dt>
<dd>

<p>if the <code>$mtime</code> argument is passed, <a href="#C_update_mtime_">$r-&gt;update_mtime</a> will be first run with that argument.</p>

</dd>
<dt id="ret:-no-return-value4">ret: no return value</dt>
<dd>

</dd>
<dt id="since:-2.0.008">since: 2.0.00</dt>
<dd>

</dd>
</dl>

<h2 id="update_mtime"><code>update_mtime</code></h2>

<p>Set the <code><a>$r-&gt;mtime</a></code> field to the specified value if it&#39;s later than what&#39;s already there.</p>

<pre><code>  $r-&gt;update_mtime($mtime);</code></pre>

<dl>

<dt id="obj:-r-Apache2::RequestRec-object9">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>

<p>The current request</p>

</dd>
<dt id="arg1:-mtime-time-in-seconds1">arg1: <code>$mtime</code> ( time in seconds )</dt>
<dd>

</dd>
<dt id="ret:-no-return-value5">ret: no return value</dt>
<dd>

</dd>
<dt id="since:-2.0.009">since: 2.0.00</dt>
<dd>

</dd>
</dl>

<p>See also: <a href="#C_set_last_modified_">$r-&gt;set_last_modified</a>.</p>

<h1 id="Unsupported-API">Unsupported API</h1>

<p><code>Apache2::Response</code> also provides auto-generated Perl interface for a few other methods which aren&#39;t tested at the moment and therefore their API is a subject to change. These methods will be finalized later as a need arises. If you want to rely on any of the following methods please contact the <a>the mod_perl development mailing list</a> so we can help each other take the steps necessary to shift the method to an officially supported API.</p>

<h2 id="send_error_response"><code>send_error_response</code></h2>

<p>Send an &quot;error&quot; response back to client. It is used for any response that can be generated by the server from the request record. This includes all 204 (no content), 3xx (redirect), 4xx (client error), and 5xx (server error) messages that have not been redirected to another handler via the ErrorDocument feature.</p>

<pre><code>  $r-&gt;send_error_response($recursive_error);</code></pre>

<dl>

<dt id="obj:-r-Apache2::RequestRec-object10">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>

<p>The current request</p>

</dd>
<dt id="arg1:-recursive_error-boolean">arg1: <code>$recursive_error</code> ( boolean )</dt>
<dd>

<p>the error status in case we get an error in the process of trying to deal with an <code>ErrorDocument</code> to handle some other error. In that case, we print the default report for the first thing that went wrong, and more briefly report on the problem with the <code>ErrorDocument</code>.</p>

</dd>
<dt id="ret:-no-return-value6">ret: no return value</dt>
<dd>

</dd>
<dt id="since:-2.0.0010">since: 2.0.00</dt>
<dd>

</dd>
</dl>

<p>META: it&#39;s really an internal Apache method, I&#39;m not quite sure how can it be used externally.</p>

<h2 id="send_mmap"><code>send_mmap</code></h2>

<p>META: Autogenerated - needs to be reviewed/completed</p>

<p>Send an MMAP&#39;ed file to the client</p>

<pre><code>  $ret = $r-&gt;send_mmap($mm, $offset, $length);</code></pre>

<dl>

<dt id="obj:-r-Apache2::RequestRec-object11">obj: <code>$r</code> ( <code><a>Apache2::RequestRec object</a></code> )</dt>
<dd>

<p>The current request</p>

</dd>
<dt id="arg1:-mm-APR::Mmap">arg1: <code>$mm</code> (<code><a>APR::Mmap</a></code>)</dt>
<dd>

<p>The MMAP&#39;ed file to send</p>

</dd>
<dt id="arg2:-offset-number">arg2: <code>$offset</code> (number)</dt>
<dd>

<p>The offset into the MMAP to start sending</p>

</dd>
<dt id="arg3:-length-integer">arg3: <code>$length</code> (integer)</dt>
<dd>

<p>The amount of data to send</p>

</dd>
<dt id="ret:-ret-integer">ret: <code>$ret</code> (integer)</dt>
<dd>

<p>The number of bytes sent</p>

</dd>
<dt id="since:-2.0.0011">since: 2.0.00</dt>
<dd>

</dd>
</dl>

<p>META: requires a working APR::Mmap, which is not supported at the moment.</p>

<h1 id="See-Also">See Also</h1>

<p><a>mod_perl 2.0 documentation</a>.</p>

<h1 id="Copyright">Copyright</h1>

<p>mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0.</p>

<h1 id="Authors">Authors</h1>

<p><a>The mod_perl development team and numerous contributors</a>.</p>


</body>

</html>