thin 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of thin might be problematic. Click here for more details.
- data/README +47 -5
- data/Rakefile +33 -2
- data/doc/rdoc/classes/Kernel.html +182 -0
- data/doc/rdoc/classes/Process.html +175 -0
- data/doc/rdoc/classes/Thin.html +184 -0
- data/doc/rdoc/classes/Thin/CGIWrapper.html +438 -0
- data/doc/rdoc/classes/Thin/Cluster.html +392 -0
- data/doc/rdoc/classes/Thin/Command.html +221 -0
- data/doc/rdoc/classes/Thin/CommandError.html +154 -0
- data/doc/rdoc/classes/Thin/Commands.html +145 -0
- data/doc/rdoc/classes/Thin/Daemonizable.html +250 -0
- data/doc/rdoc/classes/Thin/Daemonizable/ClassMethods.html +203 -0
- data/doc/rdoc/classes/Thin/DirHandler.html +250 -0
- data/doc/rdoc/classes/Thin/Handler.html +195 -0
- data/doc/rdoc/classes/Thin/Headers.html +244 -0
- data/doc/rdoc/classes/Thin/InvalidRequest.html +150 -0
- data/doc/rdoc/classes/Thin/Logging.html +214 -0
- data/doc/rdoc/classes/Thin/RailsHandler.html +234 -0
- data/doc/rdoc/classes/Thin/RailsServer.html +175 -0
- data/doc/rdoc/classes/Thin/Request.html +379 -0
- data/doc/rdoc/classes/Thin/Response.html +311 -0
- data/doc/rdoc/classes/Thin/Server.html +381 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/README.html +260 -0
- data/doc/rdoc/files/bin/thin.html +188 -0
- data/doc/rdoc/files/bin/thin_cluster.html +175 -0
- data/doc/rdoc/files/lib/thin/cgi_rb.html +263 -0
- data/doc/rdoc/files/lib/thin/cluster_rb.html +263 -0
- data/doc/rdoc/files/lib/thin/command_rb.html +263 -0
- data/doc/rdoc/files/lib/thin/consts_rb.html +263 -0
- data/doc/rdoc/files/lib/thin/daemonizing_rb.html +263 -0
- data/doc/rdoc/files/lib/thin/handler_rb.html +263 -0
- data/doc/rdoc/files/lib/thin/headers_rb.html +263 -0
- data/doc/rdoc/files/lib/thin/logging_rb.html +263 -0
- data/doc/rdoc/files/lib/thin/mime_types_rb.html +263 -0
- data/doc/rdoc/files/lib/thin/rails_rb.html +263 -0
- data/doc/rdoc/files/lib/thin/recipes_rb.html +171 -0
- data/doc/rdoc/files/lib/thin/request_rb.html +171 -0
- data/doc/rdoc/files/lib/thin/response_rb.html +171 -0
- data/doc/rdoc/files/lib/thin/server_rb.html +171 -0
- data/doc/rdoc/files/lib/thin/statuses_rb.html +171 -0
- data/doc/rdoc/files/lib/thin/version_rb.html +171 -0
- data/doc/rdoc/index.html +10 -0
- data/doc/rdoc/logo.gif +0 -0
- data/doc/rdoc/rdoc-style.css +86 -0
- data/lib/thin/commands/cluster/config.rb +2 -0
- data/lib/thin/consts.rb +4 -0
- data/lib/thin/request.rb +30 -11
- data/lib/thin/server.rb +1 -1
- data/lib/thin/version.rb +1 -1
- metadata +52 -1
@@ -0,0 +1,203 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>
|
6
|
+
thin » Module: Thin::Daemonizable::ClassMethods
|
7
|
+
</title>
|
8
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
+
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
10
|
+
<script language="JavaScript" type="text/javascript">
|
11
|
+
// <![CDATA[
|
12
|
+
|
13
|
+
function toggleSource( id )
|
14
|
+
{
|
15
|
+
var elem
|
16
|
+
var link
|
17
|
+
|
18
|
+
if( document.getElementById )
|
19
|
+
{
|
20
|
+
elem = document.getElementById( id )
|
21
|
+
link = document.getElementById( "l_" + id )
|
22
|
+
}
|
23
|
+
else if ( document.all )
|
24
|
+
{
|
25
|
+
elem = eval( "document.all." + id )
|
26
|
+
link = eval( "document.all.l_" + id )
|
27
|
+
}
|
28
|
+
else
|
29
|
+
return false;
|
30
|
+
|
31
|
+
if( elem.style.display == "block" )
|
32
|
+
{
|
33
|
+
elem.style.display = "none"
|
34
|
+
link.innerHTML = "show source"
|
35
|
+
}
|
36
|
+
else
|
37
|
+
{
|
38
|
+
elem.style.display = "block"
|
39
|
+
link.innerHTML = "hide source"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
function openCode( url )
|
44
|
+
{
|
45
|
+
window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
|
46
|
+
}
|
47
|
+
// ]]>
|
48
|
+
</script>
|
49
|
+
</head>
|
50
|
+
<body>
|
51
|
+
<ul id="menu">
|
52
|
+
<li><a href="/thin/">home</a></li>
|
53
|
+
<li><a href="/thin/doc/">doc</a></li>
|
54
|
+
<li><a href="/thin/trac.fcgi/timeline">timeline</a></li>
|
55
|
+
<li><a href="/thin/trac.fcgi/browser">code</a></li>
|
56
|
+
<li><a href="/thin/trac.fcgi/report">tickets</a></li>
|
57
|
+
<li><a href="/thin/trac.fcgi/newticket">new ticket</a></li>
|
58
|
+
</ul>
|
59
|
+
<div id="sidebar">
|
60
|
+
<h2>Files</h2>
|
61
|
+
<ul class="list">
|
62
|
+
<li><a href="../../../files/README.html" value="File: README">README</a></li>
|
63
|
+
<li><a href="../../../files/lib/thin/cgi_rb.html" value="File: cgi.rb">lib/thin/cgi.rb</a></li>
|
64
|
+
<li><a href="../../../files/lib/thin/cluster_rb.html" value="File: cluster.rb">lib/thin/cluster.rb</a></li>
|
65
|
+
<li><a href="../../../files/lib/thin/command_rb.html" value="File: command.rb">lib/thin/command.rb</a></li>
|
66
|
+
<li><a href="../../../files/lib/thin/consts_rb.html" value="File: consts.rb">lib/thin/consts.rb</a></li>
|
67
|
+
<li><a href="../../../files/lib/thin/daemonizing_rb.html" value="File: daemonizing.rb">lib/thin/daemonizing.rb</a></li>
|
68
|
+
<li><a href="../../../files/lib/thin/handler_rb.html" value="File: handler.rb">lib/thin/handler.rb</a></li>
|
69
|
+
<li><a href="../../../files/lib/thin/headers_rb.html" value="File: headers.rb">lib/thin/headers.rb</a></li>
|
70
|
+
<li><a href="../../../files/lib/thin/logging_rb.html" value="File: logging.rb">lib/thin/logging.rb</a></li>
|
71
|
+
<li><a href="../../../files/lib/thin/mime_types_rb.html" value="File: mime_types.rb">lib/thin/mime_types.rb</a></li>
|
72
|
+
<li><a href="../../../files/lib/thin/rails_rb.html" value="File: rails.rb">lib/thin/rails.rb</a></li>
|
73
|
+
<li><a href="../../../files/lib/thin/recipes_rb.html" value="File: recipes.rb">lib/thin/recipes.rb</a></li>
|
74
|
+
<li><a href="../../../files/lib/thin/request_rb.html" value="File: request.rb">lib/thin/request.rb</a></li>
|
75
|
+
<li><a href="../../../files/lib/thin/response_rb.html" value="File: response.rb">lib/thin/response.rb</a></li>
|
76
|
+
<li><a href="../../../files/lib/thin/server_rb.html" value="File: server.rb">lib/thin/server.rb</a></li>
|
77
|
+
<li><a href="../../../files/lib/thin/statuses_rb.html" value="File: statuses.rb">lib/thin/statuses.rb</a></li>
|
78
|
+
<li><a href="../../../files/lib/thin/version_rb.html" value="File: version.rb">lib/thin/version.rb</a></li>
|
79
|
+
<li><a href="../../../files/bin/thin.html" value="File: thin">bin/thin</a></li>
|
80
|
+
<li><a href="../../../files/bin/thin_cluster.html" value="File: thin_cluster">bin/thin_cluster</a></li>
|
81
|
+
</ul>
|
82
|
+
|
83
|
+
<h2>Classes</h2>
|
84
|
+
<ul class="list">
|
85
|
+
<li><a href="../../../classes/Thin.html" title="Module: Thin">Thin</a></li>
|
86
|
+
<li><a href="../../../classes/Thin/Commands.html" title="Module: Thin::Commands">Thin::Commands</a></li>
|
87
|
+
<li><a href="../../../classes/Thin/Daemonizable.html" title="Module: Thin::Daemonizable">Thin::Daemonizable</a></li>
|
88
|
+
<li><a href="../../../classes/Thin/Daemonizable/ClassMethods.html" title="Module: Thin::Daemonizable::ClassMethods">Thin::Daemonizable::ClassMethods</a></li>
|
89
|
+
<li><a href="../../../classes/Thin/VERSION.html" title="Module: Thin::VERSION">Thin::VERSION</a></li>
|
90
|
+
<li><a href="../../../classes/Thin/Logging.html" title="Module: Thin::Logging">Thin::Logging</a></li>
|
91
|
+
<li><a href="../../../classes/Thin/DirHandler.html" title="Class: Thin::DirHandler">Thin::DirHandler</a></li>
|
92
|
+
<li><a href="../../../classes/Thin/InvalidRequest.html" title="Class: Thin::InvalidRequest">Thin::InvalidRequest</a></li>
|
93
|
+
<li><a href="../../../classes/Thin/CGIWrapper.html" title="Class: Thin::CGIWrapper">Thin::CGIWrapper</a></li>
|
94
|
+
<li><a href="../../../classes/Thin/Command.html" title="Class: Thin::Command">Thin::Command</a></li>
|
95
|
+
<li><a href="../../../classes/Thin/Response.html" title="Class: Thin::Response">Thin::Response</a></li>
|
96
|
+
<li><a href="../../../classes/Thin/Headers.html" title="Class: Thin::Headers">Thin::Headers</a></li>
|
97
|
+
<li><a href="../../../classes/Thin/Server.html" title="Class: Thin::Server">Thin::Server</a></li>
|
98
|
+
<li><a href="../../../classes/Thin/CommandError.html" title="Class: Thin::CommandError">Thin::CommandError</a></li>
|
99
|
+
<li><a href="../../../classes/Thin/Request.html" title="Class: Thin::Request">Thin::Request</a></li>
|
100
|
+
<li><a href="../../../classes/Thin/RailsServer.html" title="Class: Thin::RailsServer">Thin::RailsServer</a></li>
|
101
|
+
<li><a href="../../../classes/Thin/Cluster.html" title="Class: Thin::Cluster">Thin::Cluster</a></li>
|
102
|
+
<li><a href="../../../classes/Thin/RailsHandler.html" title="Class: Thin::RailsHandler">Thin::RailsHandler</a></li>
|
103
|
+
<li><a href="../../../classes/Thin/Handler.html" title="Class: Thin::Handler">Thin::Handler</a></li>
|
104
|
+
<li><a href="../../../classes/Process.html" title="Module: Process">Process</a></li>
|
105
|
+
<li><a href="../../../classes/Kernel.html" title="Module: Kernel">Kernel</a></li>
|
106
|
+
</ul>
|
107
|
+
</div>
|
108
|
+
<div id="container">
|
109
|
+
<div id="header">
|
110
|
+
<a href="/thin/" title="Home">
|
111
|
+
<img id="logo" src="../../../logo.gif" />
|
112
|
+
</a>
|
113
|
+
<h2 id="tag_line">A fast and very simple Ruby web server</h2>
|
114
|
+
</div>
|
115
|
+
|
116
|
+
<div id="content">
|
117
|
+
<h2>Module: Thin::Daemonizable::ClassMethods</h2>
|
118
|
+
|
119
|
+
|
120
|
+
<div id="Thin::Daemonizable::ClassMethods" class="page_shade">
|
121
|
+
<div class="page">
|
122
|
+
<h3>Module Thin::Daemonizable::ClassMethods</h3>
|
123
|
+
|
124
|
+
<span class="path">(in files
|
125
|
+
<a href="../../../files/lib/thin/daemonizing_rb.html">lib/thin/daemonizing.rb</a>
|
126
|
+
)</span>
|
127
|
+
|
128
|
+
<p>
|
129
|
+
Module <a href="Daemonizable.html#M000002">included</a> in classes that can
|
130
|
+
be turned into a daemon. Handle stuff like:
|
131
|
+
</p>
|
132
|
+
<ul>
|
133
|
+
<li>storing the PID in a file
|
134
|
+
|
135
|
+
</li>
|
136
|
+
<li>redirecting output to the log file
|
137
|
+
|
138
|
+
</li>
|
139
|
+
<li>changing processs privileges
|
140
|
+
|
141
|
+
</li>
|
142
|
+
<li>killing the process gracefully
|
143
|
+
|
144
|
+
</li>
|
145
|
+
</ul>
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
<h2 class="ruled">Methods</h2>
|
152
|
+
<h4 class="ruled">
|
153
|
+
<span class="method-type" title="Public Instance method">Public Instance</span>
|
154
|
+
<strong><a name="M000005" href="#M000005" title="Permalink to Public Instance method: kill">kill(pid_file, timeout=60)</a></strong>
|
155
|
+
</h4>
|
156
|
+
|
157
|
+
<p>
|
158
|
+
Kill the process which PID is stored in <tt>pid_file</tt>.
|
159
|
+
</p>
|
160
|
+
|
161
|
+
<div class="sourcecode">
|
162
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000005_source')" id="l_M000005_source">show source</a> ]</p>
|
163
|
+
<div id="M000005_source" class="dyn-source">
|
164
|
+
<pre>
|
165
|
+
<span class="ruby-comment cmt"># File lib/thin/daemonizing.rb, line 86</span>
|
166
|
+
86: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">kill</span>(<span class="ruby-identifier">pid_file</span>, <span class="ruby-identifier">timeout</span>=<span class="ruby-value">60</span>)
|
167
|
+
87: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">pid_file</span>) <span class="ruby-operator">&&</span> <span class="ruby-identifier">pid</span> = <span class="ruby-identifier">open</span>(<span class="ruby-identifier">pid_file</span>).<span class="ruby-identifier">read</span>
|
168
|
+
88: <span class="ruby-identifier">pid</span> = <span class="ruby-identifier">pid</span>.<span class="ruby-identifier">to_i</span>
|
169
|
+
89: <span class="ruby-identifier">print</span> <span class="ruby-node">"Sending INT signal to process #{pid} ... "</span>
|
170
|
+
90: <span class="ruby-keyword kw">begin</span>
|
171
|
+
91: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-value str">'INT'</span>, <span class="ruby-identifier">pid</span>)
|
172
|
+
92: <span class="ruby-constant">Timeout</span>.<span class="ruby-identifier">timeout</span>(<span class="ruby-identifier">timeout</span>) <span class="ruby-keyword kw">do</span>
|
173
|
+
93: <span class="ruby-identifier">sleep</span> <span class="ruby-value">0</span><span class="ruby-value">.1</span> <span class="ruby-keyword kw">while</span> <span class="ruby-constant">Process</span>.<span class="ruby-identifier">running?</span>(<span class="ruby-identifier">pid</span>)
|
174
|
+
94: <span class="ruby-keyword kw">end</span>
|
175
|
+
95: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Timeout</span><span class="ruby-operator">::</span><span class="ruby-constant">Error</span>
|
176
|
+
96: <span class="ruby-identifier">print</span> <span class="ruby-value str">"timeout, Sending KILL signal ... "</span>
|
177
|
+
97: <span class="ruby-constant">Process</span>.<span class="ruby-identifier">kill</span>(<span class="ruby-value str">'KILL'</span>, <span class="ruby-identifier">pid</span>)
|
178
|
+
98: <span class="ruby-keyword kw">end</span>
|
179
|
+
99: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"stopped!"</span>
|
180
|
+
100: <span class="ruby-keyword kw">else</span>
|
181
|
+
101: <span class="ruby-identifier">puts</span> <span class="ruby-node">"Can't stop process, no PID found in #{@pid_file}"</span>
|
182
|
+
102: <span class="ruby-keyword kw">end</span>
|
183
|
+
103: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ESRCH</span> <span class="ruby-comment cmt"># No such process</span>
|
184
|
+
104: <span class="ruby-identifier">puts</span> <span class="ruby-value str">"process not found!"</span>
|
185
|
+
105: <span class="ruby-keyword kw">ensure</span>
|
186
|
+
106: <span class="ruby-constant">File</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">pid_file</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
|
187
|
+
107: <span class="ruby-keyword kw">end</span>
|
188
|
+
</pre>
|
189
|
+
</div>
|
190
|
+
</div>
|
191
|
+
|
192
|
+
</div>
|
193
|
+
</div>
|
194
|
+
|
195
|
+
|
196
|
+
</div>
|
197
|
+
</div>
|
198
|
+
<div id="footer">
|
199
|
+
<hr />
|
200
|
+
© <a href="http://macournoyer.com">Marc-André Cournoyer</a>
|
201
|
+
</div>
|
202
|
+
</body>
|
203
|
+
</html>
|
@@ -0,0 +1,250 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>
|
6
|
+
thin » Class: Thin::DirHandler
|
7
|
+
</title>
|
8
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
10
|
+
<script language="JavaScript" type="text/javascript">
|
11
|
+
// <![CDATA[
|
12
|
+
|
13
|
+
function toggleSource( id )
|
14
|
+
{
|
15
|
+
var elem
|
16
|
+
var link
|
17
|
+
|
18
|
+
if( document.getElementById )
|
19
|
+
{
|
20
|
+
elem = document.getElementById( id )
|
21
|
+
link = document.getElementById( "l_" + id )
|
22
|
+
}
|
23
|
+
else if ( document.all )
|
24
|
+
{
|
25
|
+
elem = eval( "document.all." + id )
|
26
|
+
link = eval( "document.all.l_" + id )
|
27
|
+
}
|
28
|
+
else
|
29
|
+
return false;
|
30
|
+
|
31
|
+
if( elem.style.display == "block" )
|
32
|
+
{
|
33
|
+
elem.style.display = "none"
|
34
|
+
link.innerHTML = "show source"
|
35
|
+
}
|
36
|
+
else
|
37
|
+
{
|
38
|
+
elem.style.display = "block"
|
39
|
+
link.innerHTML = "hide source"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
function openCode( url )
|
44
|
+
{
|
45
|
+
window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
|
46
|
+
}
|
47
|
+
// ]]>
|
48
|
+
</script>
|
49
|
+
</head>
|
50
|
+
<body>
|
51
|
+
<ul id="menu">
|
52
|
+
<li><a href="/thin/">home</a></li>
|
53
|
+
<li><a href="/thin/doc/">doc</a></li>
|
54
|
+
<li><a href="/thin/trac.fcgi/timeline">timeline</a></li>
|
55
|
+
<li><a href="/thin/trac.fcgi/browser">code</a></li>
|
56
|
+
<li><a href="/thin/trac.fcgi/report">tickets</a></li>
|
57
|
+
<li><a href="/thin/trac.fcgi/newticket">new ticket</a></li>
|
58
|
+
</ul>
|
59
|
+
<div id="sidebar">
|
60
|
+
<h2>Files</h2>
|
61
|
+
<ul class="list">
|
62
|
+
<li><a href="../../files/README.html" value="File: README">README</a></li>
|
63
|
+
<li><a href="../../files/lib/thin/cgi_rb.html" value="File: cgi.rb">lib/thin/cgi.rb</a></li>
|
64
|
+
<li><a href="../../files/lib/thin/cluster_rb.html" value="File: cluster.rb">lib/thin/cluster.rb</a></li>
|
65
|
+
<li><a href="../../files/lib/thin/command_rb.html" value="File: command.rb">lib/thin/command.rb</a></li>
|
66
|
+
<li><a href="../../files/lib/thin/consts_rb.html" value="File: consts.rb">lib/thin/consts.rb</a></li>
|
67
|
+
<li><a href="../../files/lib/thin/daemonizing_rb.html" value="File: daemonizing.rb">lib/thin/daemonizing.rb</a></li>
|
68
|
+
<li><a href="../../files/lib/thin/handler_rb.html" value="File: handler.rb">lib/thin/handler.rb</a></li>
|
69
|
+
<li><a href="../../files/lib/thin/headers_rb.html" value="File: headers.rb">lib/thin/headers.rb</a></li>
|
70
|
+
<li><a href="../../files/lib/thin/logging_rb.html" value="File: logging.rb">lib/thin/logging.rb</a></li>
|
71
|
+
<li><a href="../../files/lib/thin/mime_types_rb.html" value="File: mime_types.rb">lib/thin/mime_types.rb</a></li>
|
72
|
+
<li><a href="../../files/lib/thin/rails_rb.html" value="File: rails.rb">lib/thin/rails.rb</a></li>
|
73
|
+
<li><a href="../../files/lib/thin/recipes_rb.html" value="File: recipes.rb">lib/thin/recipes.rb</a></li>
|
74
|
+
<li><a href="../../files/lib/thin/request_rb.html" value="File: request.rb">lib/thin/request.rb</a></li>
|
75
|
+
<li><a href="../../files/lib/thin/response_rb.html" value="File: response.rb">lib/thin/response.rb</a></li>
|
76
|
+
<li><a href="../../files/lib/thin/server_rb.html" value="File: server.rb">lib/thin/server.rb</a></li>
|
77
|
+
<li><a href="../../files/lib/thin/statuses_rb.html" value="File: statuses.rb">lib/thin/statuses.rb</a></li>
|
78
|
+
<li><a href="../../files/lib/thin/version_rb.html" value="File: version.rb">lib/thin/version.rb</a></li>
|
79
|
+
<li><a href="../../files/bin/thin.html" value="File: thin">bin/thin</a></li>
|
80
|
+
<li><a href="../../files/bin/thin_cluster.html" value="File: thin_cluster">bin/thin_cluster</a></li>
|
81
|
+
</ul>
|
82
|
+
|
83
|
+
<h2>Classes</h2>
|
84
|
+
<ul class="list">
|
85
|
+
<li><a href="../../classes/Thin.html" title="Module: Thin">Thin</a></li>
|
86
|
+
<li><a href="../../classes/Thin/Commands.html" title="Module: Thin::Commands">Thin::Commands</a></li>
|
87
|
+
<li><a href="../../classes/Thin/Daemonizable.html" title="Module: Thin::Daemonizable">Thin::Daemonizable</a></li>
|
88
|
+
<li><a href="../../classes/Thin/Daemonizable/ClassMethods.html" title="Module: Thin::Daemonizable::ClassMethods">Thin::Daemonizable::ClassMethods</a></li>
|
89
|
+
<li><a href="../../classes/Thin/VERSION.html" title="Module: Thin::VERSION">Thin::VERSION</a></li>
|
90
|
+
<li><a href="../../classes/Thin/Logging.html" title="Module: Thin::Logging">Thin::Logging</a></li>
|
91
|
+
<li><a href="../../classes/Thin/DirHandler.html" title="Class: Thin::DirHandler">Thin::DirHandler</a></li>
|
92
|
+
<li><a href="../../classes/Thin/InvalidRequest.html" title="Class: Thin::InvalidRequest">Thin::InvalidRequest</a></li>
|
93
|
+
<li><a href="../../classes/Thin/CGIWrapper.html" title="Class: Thin::CGIWrapper">Thin::CGIWrapper</a></li>
|
94
|
+
<li><a href="../../classes/Thin/Command.html" title="Class: Thin::Command">Thin::Command</a></li>
|
95
|
+
<li><a href="../../classes/Thin/Response.html" title="Class: Thin::Response">Thin::Response</a></li>
|
96
|
+
<li><a href="../../classes/Thin/Headers.html" title="Class: Thin::Headers">Thin::Headers</a></li>
|
97
|
+
<li><a href="../../classes/Thin/Server.html" title="Class: Thin::Server">Thin::Server</a></li>
|
98
|
+
<li><a href="../../classes/Thin/CommandError.html" title="Class: Thin::CommandError">Thin::CommandError</a></li>
|
99
|
+
<li><a href="../../classes/Thin/Request.html" title="Class: Thin::Request">Thin::Request</a></li>
|
100
|
+
<li><a href="../../classes/Thin/RailsServer.html" title="Class: Thin::RailsServer">Thin::RailsServer</a></li>
|
101
|
+
<li><a href="../../classes/Thin/Cluster.html" title="Class: Thin::Cluster">Thin::Cluster</a></li>
|
102
|
+
<li><a href="../../classes/Thin/RailsHandler.html" title="Class: Thin::RailsHandler">Thin::RailsHandler</a></li>
|
103
|
+
<li><a href="../../classes/Thin/Handler.html" title="Class: Thin::Handler">Thin::Handler</a></li>
|
104
|
+
<li><a href="../../classes/Process.html" title="Module: Process">Process</a></li>
|
105
|
+
<li><a href="../../classes/Kernel.html" title="Module: Kernel">Kernel</a></li>
|
106
|
+
</ul>
|
107
|
+
</div>
|
108
|
+
<div id="container">
|
109
|
+
<div id="header">
|
110
|
+
<a href="/thin/" title="Home">
|
111
|
+
<img id="logo" src="../../logo.gif" />
|
112
|
+
</a>
|
113
|
+
<h2 id="tag_line">A fast and very simple Ruby web server</h2>
|
114
|
+
</div>
|
115
|
+
|
116
|
+
<div id="content">
|
117
|
+
<h2>Class: Thin::DirHandler</h2>
|
118
|
+
|
119
|
+
|
120
|
+
<div id="Thin::DirHandler" class="page_shade">
|
121
|
+
<div class="page">
|
122
|
+
<h3>Class Thin::DirHandler < <a href="Handler.html">Handler</a></h3>
|
123
|
+
|
124
|
+
<span class="path">(in files
|
125
|
+
<a href="../../files/lib/thin/handler_rb.html">lib/thin/handler.rb</a>
|
126
|
+
)</span>
|
127
|
+
|
128
|
+
<p>
|
129
|
+
Serve a directory from a URI.
|
130
|
+
</p>
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
<h2 class="ruled">Methods</h2>
|
137
|
+
<h4 class="ruled">
|
138
|
+
<span class="method-type" title="Public Class method">Public Class</span>
|
139
|
+
<strong><a name="M000009" href="#M000009" title="Permalink to Public Class method: new">new(pwd)</a></strong>
|
140
|
+
</h4>
|
141
|
+
|
142
|
+
|
143
|
+
<div class="sourcecode">
|
144
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000009_source')" id="l_M000009_source">show source</a> ]</p>
|
145
|
+
<div id="M000009_source" class="dyn-source">
|
146
|
+
<pre>
|
147
|
+
<span class="ruby-comment cmt"># File lib/thin/handler.rb, line 21</span>
|
148
|
+
21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">pwd</span>)
|
149
|
+
22: <span class="ruby-ivar">@pwd</span> = <span class="ruby-identifier">pwd</span>.<span class="ruby-identifier">dup</span>
|
150
|
+
23: <span class="ruby-keyword kw">end</span>
|
151
|
+
</pre>
|
152
|
+
</div>
|
153
|
+
</div>
|
154
|
+
<h4 class="ruled">
|
155
|
+
<span class="method-type" title="Public Instance method">Public Instance</span>
|
156
|
+
<strong><a name="M000010" href="#M000010" title="Permalink to Public Instance method: process">process(request, response)</a></strong>
|
157
|
+
</h4>
|
158
|
+
|
159
|
+
|
160
|
+
<div class="sourcecode">
|
161
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000010_source')" id="l_M000010_source">show source</a> ]</p>
|
162
|
+
<div id="M000010_source" class="dyn-source">
|
163
|
+
<pre>
|
164
|
+
<span class="ruby-comment cmt"># File lib/thin/handler.rb, line 25</span>
|
165
|
+
25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
|
166
|
+
26: <span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@pwd</span>, <span class="ruby-identifier">request</span>.<span class="ruby-identifier">path</span>)
|
167
|
+
27: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">path</span>)
|
168
|
+
28: <span class="ruby-identifier">serve_dir</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">path</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">response</span>
|
169
|
+
29: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
170
|
+
30: <span class="ruby-keyword kw">elsif</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">path</span>)
|
171
|
+
31: <span class="ruby-identifier">serve_file</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">response</span>
|
172
|
+
32: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
173
|
+
33: <span class="ruby-keyword kw">end</span>
|
174
|
+
34: <span class="ruby-keyword kw">false</span>
|
175
|
+
35: <span class="ruby-keyword kw">end</span>
|
176
|
+
</pre>
|
177
|
+
</div>
|
178
|
+
</div>
|
179
|
+
<h4 class="ruled">
|
180
|
+
<span class="method-type" title="Public Instance method">Public Instance</span>
|
181
|
+
<strong><a name="M000011" href="#M000011" title="Permalink to Public Instance method: serve_dir">serve_dir(base, path, response)</a></strong>
|
182
|
+
</h4>
|
183
|
+
|
184
|
+
|
185
|
+
<div class="sourcecode">
|
186
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000011_source')" id="l_M000011_source">show source</a> ]</p>
|
187
|
+
<div id="M000011_source" class="dyn-source">
|
188
|
+
<pre>
|
189
|
+
<span class="ruby-comment cmt"># File lib/thin/handler.rb, line 37</span>
|
190
|
+
37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">serve_dir</span>(<span class="ruby-identifier">base</span>, <span class="ruby-identifier">path</span>, <span class="ruby-identifier">response</span>)
|
191
|
+
38: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">content_type</span> = <span class="ruby-value str">'text/html'</span>
|
192
|
+
39: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">body</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'<html><head><title>Dir listing</title></head>'</span>
|
193
|
+
40: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">body</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"<body><h1>Listing #{base}</h1><ul>"</span>
|
194
|
+
41: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">entries</span>(<span class="ruby-identifier">path</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
|
195
|
+
42: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">entry</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'.'</span>
|
196
|
+
43: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">body</span> <span class="ruby-operator"><<</span> <span class="ruby-node">%Q{<li><a href="#{File.join(base, entry)}">#{entry}</a></li>}</span>
|
197
|
+
44: <span class="ruby-keyword kw">end</span>
|
198
|
+
45: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">body</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">'</ul></body></html>'</span>
|
199
|
+
46: <span class="ruby-keyword kw">end</span>
|
200
|
+
</pre>
|
201
|
+
</div>
|
202
|
+
</div>
|
203
|
+
<h4 class="ruled">
|
204
|
+
<span class="method-type" title="Public Instance method">Public Instance</span>
|
205
|
+
<strong><a name="M000012" href="#M000012" title="Permalink to Public Instance method: serve_file">serve_file(path, response)</a></strong>
|
206
|
+
</h4>
|
207
|
+
|
208
|
+
|
209
|
+
<div class="sourcecode">
|
210
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000012_source')" id="l_M000012_source">show source</a> ]</p>
|
211
|
+
<div id="M000012_source" class="dyn-source">
|
212
|
+
<pre>
|
213
|
+
<span class="ruby-comment cmt"># File lib/thin/handler.rb, line 48</span>
|
214
|
+
48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">serve_file</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">response</span>)
|
215
|
+
49: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">content_type</span> = <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-constant">File</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-identifier">path</span>)] <span class="ruby-operator">||</span> <span class="ruby-value str">"application/octet-stream"</span>.<span class="ruby-identifier">freeze</span>
|
216
|
+
50: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-value str">"rb"</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">body</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span> }
|
217
|
+
51: <span class="ruby-keyword kw">end</span>
|
218
|
+
</pre>
|
219
|
+
</div>
|
220
|
+
</div>
|
221
|
+
<h4 class="ruled">
|
222
|
+
<span class="method-type" title="Public Instance method">Public Instance</span>
|
223
|
+
<strong><a name="M000013" href="#M000013" title="Permalink to Public Instance method: to_s">to_s()</a></strong>
|
224
|
+
</h4>
|
225
|
+
|
226
|
+
|
227
|
+
<div class="sourcecode">
|
228
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000013_source')" id="l_M000013_source">show source</a> ]</p>
|
229
|
+
<div id="M000013_source" class="dyn-source">
|
230
|
+
<pre>
|
231
|
+
<span class="ruby-comment cmt"># File lib/thin/handler.rb, line 53</span>
|
232
|
+
53: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
233
|
+
54: <span class="ruby-node">"dir #{@pwd}"</span>
|
234
|
+
55: <span class="ruby-keyword kw">end</span>
|
235
|
+
</pre>
|
236
|
+
</div>
|
237
|
+
</div>
|
238
|
+
|
239
|
+
</div>
|
240
|
+
</div>
|
241
|
+
|
242
|
+
|
243
|
+
</div>
|
244
|
+
</div>
|
245
|
+
<div id="footer">
|
246
|
+
<hr />
|
247
|
+
© <a href="http://macournoyer.com">Marc-André Cournoyer</a>
|
248
|
+
</div>
|
249
|
+
</body>
|
250
|
+
</html>
|