mongrel 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +4 -1
- data/Rakefile +1 -1
- data/bin/mongrel_rails +77 -24
- data/doc/rdoc/classes/Mongrel.html +0 -30
- data/doc/rdoc/classes/Mongrel/DirHandler.html +45 -26
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000022.html +20 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000023.html +29 -7
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000024.html +27 -29
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000025.html +18 -27
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000026.html +25 -18
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000027.html +5 -25
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000047.html +4 -4
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000048.html +4 -4
- data/doc/rdoc/classes/Mongrel/HttpParser.html +35 -35
- data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000022.html → M000015.html} +6 -6
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000016.html +6 -5
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000017.html +7 -7
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000018.html +20 -8
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000019.html +6 -20
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000020.html +5 -5
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000021.html +6 -5
- data/doc/rdoc/classes/Mongrel/HttpServer.html +1 -1
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000028.html +16 -9
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000029.html +49 -49
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000030.html +9 -9
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000031.html +4 -4
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000032.html +4 -4
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README.html +7 -2
- data/doc/rdoc/files/lib/mongrel_rb.html +1 -1
- data/doc/rdoc/fr_method_index.html +15 -15
- data/lib/mongrel.rb +17 -8
- metadata +4 -5
- data/doc/rdoc/classes/Mongrel.src/M000015.html +0 -18
data/README
CHANGED
@@ -11,7 +11,7 @@ scream without too many portability issues.
|
|
11
11
|
|
12
12
|
== Status
|
13
13
|
|
14
|
-
The 0.3.
|
14
|
+
The 0.3.2 release supports Ruby On Rails much better than previously, and also
|
15
15
|
sports the beginning of a command and plugin infrastructure. This last part
|
16
16
|
isn't documented yet.
|
17
17
|
|
@@ -37,6 +37,9 @@ And you can stop it whenever you like with:
|
|
37
37
|
All of which should be done from your application's directory. It writes the
|
38
38
|
PID of the process you ran into log/mongrel.pid.
|
39
39
|
|
40
|
+
There are also many more new options for configuring the rails runner including
|
41
|
+
changing to a different directory, adding more MIME types, and setting processor
|
42
|
+
threads and timeouts.
|
40
43
|
|
41
44
|
== Install
|
42
45
|
|
data/Rakefile
CHANGED
@@ -31,6 +31,6 @@ setup_extension("http11", "http11")
|
|
31
31
|
|
32
32
|
summary = "A small fast HTTP library and server that runs Rails, Camping, and Nitro apps."
|
33
33
|
test_file = "test/test_ws.rb"
|
34
|
-
setup_gem("mongrel", "0.3.
|
34
|
+
setup_gem("mongrel", "0.3.2", "Zed A. Shaw", summary, ['mongrel_rails'], test_file) do |spec|
|
35
35
|
spec.add_dependency('daemons', '>= 0.4.2')
|
36
36
|
end
|
data/bin/mongrel_rails
CHANGED
@@ -51,9 +51,13 @@ end
|
|
51
51
|
|
52
52
|
|
53
53
|
class RailsHandler < Mongrel::HttpHandler
|
54
|
-
|
54
|
+
|
55
|
+
def initialize(dir, mime_map = {})
|
55
56
|
@files = Mongrel::DirHandler.new(dir,false)
|
56
57
|
@guard = Mutex.new
|
58
|
+
|
59
|
+
# register the requested mime types
|
60
|
+
mime_map.each {|k,v| Mongrel::DirHandler::add_mime_type(k,v) }
|
57
61
|
end
|
58
62
|
|
59
63
|
def process(request, response)
|
@@ -88,50 +92,94 @@ class StartCommand < Mongrel::Command::Command
|
|
88
92
|
|
89
93
|
def configure
|
90
94
|
options [
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
95
|
+
["-e", "--environment ENV", "Rails environment to run as", :@environment, ENV['RAILS_ENV'] || "development"],
|
96
|
+
["-d", "--daemonize", "Whether to run in the background or not", :@daemon, false],
|
97
|
+
['-p', '--port PORT', "Which port to bind to", :@port, 3000],
|
98
|
+
['-a', '--address ADDR', "Address to bind to", :@address, "0.0.0.0"],
|
99
|
+
['-l', '--log FILE', "Where to write log messages", :@log_file, "log/mongrel.log"],
|
100
|
+
['-P', '--pid FILE', "Where to write the PID", :@pid_file, "log/mongrel.pid"],
|
101
|
+
['-n', '--num-procs INT', "Number of processor threads to use", :@num_procs, 20],
|
102
|
+
['-t', '--timeout SECONDS', "Timeout all requests after SECONDS time", :@timeout, 120],
|
103
|
+
['-m', '--mime PATH', "A YAML file that lists additional MIME types", :@mime_map, nil],
|
104
|
+
['-c', '--chdir PATH', "Change to dir before starting (will be expanded)", :@cwd, Dir.pwd],
|
105
|
+
['-r', '--root PATH', "Set the document root (default 'public')", :@docroot, "public"],
|
97
106
|
]
|
98
107
|
end
|
99
108
|
|
100
109
|
def validate
|
101
|
-
|
110
|
+
@cwd = File.expand_path(@cwd)
|
111
|
+
valid_dir? @cwd, "Invalid path to change to during daemon mode: #@cwd"
|
112
|
+
|
113
|
+
# change there to start, then we'll have to come back after daemonize
|
114
|
+
Dir.chdir(@cwd)
|
115
|
+
|
102
116
|
valid_dir? File.dirname(@log_file), "Path to log file not valid: #@log_file"
|
103
117
|
valid_dir? File.dirname(@pid_file), "Path to pid file not valid: #@pid_file"
|
104
|
-
|
118
|
+
valid_dir? @docroot, "Path to docroot not valid: #@docroot"
|
119
|
+
valid_exists? @mime_map, "MIME mapping file does not exist: #@mime_map" if @mime_map
|
120
|
+
|
105
121
|
return @valid
|
106
122
|
end
|
107
123
|
|
108
|
-
|
109
|
-
|
110
|
-
cwd = Dir.pwd
|
111
|
-
|
124
|
+
def daemonize
|
125
|
+
# save this for later since daemonize will hose it
|
112
126
|
if @daemon
|
113
|
-
puts "
|
127
|
+
puts "Started Mongrel server in #@environment mode at #@address:#@port"
|
114
128
|
Daemonize.daemonize(log_file=@log_file)
|
115
|
-
|
129
|
+
|
116
130
|
# change back to the original starting directory
|
117
|
-
Dir.chdir(cwd)
|
131
|
+
Dir.chdir(@cwd)
|
132
|
+
|
133
|
+
open(@pid_file,"w") {|f| f.write(Process.pid) }
|
118
134
|
else
|
119
|
-
puts "Running at #@address:#@port"
|
135
|
+
puts "Running Mongrel server in #@environment mode at #@address:#@port"
|
120
136
|
end
|
137
|
+
end
|
121
138
|
|
122
|
-
|
139
|
+
def load_mime_map
|
140
|
+
mime = {}
|
141
|
+
|
142
|
+
# configure any requested mime map
|
143
|
+
if @mime_map
|
144
|
+
puts "Loading additional MIME types from #@mime_map"
|
145
|
+
mime.merge!(YAML.load_file(@mime_map))
|
123
146
|
|
147
|
+
# check all the mime types to make sure they are the right format
|
148
|
+
mime.each {|k,v| puts "WARNING: MIME type #{k} must start with '.'" if k.index(".") != 0 }
|
149
|
+
end
|
150
|
+
|
151
|
+
return mime
|
152
|
+
end
|
153
|
+
|
154
|
+
def configure_rails
|
155
|
+
ENV['RAILS_ENV'] = @environment
|
124
156
|
require 'config/environment'
|
125
|
-
|
126
|
-
|
127
|
-
|
157
|
+
|
158
|
+
# configure the rails handler
|
159
|
+
rails = RailsHandler.new(@docroot, load_mime_map)
|
160
|
+
|
161
|
+
return rails
|
162
|
+
end
|
163
|
+
|
164
|
+
def start_mongrel(rails)
|
165
|
+
# start up mongrel with the right configurations
|
166
|
+
server = Mongrel::HttpServer.new(@address, @port, @num_procs.to_i, @timeout.to_i)
|
167
|
+
server.register("/", rails)
|
168
|
+
server.run
|
128
169
|
|
129
170
|
begin
|
130
|
-
|
171
|
+
puts "Server ready."
|
172
|
+
server.acceptor.join
|
131
173
|
rescue Interrupt
|
132
174
|
puts "Interrupted."
|
133
175
|
end
|
134
176
|
end
|
177
|
+
|
178
|
+
def run
|
179
|
+
daemonize
|
180
|
+
rails = configure_rails
|
181
|
+
start_mongrel(rails)
|
182
|
+
end
|
135
183
|
end
|
136
184
|
|
137
185
|
|
@@ -140,13 +188,18 @@ class StopCommand < Mongrel::Command::Command
|
|
140
188
|
|
141
189
|
def configure
|
142
190
|
options [
|
143
|
-
|
144
|
-
|
191
|
+
['-c', '--chdir PATH', "Change to dir before starting (will be expanded)", :@cwd, Dir.pwd],
|
192
|
+
['-P', '--pid FILE', "Where to write the PID", :@pid_file, "log/mongrel.pid"]
|
145
193
|
]
|
146
194
|
end
|
147
195
|
|
148
196
|
def validate
|
197
|
+
@cwd = File.expand_path(@cwd)
|
198
|
+
valid_dir? @cwd, "Invalid path to change to during daemon mode: #@cwd"
|
199
|
+
|
200
|
+
@pid_file = File.join(@cwd,@pid_file)
|
149
201
|
valid_exists? @pid_file, "PID file #@pid_file does not exist. Not running?"
|
202
|
+
|
150
203
|
return @valid
|
151
204
|
end
|
152
205
|
|
@@ -89,13 +89,6 @@ to service web application requests fast as possible.
|
|
89
89
|
|
90
90
|
</div>
|
91
91
|
|
92
|
-
<div id="method-list">
|
93
|
-
<h3 class="section-bar">Methods</h3>
|
94
|
-
|
95
|
-
<div class="name-list">
|
96
|
-
<a href="#M000015">add_mime_type</a>
|
97
|
-
</div>
|
98
|
-
</div>
|
99
92
|
|
100
93
|
</div>
|
101
94
|
|
@@ -148,29 +141,6 @@ href="Mongrel/Const.html">Mongrel::Const</a>.
|
|
148
141
|
|
149
142
|
|
150
143
|
<!-- if method_list -->
|
151
|
-
<div id="methods">
|
152
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
153
|
-
|
154
|
-
<div id="method-M000015" class="method-detail">
|
155
|
-
<a name="M000015"></a>
|
156
|
-
|
157
|
-
<div class="method-heading">
|
158
|
-
<a href="Mongrel.src/M000015.html" target="Code" class="method-signature"
|
159
|
-
onclick="popupCode('Mongrel.src/M000015.html');return false;">
|
160
|
-
<span class="method-name">add_mime_type</span><span class="method-args">(extension, type)</span>
|
161
|
-
</a>
|
162
|
-
</div>
|
163
|
-
|
164
|
-
<div class="method-description">
|
165
|
-
<p>
|
166
|
-
There is a small number of default mime types for extensions, but this lets
|
167
|
-
you add any others you’ll need when serving content.
|
168
|
-
</p>
|
169
|
-
</div>
|
170
|
-
</div>
|
171
|
-
|
172
|
-
|
173
|
-
</div>
|
174
144
|
|
175
145
|
|
176
146
|
</div>
|
@@ -103,11 +103,12 @@ than it simply gives a 404.
|
|
103
103
|
<h3 class="section-bar">Methods</h3>
|
104
104
|
|
105
105
|
<div class="name-list">
|
106
|
-
<a href="#
|
107
|
-
<a href="#M000023">
|
108
|
-
<a href="#
|
109
|
-
<a href="#
|
110
|
-
<a href="#
|
106
|
+
<a href="#M000027">add_mime_type</a>
|
107
|
+
<a href="#M000023">can_serve</a>
|
108
|
+
<a href="#M000022">new</a>
|
109
|
+
<a href="#M000026">process</a>
|
110
|
+
<a href="#M000024">send_dir_listing</a>
|
111
|
+
<a href="#M000025">send_file</a>
|
111
112
|
</div>
|
112
113
|
</div>
|
113
114
|
|
@@ -155,12 +156,30 @@ than it simply gives a 404.
|
|
155
156
|
<div id="methods">
|
156
157
|
<h3 class="section-bar">Public Class methods</h3>
|
157
158
|
|
158
|
-
<div id="method-
|
159
|
-
<a name="
|
159
|
+
<div id="method-M000027" class="method-detail">
|
160
|
+
<a name="M000027"></a>
|
160
161
|
|
161
162
|
<div class="method-heading">
|
162
|
-
<a href="DirHandler.src/
|
163
|
-
onclick="popupCode('DirHandler.src/
|
163
|
+
<a href="DirHandler.src/M000027.html" target="Code" class="method-signature"
|
164
|
+
onclick="popupCode('DirHandler.src/M000027.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’ll need when serving content.
|
173
|
+
</p>
|
174
|
+
</div>
|
175
|
+
</div>
|
176
|
+
|
177
|
+
<div id="method-M000022" class="method-detail">
|
178
|
+
<a name="M000022"></a>
|
179
|
+
|
180
|
+
<div class="method-heading">
|
181
|
+
<a href="DirHandler.src/M000022.html" target="Code" class="method-signature"
|
182
|
+
onclick="popupCode('DirHandler.src/M000022.html');return false;">
|
164
183
|
<span class="method-name">new</span><span class="method-args">(path, listing_allowed=true, index_html="index.html")</span>
|
165
184
|
</a>
|
166
185
|
</div>
|
@@ -174,12 +193,12 @@ You give it the path to the directory root and an (optional)
|
|
174
193
|
|
175
194
|
<h3 class="section-bar">Public Instance methods</h3>
|
176
195
|
|
177
|
-
<div id="method-
|
178
|
-
<a name="
|
196
|
+
<div id="method-M000023" class="method-detail">
|
197
|
+
<a name="M000023"></a>
|
179
198
|
|
180
199
|
<div class="method-heading">
|
181
|
-
<a href="DirHandler.src/
|
182
|
-
onclick="popupCode('DirHandler.src/
|
200
|
+
<a href="DirHandler.src/M000023.html" target="Code" class="method-signature"
|
201
|
+
onclick="popupCode('DirHandler.src/M000023.html');return false;">
|
183
202
|
<span class="method-name">can_serve</span><span class="method-args">(path_info)</span>
|
184
203
|
</a>
|
185
204
|
</div>
|
@@ -192,12 +211,12 @@ not).
|
|
192
211
|
</div>
|
193
212
|
</div>
|
194
213
|
|
195
|
-
<div id="method-
|
196
|
-
<a name="
|
214
|
+
<div id="method-M000026" class="method-detail">
|
215
|
+
<a name="M000026"></a>
|
197
216
|
|
198
217
|
<div class="method-heading">
|
199
|
-
<a href="DirHandler.src/
|
200
|
-
onclick="popupCode('DirHandler.src/
|
218
|
+
<a href="DirHandler.src/M000026.html" target="Code" class="method-signature"
|
219
|
+
onclick="popupCode('DirHandler.src/M000026.html');return false;">
|
201
220
|
<span class="method-name">process</span><span class="method-args">(request, response)</span>
|
202
221
|
</a>
|
203
222
|
</div>
|
@@ -210,12 +229,12 @@ allowed (based on the listing_allowed paramter to the constructor).
|
|
210
229
|
</div>
|
211
230
|
</div>
|
212
231
|
|
213
|
-
<div id="method-
|
214
|
-
<a name="
|
232
|
+
<div id="method-M000024" class="method-detail">
|
233
|
+
<a name="M000024"></a>
|
215
234
|
|
216
235
|
<div class="method-heading">
|
217
|
-
<a href="DirHandler.src/
|
218
|
-
onclick="popupCode('DirHandler.src/
|
236
|
+
<a href="DirHandler.src/M000024.html" target="Code" class="method-signature"
|
237
|
+
onclick="popupCode('DirHandler.src/M000024.html');return false;">
|
219
238
|
<span class="method-name">send_dir_listing</span><span class="method-args">(base, dir, response)</span>
|
220
239
|
</a>
|
221
240
|
</div>
|
@@ -225,18 +244,18 @@ allowed (based on the listing_allowed paramter to the constructor).
|
|
225
244
|
Returns a simplistic directory listing if they’re enabled, otherwise
|
226
245
|
a 403. Base is the base URI from the REQUEST_URI, dir is the directory to
|
227
246
|
serve on the file system (comes from <a
|
228
|
-
href="DirHandler.html#
|
247
|
+
href="DirHandler.html#M000023">can_serve</a>()), and response is the <a
|
229
248
|
href="HttpResponse.html">HttpResponse</a> object to send the results on.
|
230
249
|
</p>
|
231
250
|
</div>
|
232
251
|
</div>
|
233
252
|
|
234
|
-
<div id="method-
|
235
|
-
<a name="
|
253
|
+
<div id="method-M000025" class="method-detail">
|
254
|
+
<a name="M000025"></a>
|
236
255
|
|
237
256
|
<div class="method-heading">
|
238
|
-
<a href="DirHandler.src/
|
239
|
-
onclick="popupCode('DirHandler.src/
|
257
|
+
<a href="DirHandler.src/M000025.html" target="Code" class="method-signature"
|
258
|
+
onclick="popupCode('DirHandler.src/M000025.html');return false;">
|
240
259
|
<span class="method-name">send_file</span><span class="method-args">(req, response)</span>
|
241
260
|
</a>
|
242
261
|
</div>
|
@@ -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.rb, line 470</span>
|
14
|
+
470: <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">"index.html"</span>)
|
15
|
+
471: <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
|
+
472: <span class="ruby-ivar">@listing_allowed</span>=<span class="ruby-identifier">listing_allowed</span>
|
17
|
+
473: <span class="ruby-ivar">@index_html</span> = <span class="ruby-identifier">index_html</span>
|
18
|
+
474: <span class="ruby-keyword kw">end</span></pre>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -5,16 +5,38 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>can_serve (Mongrel::DirHandler)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 477</span>
|
14
|
+
477: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">can_serve</span>(<span class="ruby-identifier">path_info</span>)
|
15
|
+
478: <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
|
+
479:
|
17
|
+
480: <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
|
+
481: <span class="ruby-comment cmt"># it exists and it's in the right location</span>
|
19
|
+
482: <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
|
+
483: <span class="ruby-comment cmt"># the request is for a directory</span>
|
21
|
+
484: <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
|
+
485: <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
|
+
486: <span class="ruby-comment cmt"># serve the index</span>
|
24
|
+
487: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">index</span>
|
25
|
+
488: <span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@listing_allows</span>
|
26
|
+
489: <span class="ruby-comment cmt"># serve the directory</span>
|
27
|
+
490: <span class="ruby-identifier">req</span>
|
28
|
+
491: <span class="ruby-keyword kw">else</span>
|
29
|
+
492: <span class="ruby-comment cmt"># do not serve anything</span>
|
30
|
+
493: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
|
31
|
+
494: <span class="ruby-keyword kw">end</span>
|
32
|
+
495: <span class="ruby-keyword kw">else</span>
|
33
|
+
496: <span class="ruby-comment cmt"># it's a file and it's there</span>
|
34
|
+
497: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">req</span>
|
35
|
+
498: <span class="ruby-keyword kw">end</span>
|
36
|
+
499: <span class="ruby-keyword kw">else</span>
|
37
|
+
500: <span class="ruby-comment cmt"># does not exist or isn't in the right spot</span>
|
38
|
+
501: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
|
39
|
+
502: <span class="ruby-keyword kw">end</span>
|
40
|
+
503: <span class="ruby-keyword kw">end</span></pre>
|
19
41
|
</body>
|
20
42
|
</html>
|
@@ -5,38 +5,36 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>send_dir_listing (Mongrel::DirHandler)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line
|
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
|
-
495: <span class="ruby-keyword kw">end</span>
|
40
|
-
496: <span class="ruby-keyword kw">end</span></pre>
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 510</span>
|
14
|
+
510: <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
|
+
511: <span class="ruby-comment cmt"># take off any trailing / so the links come out right</span>
|
16
|
+
512: <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">"/"</span>[<span class="ruby-value">-1</span>]
|
17
|
+
513:
|
18
|
+
514: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@listing_allowed</span>
|
19
|
+
515: <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
|
+
516: <span class="ruby-identifier">head</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-value str">"text/html"</span>
|
21
|
+
517: <span class="ruby-identifier">out</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"<html><head><title>Directory Listing</title></head><body>"</span>
|
22
|
+
518: <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
|
+
519: <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">"."</span>
|
24
|
+
520:
|
25
|
+
521: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">child</span> <span class="ruby-operator">==</span> <span class="ruby-value str">".."</span>
|
26
|
+
522: <span class="ruby-identifier">out</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"<a href=\"#{base}/#{child}\">Up to parent..</a><br/>"</span>
|
27
|
+
523: <span class="ruby-keyword kw">else</span>
|
28
|
+
524: <span class="ruby-identifier">out</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"<a href=\"#{base}/#{child}\">#{child}</a><br/>"</span>
|
29
|
+
525: <span class="ruby-keyword kw">end</span>
|
30
|
+
526: <span class="ruby-keyword kw">end</span>
|
31
|
+
527: <span class="ruby-identifier">out</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"</body></html>"</span>
|
32
|
+
528: <span class="ruby-keyword kw">end</span>
|
33
|
+
529: <span class="ruby-keyword kw">else</span>
|
34
|
+
530: <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
|
+
531: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">"Directory listings not allowed"</span>)
|
36
|
+
532: <span class="ruby-keyword kw">end</span>
|
37
|
+
533: <span class="ruby-keyword kw">end</span>
|
38
|
+
534: <span class="ruby-keyword kw">end</span></pre>
|
41
39
|
</body>
|
42
40
|
</html>
|