This file is indexed.

/usr/share/doc/libapache2-mod-perl2-doc/docs/2.0/api/Apache2/compat.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
<?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="#Compatibility-Functions-Colliding-with-mod_perl-2.0-API">Compatibility Functions Colliding with mod_perl 2.0 API</a>
    <ul>
      <li><a href="#Available-Overridable-Functions">Available Overridable Functions</a></li>
    </ul>
  </li>
  <li><a href="#Use-in-CPAN-Modules">Use in CPAN Modules</a></li>
  <li><a href="#API">API</a></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::compat -- 1.0 backward compatibility functions deprecated in 2.0</p>

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

<pre><code>  # either add at the very beginning of startup.pl
  use Apache2::compat;
  # or httpd.conf
  PerlModule Apache2::compat

  # override and restore compat functions colliding with mp2 API
  Apache2::compat::override_mp2_api(&#39;Apache2::Connection::local_addr&#39;);
  my ($local_port, $local_addr) = sockaddr_in($c-&gt;local_addr);
  Apache2::compat::restore_mp2_api(&#39;Apache2::Connection::local_addr&#39;);</code></pre>

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

<p><code>Apache2::compat</code> provides mod_perl 1.0 compatibility layer and can be used to smooth the transition process to mod_perl 2.0.</p>

<p>It includes functions that have changed their API or were removed in mod_perl 2.0. If your code uses any of those functions, you should load this module at the server startup, and everything should work as it did in 1.0. If it doesn&#39;t please <a>report the bug</a>, but before you do that please make sure that your code does work properly under mod_perl 1.0.</p>

<p>However, remember, that it&#39;s implemented in pure Perl and not C, therefore its functionality is not optimized and it&#39;s the best to try to <a>port your code</a> not to use deprecated functions and stop using the compatibility layer.</p>

<h1 id="Compatibility-Functions-Colliding-with-mod_perl-2.0-API">Compatibility Functions Colliding with mod_perl 2.0 API</h1>

<p>Most of the functions provided by Apache2::compat don&#39;t interfere with mod_perl 2.0 API. However there are several functions which have the same name in the mod_perl 1.0 and mod_perl 2.0 API, accept the same number of arguments, but either the arguments themselves aren&#39;t the same or the return values are different. For example the mod_perl 1.0 code:</p>

<pre><code>  require Socket;
  my $sockaddr_in = $c-&gt;local_addr;
  my ($local_port, $local_addr) = Socket::sockaddr_in($sockaddr_in);</code></pre>

<p>should be adjusted to be:</p>

<pre><code>  require Apache2::Connection;
  require APR::SockAddr;
  my $sockaddr = $c-&gt;local_addr;
  my ($local_port, $local_addr) = ($sockaddr-&gt;port, $sockaddr-&gt;ip_get);</code></pre>

<p>to work under mod_perl 2.0.</p>

<p>As you can see in mod_perl 1.0 API local_addr() was returning a SOCKADDR_IN object (see the Socket perl manpage), in mod_perl 2.0 API it returns an <code><a>APR::SockAddr</a></code> object, which is a totally different beast. If Apache2::compat overrides the function <code>local_addr()</code> to be back-compatible with mod_perl 1.0 API. Any code that relies on this function to work as it should under mod_perl 2.0 will be broken. Therefore the solution is not to override <code>local_addr()</code> by default. Instead a special API is provided which overrides colliding functions only when needed and which can be restored when no longer needed. So for example if you have code from mod_perl 1.0:</p>

<pre><code>  my ($local_port, $local_addr) = Socket::sockaddr_in($c-&gt;local_addr);</code></pre>

<p>and you aren&#39;t ready to port it to to use the mp2 API:</p>

<pre><code>  my ($local_port, $local_addr) = ($c-&gt;local_addr-&gt;port,
                                   $c-&gt;local_addr-&gt;ip_get);</code></pre>

<p>you could do the following:</p>

<pre><code>  Apache2::compat::override_mp2_api(&#39;Apache2::Connection::local_addr&#39;);
  my ($local_port, $local_addr) = Socket::sockaddr_in($c-&gt;local_addr);
  Apache2::compat::restore_mp2_api(&#39;Apache2::Connection::local_addr&#39;);</code></pre>

<p>Notice that you need to restore the API as soon as possible.</p>

<p>Both <code>override_mp2_api()</code> and <code>restore_mp2_api()</code> accept a list of functions to operate on.</p>

<h2 id="Available-Overridable-Functions">Available Overridable Functions</h2>

<p>At the moment the following colliding functions are available for overriding:</p>

<dl>

<dt id="Apache2::RequestRec::notes">Apache2::RequestRec::notes</dt>
<dd>

</dd>
<dt id="Apache2::RequestRec::filename">Apache2::RequestRec::filename</dt>
<dd>

</dd>
<dt id="Apache2::RequestRec::finfo">Apache2::RequestRec::finfo</dt>
<dd>

</dd>
<dt id="Apache2::Connection::local_addr">Apache2::Connection::local_addr</dt>
<dd>

</dd>
<dt id="Apache2::Connection::remote_addr">Apache2::Connection::remote_addr</dt>
<dd>

</dd>
<dt id="Apache2::Util::ht_time">Apache2::Util::ht_time</dt>
<dd>

</dd>
<dt id="Apache2::Module::top_module">Apache2::Module::top_module</dt>
<dd>

</dd>
<dt id="Apache2::Module::get_config">Apache2::Module::get_config</dt>
<dd>

</dd>
<dt id="APR::URI::unparse">APR::URI::unparse</dt>
<dd>

</dd>
</dl>

<h1 id="Use-in-CPAN-Modules">Use in CPAN Modules</h1>

<p>The short answer: <b>Do not use</b> <code>Apache2::compat</code> in CPAN modules.</p>

<p>The long answer:</p>

<p><code>Apache2::compat</code> is useful during the mod_perl 1.0 code porting. Though remember that it&#39;s implemented in pure Perl. In certain cases it overrides mod_perl 2.0 methods, because their API is very different and doesn&#39;t map 1:1 to mod_perl 1.0. So if anything, not under user&#39;s control, loads <code>Apache2::compat</code> user&#39;s code is forced to use the potentially slower method. Which is quite bad.</p>

<p>Some users may choose to keep using <code>Apache2::compat</code> in production and it may perform just fine. Other users will choose not to use that module, by porting their code to use mod_perl 2.0 API. However it should be users&#39; choice whether to load this module or not and not to be enforced by CPAN modules.</p>

<p>If you port your CPAN modules to work with mod_perl 2.0, you should follow the porting <a>Perl</a> and <a>XS</a> module guidelines.</p>

<p>Users that are stuck with CPAN modules preloading <code>Apache2::compat</code>, can prevent this from happening by adding</p>

<pre><code>  $INC{&#39;Apache2/compat.pm&#39;} = __FILE__;</code></pre>

<p>at the very beginning of their <i>startup.pl</i>. But this will most certainly break the module that needed this module.</p>

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

<p>You should be reading the mod_perl 1.0 <a>API docs</a> for usage of the methods and functions in this package, since what this module is doing is providing a backwards compatibility and it makes no sense to duplicate documentation.</p>

<p>Another important document to read is: <a>Migrating from mod_perl 1.0 to mod_perl 2.0</a> which covers all mod_perl 1.0 constants, functions and methods that have changed in mod_perl 2.0.</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>