File: classHooks.html

package info (click to toggle)
passenger 2.2.11debian-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 11,576 kB
  • ctags: 28,138
  • sloc: cpp: 66,323; ruby: 9,646; ansic: 2,425; python: 141; sh: 56; makefile: 29
file content (155 lines) | stat: -rw-r--r-- 9,735 bytes parent folder | download
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Passenger: Hooks Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>Hooks Class Reference<br>
<small>
[<a class="el" href="group__Core.html">Core Apache-related classes and functions</a>]</small>
</h1><!-- doxytag: class="Hooks" -->Apache hook functions, wrapped in a class.  
<a href="#_details">More...</a>
<p>

<p>
<a href="classHooks-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classHooks.html#64333270a19c93451c33dcb8fe1666de">saveOriginalFilename</a> (request_rec *r)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This is the hook method for the map_to_storage hook.  <a href="#64333270a19c93451c33dcb8fe1666de"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classHooks.html#404c390fa2529611d1c5a15c0bd9f1c3">saveStateBeforeRewriteRules</a> (request_rec *r)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The default .htaccess provided by on Rails on Rails (that is, before version 2.1.0) has the following mod_rewrite rules in it:.  <a href="#404c390fa2529611d1c5a15c0bd9f1c3"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classHooks.html#e3091c57c95b2f8269f566099802f0ec">startBlockingModDir</a> (request_rec *r)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">mod_dir does the following: If r-&gt;filename is a directory, and the URI doesn't end with a slash, then it will redirect the browser to an URI with a slash.  <a href="#e3091c57c95b2f8269f566099802f0ec"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="classHooks.html#d6cca64be8a9075b4b92efdb4d9020a5">startBlockingModAutoIndex</a> (request_rec *r)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">mod_autoindex will try to display a directory index for URIs that map to a directory.  <a href="#d6cca64be8a9075b4b92efdb4d9020a5"></a><br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Apache hook functions, wrapped in a class. <hr><h2>Member Function Documentation</h2>
<a class="anchor" name="64333270a19c93451c33dcb8fe1666de"></a><!-- doxytag: member="Hooks::saveOriginalFilename" ref="64333270a19c93451c33dcb8fe1666de" args="(request_rec *r)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Hooks::saveOriginalFilename           </td>
          <td>(</td>
          <td class="paramtype">request_rec *&nbsp;</td>
          <td class="paramname"> <em>r</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This is the hook method for the map_to_storage hook. 
<p>
Apache's final map_to_storage hook method (defined in core.c) will do the following:<p>
If r-&gt;filename doesn't exist, then it will change the filename to the following form:<p>
A/B<p>
A is top-most directory that exists. B is the first filename piece that normally follows A. For example, suppose that a website's DocumentRoot is /website, on server <a href="http://test.com/.">http://test.com/.</a> Suppose that there's also a directory /website/images. No other files or directories exist in /website.<p>
If we access: then r-&gt;filename will be: <a href="http://test.com/foo/bar">http://test.com/foo/bar</a> /website/foo <a href="http://test.com/foo/bar/baz">http://test.com/foo/bar/baz</a> /website/foo <a href="http://test.com/images/foo/bar">http://test.com/images/foo/bar</a> /website/images/foo<p>
We obviously don't want this to happen because it'll interfere with our page cache file search code. So here we save the original value of r-&gt;filename so that we can use it later. 
</div>
</div><p>
<a class="anchor" name="404c390fa2529611d1c5a15c0bd9f1c3"></a><!-- doxytag: member="Hooks::saveStateBeforeRewriteRules" ref="404c390fa2529611d1c5a15c0bd9f1c3" args="(request_rec *r)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Hooks::saveStateBeforeRewriteRules           </td>
          <td>(</td>
          <td class="paramtype">request_rec *&nbsp;</td>
          <td class="paramname"> <em>r</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
The default .htaccess provided by on Rails on Rails (that is, before version 2.1.0) has the following mod_rewrite rules in it:. 
<p>
RewriteEngine on RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.cgi [QSA,L]<p>
As a result, all requests that do not map to a filename will be redirected to dispatch.cgi (or dispatch.fcgi, if the user so specified). We don't want that to happen, so before mod_rewrite applies its rules, we save the current state. After mod_rewrite has applied its rules, undoRedirectionToDispatchCgi() will check whether mod_rewrite attempted to perform an internal redirection to dispatch.(f)cgi. If so, then it will revert the state to the way it was before mod_rewrite took place. 
</div>
</div><p>
<a class="anchor" name="d6cca64be8a9075b4b92efdb4d9020a5"></a><!-- doxytag: member="Hooks::startBlockingModAutoIndex" ref="d6cca64be8a9075b4b92efdb4d9020a5" args="(request_rec *r)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Hooks::startBlockingModAutoIndex           </td>
          <td>(</td>
          <td class="paramtype">request_rec *&nbsp;</td>
          <td class="paramname"> <em>r</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
mod_autoindex will try to display a directory index for URIs that map to a directory. 
<p>
This is undesired because of page caching semantics. Suppose that a Rails application has an ImagesController which has page caching enabled, and thus also a 'public/images' directory. When the visitor visits /images we'll want the request to be forwarded to the Rails application, instead of displaying a directory index.<p>
So in this hook method, we temporarily change some fields in the request structure in order to block mod_autoindex. In endBlockingModAutoIndex(), we restore the request structure to its former state. 
</div>
</div><p>
<a class="anchor" name="e3091c57c95b2f8269f566099802f0ec"></a><!-- doxytag: member="Hooks::startBlockingModDir" ref="e3091c57c95b2f8269f566099802f0ec" args="(request_rec *r)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Hooks::startBlockingModDir           </td>
          <td>(</td>
          <td class="paramtype">request_rec *&nbsp;</td>
          <td class="paramname"> <em>r</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
mod_dir does the following: If r-&gt;filename is a directory, and the URI doesn't end with a slash, then it will redirect the browser to an URI with a slash. 
<p>
For example, if you go to <a href="http://foo.com/images,">http://foo.com/images,</a> then it will redirect you to <a href="http://foo.com/images/.">http://foo.com/images/.</a><p>
This behavior is undesired. Suppose that there is an ImagesController, and there's also a 'public/images' folder used for storing page cache files. Then we don't want mod_dir to perform the redirection.<p>
So in <a class="el" href="classHooks.html#e3091c57c95b2f8269f566099802f0ec" title="mod_dir does the following: If r-&gt;filename is a directory, and the URI doesn&#39;t...">startBlockingModDir()</a>, we temporarily change some fields in the request structure in order to block mod_dir. In endBlockingModDir() we revert those fields to their old value. 
</div>
</div><p>
<hr>The documentation for this class was generated from the following file:<ul>
<li>Hooks.cpp</ul>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Mar 5 11:13:04 2010 for Passenger by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>