mongrel 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/README +30 -24
  2. data/Rakefile +12 -2
  3. data/bin/mongrel_rails +12 -8
  4. data/doc/rdoc/classes/Mongrel.html +18 -1
  5. data/doc/rdoc/classes/Mongrel/CGIWrapper.html +381 -0
  6. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000051.html +24 -0
  7. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000052.html +47 -0
  8. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000053.html +34 -0
  9. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000054.html +27 -0
  10. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000055.html +25 -0
  11. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000056.html +18 -0
  12. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000057.html +18 -0
  13. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000058.html +18 -0
  14. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000059.html +19 -0
  15. data/doc/rdoc/classes/Mongrel/Command.html +119 -0
  16. data/doc/rdoc/classes/Mongrel/Command/Base.html +332 -0
  17. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000003.html +24 -0
  18. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000004.html +41 -0
  19. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000005.html +18 -0
  20. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000006.html +18 -0
  21. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000007.html +18 -0
  22. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000008.html +22 -0
  23. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000009.html +18 -0
  24. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000010.html +18 -0
  25. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000011.html +18 -0
  26. data/doc/rdoc/classes/Mongrel/Command/Base.src/M000012.html +18 -0
  27. data/doc/rdoc/classes/Mongrel/Command/Registry.html +192 -0
  28. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000013.html +20 -0
  29. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000014.html +25 -0
  30. data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000015.html +46 -0
  31. data/doc/rdoc/classes/Mongrel/Const.html +2 -2
  32. data/doc/rdoc/classes/Mongrel/DirHandler.html +283 -0
  33. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000023.html +20 -0
  34. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000024.html +42 -0
  35. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000025.html +40 -0
  36. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000026.html +31 -0
  37. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000027.html +38 -0
  38. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000028.html +18 -0
  39. data/doc/rdoc/classes/Mongrel/Error404Handler.html +171 -0
  40. data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000060.html +18 -0
  41. data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000061.html +18 -0
  42. data/doc/rdoc/classes/Mongrel/HeaderOut.html +10 -10
  43. data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000014.html → M000035.html} +0 -0
  44. data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000015.html → M000036.html} +0 -0
  45. data/doc/rdoc/classes/Mongrel/HttpHandler.html +146 -0
  46. data/doc/rdoc/classes/Mongrel/HttpHandler.src/M000037.html +17 -0
  47. data/doc/rdoc/classes/Mongrel/HttpParser.html +35 -35
  48. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000001.html → M000016.html} +0 -0
  49. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000002.html → M000017.html} +0 -0
  50. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000003.html → M000018.html} +0 -0
  51. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000004.html → M000019.html} +0 -0
  52. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000005.html → M000020.html} +0 -0
  53. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000006.html → M000021.html} +0 -0
  54. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000007.html → M000022.html} +0 -0
  55. data/doc/rdoc/classes/Mongrel/HttpRequest.html +5 -5
  56. data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000029.html → M000062.html} +0 -0
  57. data/doc/rdoc/classes/Mongrel/HttpResponse.html +36 -36
  58. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000016.html → M000038.html} +0 -0
  59. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000017.html → M000039.html} +0 -0
  60. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000018.html → M000040.html} +0 -0
  61. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000019.html → M000041.html} +0 -0
  62. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000020.html → M000042.html} +0 -0
  63. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000021.html → M000043.html} +0 -0
  64. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000022.html → M000044.html} +0 -0
  65. data/doc/rdoc/classes/Mongrel/HttpServer.html +33 -33
  66. data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000008.html → M000029.html} +0 -0
  67. data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000009.html → M000030.html} +0 -0
  68. data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000010.html → M000031.html} +0 -0
  69. data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000011.html → M000032.html} +0 -0
  70. data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000012.html → M000033.html} +0 -0
  71. data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000013.html → M000034.html} +0 -0
  72. data/doc/rdoc/classes/Mongrel/URIClassifier.html +33 -32
  73. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000023.html → M000045.html} +0 -0
  74. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000024.html → M000046.html} +0 -0
  75. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000025.html → M000047.html} +0 -0
  76. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000026.html → M000048.html} +0 -0
  77. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000027.html → M000049.html} +0 -0
  78. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000028.html → M000050.html} +0 -0
  79. data/doc/rdoc/classes/RailsHandler.html +225 -0
  80. data/doc/rdoc/classes/RailsHandler.src/M000001.html +22 -0
  81. data/doc/rdoc/classes/RailsHandler.src/M000002.html +48 -0
  82. data/doc/rdoc/created.rid +1 -1
  83. data/doc/rdoc/files/README.html +45 -50
  84. data/doc/rdoc/files/lib/mongrel/cgi_rb.html +108 -0
  85. data/doc/rdoc/files/lib/mongrel/command_rb.html +110 -0
  86. data/doc/rdoc/files/lib/mongrel/handlers_rb.html +101 -0
  87. data/doc/rdoc/files/lib/mongrel/plugins_rb.html +108 -0
  88. data/doc/rdoc/files/lib/mongrel/rails_rb.html +108 -0
  89. data/doc/rdoc/fr_class_index.html +8 -0
  90. data/doc/rdoc/fr_file_index.html +5 -0
  91. data/doc/rdoc/fr_method_index.html +62 -29
  92. data/lib/mongrel/command.rb +5 -5
  93. data/lib/mongrel/plugins.rb +3 -152
  94. data/lib/mongrel/rails.rb +1 -1
  95. metadata +95 -35
  96. data/test/plugins/commands/test1.rb +0 -19
  97. data/test/test_plugins.rb +0 -45
@@ -0,0 +1,46 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>run (Mongrel::Command::Registry)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel/command.rb, line 136</span>
14
+ 136: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>(<span class="ruby-identifier">args</span>)
15
+ 137: <span class="ruby-comment cmt"># find the command</span>
16
+ 138: <span class="ruby-identifier">cmd_name</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">shift</span>
17
+ 139:
18
+ 140: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">cmd_name</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">cmd_name</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;?&quot;</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">cmd_name</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;help&quot;</span>
19
+ 141: <span class="ruby-identifier">print_command_list</span>
20
+ 142: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
21
+ 143: <span class="ruby-keyword kw">end</span>
22
+ 144:
23
+ 145: <span class="ruby-comment cmt"># command exists, set it up and validate it</span>
24
+ 146: <span class="ruby-keyword kw">begin</span>
25
+ 147: <span class="ruby-identifier">command</span> = <span class="ruby-constant">GemPlugin</span><span class="ruby-operator">::</span><span class="ruby-constant">Manager</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">create</span>(<span class="ruby-node">&quot;/commands/#{cmd_name}&quot;</span>, <span class="ruby-identifier">:argv</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">args</span>)
26
+ 148: <span class="ruby-keyword kw">rescue</span>
27
+ 149: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;INVALID COMMAND: #$!&quot;</span>
28
+ 150: <span class="ruby-identifier">print_command_list</span>
29
+ 151: <span class="ruby-keyword kw">return</span>
30
+ 152: <span class="ruby-keyword kw">end</span>
31
+ 153:
32
+ 154: <span class="ruby-comment cmt"># Normally the command is NOT valid right after being created</span>
33
+ 155: <span class="ruby-comment cmt"># but sometimes (like with -h or -v) there's no further processing</span>
34
+ 156: <span class="ruby-comment cmt"># needed so the command is already valid so we can skip it.</span>
35
+ 157: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">done_validating</span>
36
+ 158: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">command</span>.<span class="ruby-identifier">validate</span>
37
+ 159: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{cmd_name} reported an error. Use -h to get help.&quot;</span>
38
+ 160: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
39
+ 161: <span class="ruby-keyword kw">else</span>
40
+ 162: <span class="ruby-identifier">command</span>.<span class="ruby-identifier">run</span>
41
+ 163: <span class="ruby-keyword kw">end</span>
42
+ 164: <span class="ruby-keyword kw">end</span>
43
+ 165: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
44
+ 166: <span class="ruby-keyword kw">end</span></pre>
45
+ </body>
46
+ </html>
@@ -230,7 +230,7 @@ DNS resolves. It is only here for completeness for the CGI standard.
230
230
  <td width="3em">&nbsp;</td>
231
231
  <td class="context-item-desc">
232
232
  The name/host of our server as given by the <a
233
- href="HttpServer.html#M000008">HttpServer.new</a>(host,port) call.
233
+ href="HttpServer.html#M000029">HttpServer.new</a>(host,port) call.
234
234
 
235
235
  </td>
236
236
  </tr>
@@ -241,7 +241,7 @@ href="HttpServer.html#M000008">HttpServer.new</a>(host,port) call.
241
241
  <td width="3em">&nbsp;</td>
242
242
  <td class="context-item-desc">
243
243
  The port of our server as given by the <a
244
- href="HttpServer.html#M000008">HttpServer.new</a>(host,port) call.
244
+ href="HttpServer.html#M000029">HttpServer.new</a>(host,port) call.
245
245
 
246
246
  </td>
247
247
  </tr>
@@ -0,0 +1,283 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Mongrel::DirHandler</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Mongrel::DirHandler</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/mongrel/handlers_rb.html">
59
+ lib/mongrel/handlers.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ <a href="HttpHandler.html">
69
+ HttpHandler
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </div>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+
79
+
80
+
81
+ <div id="contextContent">
82
+
83
+ <div id="description">
84
+ <p>
85
+ Serves the contents of a directory. You give it the path to the root where
86
+ the files are located, and it tries to find the files based on the
87
+ PATH_INFO inside the directory. If the requested path is a directory then
88
+ it returns a simple directory listing.
89
+ </p>
90
+ <p>
91
+ It does a simple protection against going outside it&#8217;s root path by
92
+ converting all paths to an absolute expanded path, and then making sure
93
+ that the final expanded path includes the root path. If it doesn&#8217;t
94
+ than it simply gives a 404.
95
+ </p>
96
+
97
+ </div>
98
+
99
+
100
+ </div>
101
+
102
+ <div id="method-list">
103
+ <h3 class="section-bar">Methods</h3>
104
+
105
+ <div class="name-list">
106
+ <a href="#M000028">add_mime_type</a>&nbsp;&nbsp;
107
+ <a href="#M000024">can_serve</a>&nbsp;&nbsp;
108
+ <a href="#M000023">new</a>&nbsp;&nbsp;
109
+ <a href="#M000027">process</a>&nbsp;&nbsp;
110
+ <a href="#M000025">send_dir_listing</a>&nbsp;&nbsp;
111
+ <a href="#M000026">send_file</a>&nbsp;&nbsp;
112
+ </div>
113
+ </div>
114
+
115
+ </div>
116
+
117
+
118
+ <!-- if includes -->
119
+
120
+ <div id="section">
121
+
122
+
123
+ <div id="constants-list">
124
+ <h3 class="section-bar">Constants</h3>
125
+
126
+ <div class="name-list">
127
+ <table summary="Constants">
128
+ <tr class="top-aligned-row context-row">
129
+ <td class="context-item-name">MIME_TYPES</td>
130
+ <td>=</td>
131
+ <td class="context-item-value">{ &quot;.css&quot; =&gt; &quot;text/css&quot;, &quot;.gif&quot; =&gt; &quot;image/gif&quot;, &quot;.htm&quot; =&gt; &quot;text/html&quot;, &quot;.html&quot; =&gt; &quot;text/html&quot;, &quot;.jpeg&quot; =&gt; &quot;image/jpeg&quot;, &quot;.jpg&quot; =&gt; &quot;image/jpeg&quot;, &quot;.js&quot; =&gt; &quot;text/javascript&quot;, &quot;.png&quot; =&gt; &quot;image/png&quot;, &quot;.swf&quot; =&gt; &quot;application/x-shockwave-flash&quot;, &quot;.txt&quot; =&gt; &quot;text/plain&quot;</td>
132
+ </tr>
133
+ </table>
134
+ </div>
135
+ </div>
136
+
137
+
138
+
139
+ <div id="attribute-list">
140
+ <h3 class="section-bar">Attributes</h3>
141
+
142
+ <div class="name-list">
143
+ <table>
144
+ <tr class="top-aligned-row context-row">
145
+ <td class="context-item-name">path</td>
146
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
147
+ <td class="context-item-desc"></td>
148
+ </tr>
149
+ </table>
150
+ </div>
151
+ </div>
152
+
153
+
154
+
155
+ <!-- if method_list -->
156
+ <div id="methods">
157
+ <h3 class="section-bar">Public Class methods</h3>
158
+
159
+ <div id="method-M000028" class="method-detail">
160
+ <a name="M000028"></a>
161
+
162
+ <div class="method-heading">
163
+ <a href="DirHandler.src/M000028.html" target="Code" class="method-signature"
164
+ onclick="popupCode('DirHandler.src/M000028.html');return false;">
165
+ <span class="method-name">add_mime_type</span><span class="method-args">(extension, type)</span>
166
+ </a>
167
+ </div>
168
+
169
+ <div class="method-description">
170
+ <p>
171
+ There is a small number of default mime types for extensions, but this lets
172
+ you add any others you&#8217;ll need when serving content.
173
+ </p>
174
+ </div>
175
+ </div>
176
+
177
+ <div id="method-M000023" class="method-detail">
178
+ <a name="M000023"></a>
179
+
180
+ <div class="method-heading">
181
+ <a href="DirHandler.src/M000023.html" target="Code" class="method-signature"
182
+ onclick="popupCode('DirHandler.src/M000023.html');return false;">
183
+ <span class="method-name">new</span><span class="method-args">(path, listing_allowed=true, index_html=&quot;index.html&quot;)</span>
184
+ </a>
185
+ </div>
186
+
187
+ <div class="method-description">
188
+ <p>
189
+ You give it the path to the directory root and an (optional)
190
+ </p>
191
+ </div>
192
+ </div>
193
+
194
+ <h3 class="section-bar">Public Instance methods</h3>
195
+
196
+ <div id="method-M000024" class="method-detail">
197
+ <a name="M000024"></a>
198
+
199
+ <div class="method-heading">
200
+ <a href="DirHandler.src/M000024.html" target="Code" class="method-signature"
201
+ onclick="popupCode('DirHandler.src/M000024.html');return false;">
202
+ <span class="method-name">can_serve</span><span class="method-args">(path_info)</span>
203
+ </a>
204
+ </div>
205
+
206
+ <div class="method-description">
207
+ <p>
208
+ Checks if the given path can be served and returns the full path (or nil if
209
+ not).
210
+ </p>
211
+ </div>
212
+ </div>
213
+
214
+ <div id="method-M000027" class="method-detail">
215
+ <a name="M000027"></a>
216
+
217
+ <div class="method-heading">
218
+ <a href="DirHandler.src/M000027.html" target="Code" class="method-signature"
219
+ onclick="popupCode('DirHandler.src/M000027.html');return false;">
220
+ <span class="method-name">process</span><span class="method-args">(request, response)</span>
221
+ </a>
222
+ </div>
223
+
224
+ <div class="method-description">
225
+ <p>
226
+ Process the request to either serve a file or a directory listing if
227
+ allowed (based on the listing_allowed paramter to the constructor).
228
+ </p>
229
+ </div>
230
+ </div>
231
+
232
+ <div id="method-M000025" class="method-detail">
233
+ <a name="M000025"></a>
234
+
235
+ <div class="method-heading">
236
+ <a href="DirHandler.src/M000025.html" target="Code" class="method-signature"
237
+ onclick="popupCode('DirHandler.src/M000025.html');return false;">
238
+ <span class="method-name">send_dir_listing</span><span class="method-args">(base, dir, response)</span>
239
+ </a>
240
+ </div>
241
+
242
+ <div class="method-description">
243
+ <p>
244
+ Returns a simplistic directory listing if they&#8217;re enabled, otherwise
245
+ a 403. Base is the base URI from the REQUEST_URI, dir is the directory to
246
+ serve on the file system (comes from <a
247
+ href="DirHandler.html#M000024">can_serve</a>()), and response is the <a
248
+ href="HttpResponse.html">HttpResponse</a> object to send the results on.
249
+ </p>
250
+ </div>
251
+ </div>
252
+
253
+ <div id="method-M000026" class="method-detail">
254
+ <a name="M000026"></a>
255
+
256
+ <div class="method-heading">
257
+ <a href="DirHandler.src/M000026.html" target="Code" class="method-signature"
258
+ onclick="popupCode('DirHandler.src/M000026.html');return false;">
259
+ <span class="method-name">send_file</span><span class="method-args">(req, response)</span>
260
+ </a>
261
+ </div>
262
+
263
+ <div class="method-description">
264
+ <p>
265
+ Sends the contents of a file back to the user. Not terribly efficient since
266
+ it&#8217;s opening and closing the file for each read.
267
+ </p>
268
+ </div>
269
+ </div>
270
+
271
+
272
+ </div>
273
+
274
+
275
+ </div>
276
+
277
+
278
+ <div id="validator-badges">
279
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
280
+ </div>
281
+
282
+ </body>
283
+ </html>
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>new (Mongrel::DirHandler)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel/handlers.rb, line 60</span>
14
+ 60: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">listing_allowed</span>=<span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">index_html</span>=<span class="ruby-value str">&quot;index.html&quot;</span>)
15
+ 61: <span class="ruby-ivar">@path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">path</span>)
16
+ 62: <span class="ruby-ivar">@listing_allowed</span>=<span class="ruby-identifier">listing_allowed</span>
17
+ 63: <span class="ruby-ivar">@index_html</span> = <span class="ruby-identifier">index_html</span>
18
+ 64: <span class="ruby-keyword kw">end</span></pre>
19
+ </body>
20
+ </html>
@@ -0,0 +1,42 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>can_serve (Mongrel::DirHandler)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel/handlers.rb, line 67</span>
14
+ 67: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">can_serve</span>(<span class="ruby-identifier">path_info</span>)
15
+ 68: <span class="ruby-identifier">req</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@path</span>,<span class="ruby-identifier">path_info</span>), <span class="ruby-ivar">@path</span>)
16
+ 69:
17
+ 70: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">req</span>.<span class="ruby-identifier">index</span>(<span class="ruby-ivar">@path</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">and</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">req</span>
18
+ 71: <span class="ruby-comment cmt"># it exists and it's in the right location</span>
19
+ 72: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-identifier">req</span>
20
+ 73: <span class="ruby-comment cmt"># the request is for a directory</span>
21
+ 74: <span class="ruby-identifier">index</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">req</span>, <span class="ruby-ivar">@index_html</span>)
22
+ 75: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">index</span>
23
+ 76: <span class="ruby-comment cmt"># serve the index</span>
24
+ 77: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">index</span>
25
+ 78: <span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@listing_allowed</span>
26
+ 79: <span class="ruby-comment cmt"># serve the directory</span>
27
+ 80: <span class="ruby-identifier">req</span>
28
+ 81: <span class="ruby-keyword kw">else</span>
29
+ 82: <span class="ruby-comment cmt"># do not serve anything</span>
30
+ 83: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
31
+ 84: <span class="ruby-keyword kw">end</span>
32
+ 85: <span class="ruby-keyword kw">else</span>
33
+ 86: <span class="ruby-comment cmt"># it's a file and it's there</span>
34
+ 87: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">req</span>
35
+ 88: <span class="ruby-keyword kw">end</span>
36
+ 89: <span class="ruby-keyword kw">else</span>
37
+ 90: <span class="ruby-comment cmt"># does not exist or isn't in the right spot</span>
38
+ 91: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
39
+ 92: <span class="ruby-keyword kw">end</span>
40
+ 93: <span class="ruby-keyword kw">end</span></pre>
41
+ </body>
42
+ </html>
@@ -0,0 +1,40 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>send_dir_listing (Mongrel::DirHandler)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel/handlers.rb, line 100</span>
14
+ 100: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_dir_listing</span>(<span class="ruby-identifier">base</span>, <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">response</span>)
15
+ 101: <span class="ruby-comment cmt"># take off any trailing / so the links come out right</span>
16
+ 102: <span class="ruby-identifier">base</span>.<span class="ruby-identifier">chop!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">base</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>[<span class="ruby-value">-1</span>]
17
+ 103:
18
+ 104: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@listing_allowed</span>
19
+ 105: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">200</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
20
+ 106: <span class="ruby-identifier">head</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-value str">&quot;text/html&quot;</span>
21
+ 107: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Directory Listing&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&quot;</span>
22
+ 108: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">entries</span>(<span class="ruby-identifier">dir</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
23
+ 109: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">child</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;.&quot;</span>
24
+ 110:
25
+ 111: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">child</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;..&quot;</span>
26
+ 112: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;a href=\&quot;#{base}/#{child}\&quot;&gt;Up to parent..&lt;/a&gt;&lt;br/&gt;&quot;</span>
27
+ 113: <span class="ruby-keyword kw">else</span>
28
+ 114: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;a href=\&quot;#{base}/#{child}\&quot;&gt;#{child}&lt;/a&gt;&lt;br/&gt;&quot;</span>
29
+ 115: <span class="ruby-keyword kw">end</span>
30
+ 116: <span class="ruby-keyword kw">end</span>
31
+ 117: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/body&gt;&lt;/html&gt;&quot;</span>
32
+ 118: <span class="ruby-keyword kw">end</span>
33
+ 119: <span class="ruby-keyword kw">else</span>
34
+ 120: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">403</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
35
+ 121: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">&quot;Directory listings not allowed&quot;</span>)
36
+ 122: <span class="ruby-keyword kw">end</span>
37
+ 123: <span class="ruby-keyword kw">end</span>
38
+ 124: <span class="ruby-keyword kw">end</span></pre>
39
+ </body>
40
+ </html>