thin 0.4.1 → 0.5.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/COPYING +18 -0
- data/README +32 -45
- data/Rakefile +66 -23
- data/bin/thin +76 -45
- data/doc/benchmarks.txt +64 -249
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README.html +37 -100
- data/doc/rdoc/rdoc-style.css +5 -0
- data/example/config.ru +9 -0
- data/ext/thin_parser/common.rl +54 -0
- data/ext/thin_parser/ext_help.h +14 -0
- data/ext/thin_parser/extconf.rb +6 -0
- data/ext/thin_parser/parser.c +1199 -0
- data/ext/thin_parser/parser.h +49 -0
- data/ext/thin_parser/parser.rl +143 -0
- data/ext/thin_parser/thin.c +424 -0
- data/lib/rack/adapter/rails.rb +136 -0
- data/lib/rack/handler/thin.rb +13 -0
- data/lib/thin.rb +28 -12
- data/lib/thin/connection.rb +47 -0
- data/lib/thin/daemonizing.rb +5 -1
- data/lib/thin/headers.rb +3 -2
- data/lib/thin/logging.rb +6 -13
- data/lib/thin/request.rb +53 -133
- data/lib/thin/response.rb +21 -25
- data/lib/thin/server.rb +30 -94
- data/lib/thin/version.rb +2 -2
- data/lib/thin_parser.bundle +0 -0
- data/spec/daemonizing_spec.rb +94 -0
- data/spec/headers_spec.rb +35 -0
- data/spec/request_spec.rb +258 -0
- data/spec/response_spec.rb +40 -0
- data/spec/server_spec.rb +75 -0
- data/spec/spec_helper.rb +126 -0
- metadata +79 -99
- data/bin/thin_cluster +0 -53
- data/doc/rdoc/classes/Kernel.html +0 -182
- data/doc/rdoc/classes/Process.html +0 -175
- data/doc/rdoc/classes/Thin.html +0 -184
- data/doc/rdoc/classes/Thin/CGIWrapper.html +0 -438
- data/doc/rdoc/classes/Thin/Cluster.html +0 -392
- data/doc/rdoc/classes/Thin/Command.html +0 -221
- data/doc/rdoc/classes/Thin/CommandError.html +0 -154
- data/doc/rdoc/classes/Thin/Commands.html +0 -145
- data/doc/rdoc/classes/Thin/Daemonizable.html +0 -250
- data/doc/rdoc/classes/Thin/Daemonizable/ClassMethods.html +0 -203
- data/doc/rdoc/classes/Thin/DirHandler.html +0 -250
- data/doc/rdoc/classes/Thin/Handler.html +0 -195
- data/doc/rdoc/classes/Thin/Headers.html +0 -244
- data/doc/rdoc/classes/Thin/InvalidRequest.html +0 -150
- data/doc/rdoc/classes/Thin/Logging.html +0 -214
- data/doc/rdoc/classes/Thin/RailsHandler.html +0 -234
- data/doc/rdoc/classes/Thin/RailsServer.html +0 -175
- data/doc/rdoc/classes/Thin/Request.html +0 -379
- data/doc/rdoc/classes/Thin/Response.html +0 -311
- data/doc/rdoc/classes/Thin/Server.html +0 -381
- data/doc/rdoc/files/bin/thin.html +0 -188
- data/doc/rdoc/files/bin/thin_cluster.html +0 -175
- data/doc/rdoc/files/lib/thin/cgi_rb.html +0 -263
- data/doc/rdoc/files/lib/thin/cluster_rb.html +0 -263
- data/doc/rdoc/files/lib/thin/command_rb.html +0 -263
- data/doc/rdoc/files/lib/thin/consts_rb.html +0 -263
- data/doc/rdoc/files/lib/thin/daemonizing_rb.html +0 -263
- data/doc/rdoc/files/lib/thin/handler_rb.html +0 -263
- data/doc/rdoc/files/lib/thin/headers_rb.html +0 -263
- data/doc/rdoc/files/lib/thin/logging_rb.html +0 -263
- data/doc/rdoc/files/lib/thin/mime_types_rb.html +0 -263
- data/doc/rdoc/files/lib/thin/rails_rb.html +0 -263
- data/doc/rdoc/files/lib/thin/recipes_rb.html +0 -171
- data/doc/rdoc/files/lib/thin/request_rb.html +0 -171
- data/doc/rdoc/files/lib/thin/response_rb.html +0 -171
- data/doc/rdoc/files/lib/thin/server_rb.html +0 -171
- data/doc/rdoc/files/lib/thin/statuses_rb.html +0 -171
- data/doc/rdoc/files/lib/thin/version_rb.html +0 -171
- data/lib/thin/cgi.rb +0 -159
- data/lib/thin/cluster.rb +0 -147
- data/lib/thin/command.rb +0 -49
- data/lib/thin/commands/cluster/base.rb +0 -24
- data/lib/thin/commands/cluster/config.rb +0 -36
- data/lib/thin/commands/cluster/restart.rb +0 -35
- data/lib/thin/commands/cluster/start.rb +0 -40
- data/lib/thin/commands/cluster/stop.rb +0 -28
- data/lib/thin/commands/server/base.rb +0 -7
- data/lib/thin/commands/server/start.rb +0 -33
- data/lib/thin/commands/server/stop.rb +0 -29
- data/lib/thin/consts.rb +0 -37
- data/lib/thin/handler.rb +0 -57
- data/lib/thin/mime_types.rb +0 -619
- data/lib/thin/rails.rb +0 -44
- data/lib/thin/recipes.rb +0 -36
- data/lib/transat/parser.rb +0 -247
@@ -1,311 +0,0 @@
|
|
1
|
-
|
2
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<title>
|
6
|
-
thin » Class: Thin::Response
|
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::Response</h2>
|
118
|
-
|
119
|
-
|
120
|
-
<div id="Thin::Response" class="page_shade">
|
121
|
-
<div class="page">
|
122
|
-
<h3>Class Thin::Response < <a href="Handler.html">Object</a></h3>
|
123
|
-
|
124
|
-
<span class="path">(in files
|
125
|
-
<a href="../../files/lib/thin/response_rb.html">lib/thin/response.rb</a>
|
126
|
-
)</span>
|
127
|
-
|
128
|
-
<p>
|
129
|
-
A response sent to the client.
|
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="M000027" href="#M000027" title="Permalink to Public Class method: new">new()</a></strong>
|
140
|
-
</h4>
|
141
|
-
|
142
|
-
|
143
|
-
<div class="sourcecode">
|
144
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000027_source')" id="l_M000027_source">show source</a> ]</p>
|
145
|
-
<div id="M000027_source" class="dyn-source">
|
146
|
-
<pre>
|
147
|
-
<span class="ruby-comment cmt"># File lib/thin/response.rb, line 9</span>
|
148
|
-
9: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
|
149
|
-
10: <span class="ruby-ivar">@headers</span> = <span class="ruby-constant">Headers</span>.<span class="ruby-identifier">new</span>
|
150
|
-
11: <span class="ruby-ivar">@body</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>
|
151
|
-
12: <span class="ruby-ivar">@status</span> = <span class="ruby-value">200</span>
|
152
|
-
13: <span class="ruby-keyword kw">end</span>
|
153
|
-
</pre>
|
154
|
-
</div>
|
155
|
-
</div>
|
156
|
-
<h4 class="ruled">
|
157
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
158
|
-
<strong><a name="M000033" href="#M000033" title="Permalink to Public Instance method: close">close()</a></strong>
|
159
|
-
</h4>
|
160
|
-
|
161
|
-
|
162
|
-
<div class="sourcecode">
|
163
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000033_source')" id="l_M000033_source">show source</a> ]</p>
|
164
|
-
<div id="M000033_source" class="dyn-source">
|
165
|
-
<pre>
|
166
|
-
<span class="ruby-comment cmt"># File lib/thin/response.rb, line 39</span>
|
167
|
-
39: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close</span>
|
168
|
-
40: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">close</span>
|
169
|
-
41: <span class="ruby-keyword kw">end</span>
|
170
|
-
</pre>
|
171
|
-
</div>
|
172
|
-
</div>
|
173
|
-
<h4 class="ruled">
|
174
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
175
|
-
<strong><a name="M000029" href="#M000029" title="Permalink to Public Instance method: content_type">content_type()</a></strong>
|
176
|
-
</h4>
|
177
|
-
|
178
|
-
|
179
|
-
<div class="sourcecode">
|
180
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000029_source')" id="l_M000029_source">show source</a> ]</p>
|
181
|
-
<div id="M000029_source" class="dyn-source">
|
182
|
-
<pre>
|
183
|
-
<span class="ruby-comment cmt"># File lib/thin/response.rb, line 19</span>
|
184
|
-
19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_type</span>
|
185
|
-
20: <span class="ruby-ivar">@headers</span>[<span class="ruby-constant">CONTENT_TYPE</span>]
|
186
|
-
21: <span class="ruby-keyword kw">end</span>
|
187
|
-
</pre>
|
188
|
-
</div>
|
189
|
-
</div>
|
190
|
-
<h4 class="ruled">
|
191
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
192
|
-
<strong><a name="M000028" href="#M000028" title="Permalink to Public Instance method: content_type=">content_type=(type)</a></strong>
|
193
|
-
</h4>
|
194
|
-
|
195
|
-
|
196
|
-
<div class="sourcecode">
|
197
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000028_source')" id="l_M000028_source">show source</a> ]</p>
|
198
|
-
<div id="M000028_source" class="dyn-source">
|
199
|
-
<pre>
|
200
|
-
<span class="ruby-comment cmt"># File lib/thin/response.rb, line 15</span>
|
201
|
-
15: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_type=</span>(<span class="ruby-identifier">type</span>)
|
202
|
-
16: <span class="ruby-ivar">@headers</span>[<span class="ruby-constant">CONTENT_TYPE</span>] = <span class="ruby-identifier">type</span>
|
203
|
-
17: <span class="ruby-keyword kw">end</span>
|
204
|
-
</pre>
|
205
|
-
</div>
|
206
|
-
</div>
|
207
|
-
<h4 class="ruled">
|
208
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
209
|
-
<strong><a name="M000031" href="#M000031" title="Permalink to Public Instance method: head">head()</a></strong>
|
210
|
-
</h4>
|
211
|
-
|
212
|
-
|
213
|
-
<div class="sourcecode">
|
214
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000031_source')" id="l_M000031_source">show source</a> ]</p>
|
215
|
-
<div id="M000031_source" class="dyn-source">
|
216
|
-
<pre>
|
217
|
-
<span class="ruby-comment cmt"># File lib/thin/response.rb, line 29</span>
|
218
|
-
29: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">head</span>
|
219
|
-
30: <span class="ruby-node">"HTTP/1.1 #{@status} #{HTTP_STATUS_CODES[@status.to_i]}\r\n#{headers_output}\r\n"</span>
|
220
|
-
31: <span class="ruby-keyword kw">end</span>
|
221
|
-
</pre>
|
222
|
-
</div>
|
223
|
-
</div>
|
224
|
-
<h4 class="ruled">
|
225
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
226
|
-
<strong><a name="M000030" href="#M000030" title="Permalink to Public Instance method: headers_output">headers_output()</a></strong>
|
227
|
-
</h4>
|
228
|
-
|
229
|
-
|
230
|
-
<div class="sourcecode">
|
231
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000030_source')" id="l_M000030_source">show source</a> ]</p>
|
232
|
-
<div id="M000030_source" class="dyn-source">
|
233
|
-
<pre>
|
234
|
-
<span class="ruby-comment cmt"># File lib/thin/response.rb, line 23</span>
|
235
|
-
23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">headers_output</span>
|
236
|
-
24: <span class="ruby-ivar">@headers</span>[<span class="ruby-constant">CONTENT_LENGTH</span>] = <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">size</span>
|
237
|
-
25: <span class="ruby-ivar">@headers</span>[<span class="ruby-constant">CONNECTION</span>] = <span class="ruby-constant">CLOSE</span>
|
238
|
-
26: <span class="ruby-ivar">@headers</span>.<span class="ruby-identifier">to_s</span>
|
239
|
-
27: <span class="ruby-keyword kw">end</span>
|
240
|
-
</pre>
|
241
|
-
</div>
|
242
|
-
</div>
|
243
|
-
<h4 class="ruled">
|
244
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
245
|
-
<strong><a name="M000034" href="#M000034" title="Permalink to Public Instance method: start">start(status) {|@headers, @body| ...}</a></strong>
|
246
|
-
</h4>
|
247
|
-
|
248
|
-
|
249
|
-
<div class="sourcecode">
|
250
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000034_source')" id="l_M000034_source">show source</a> ]</p>
|
251
|
-
<div id="M000034_source" class="dyn-source">
|
252
|
-
<pre>
|
253
|
-
<span class="ruby-comment cmt"># File lib/thin/response.rb, line 43</span>
|
254
|
-
43: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start</span>(<span class="ruby-identifier">status</span>)
|
255
|
-
44: <span class="ruby-ivar">@status</span> = <span class="ruby-identifier">status</span>
|
256
|
-
45: <span class="ruby-keyword kw">yield</span> <span class="ruby-ivar">@headers</span>, <span class="ruby-ivar">@body</span>
|
257
|
-
46: <span class="ruby-keyword kw">end</span>
|
258
|
-
</pre>
|
259
|
-
</div>
|
260
|
-
</div>
|
261
|
-
<h4 class="ruled">
|
262
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
263
|
-
<strong><a name="M000035" href="#M000035" title="Permalink to Public Instance method: to_s">to_s()</a></strong>
|
264
|
-
</h4>
|
265
|
-
|
266
|
-
|
267
|
-
<div class="sourcecode">
|
268
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000035_source')" id="l_M000035_source">show source</a> ]</p>
|
269
|
-
<div id="M000035_source" class="dyn-source">
|
270
|
-
<pre>
|
271
|
-
<span class="ruby-comment cmt"># File lib/thin/response.rb, line 48</span>
|
272
|
-
48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
|
273
|
-
49: <span class="ruby-identifier">out</span> = <span class="ruby-value str">''</span>
|
274
|
-
50: <span class="ruby-identifier">write</span> <span class="ruby-identifier">out</span>
|
275
|
-
51: <span class="ruby-identifier">out</span>
|
276
|
-
52: <span class="ruby-keyword kw">end</span>
|
277
|
-
</pre>
|
278
|
-
</div>
|
279
|
-
</div>
|
280
|
-
<h4 class="ruled">
|
281
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
282
|
-
<strong><a name="M000032" href="#M000032" title="Permalink to Public Instance method: write">write(socket)</a></strong>
|
283
|
-
</h4>
|
284
|
-
|
285
|
-
|
286
|
-
<div class="sourcecode">
|
287
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000032_source')" id="l_M000032_source">show source</a> ]</p>
|
288
|
-
<div id="M000032_source" class="dyn-source">
|
289
|
-
<pre>
|
290
|
-
<span class="ruby-comment cmt"># File lib/thin/response.rb, line 33</span>
|
291
|
-
33: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">socket</span>)
|
292
|
-
34: <span class="ruby-identifier">socket</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">head</span>
|
293
|
-
35: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">rewind</span>
|
294
|
-
36: <span class="ruby-identifier">socket</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">read</span>
|
295
|
-
37: <span class="ruby-keyword kw">end</span>
|
296
|
-
</pre>
|
297
|
-
</div>
|
298
|
-
</div>
|
299
|
-
|
300
|
-
</div>
|
301
|
-
</div>
|
302
|
-
|
303
|
-
|
304
|
-
</div>
|
305
|
-
</div>
|
306
|
-
<div id="footer">
|
307
|
-
<hr />
|
308
|
-
© <a href="http://macournoyer.com">Marc-André Cournoyer</a>
|
309
|
-
</div>
|
310
|
-
</body>
|
311
|
-
</html>
|
@@ -1,381 +0,0 @@
|
|
1
|
-
|
2
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<title>
|
6
|
-
thin » Class: Thin::Server
|
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::Server</h2>
|
118
|
-
|
119
|
-
|
120
|
-
<div id="Thin::Server" class="page_shade">
|
121
|
-
<div class="page">
|
122
|
-
<h3>Class Thin::Server < <a href="Handler.html">Object</a></h3>
|
123
|
-
|
124
|
-
<span class="path">(in files
|
125
|
-
<a href="../../files/lib/thin/server_rb.html">lib/thin/server.rb</a>
|
126
|
-
)</span>
|
127
|
-
|
128
|
-
<p>
|
129
|
-
The <a href="../Thin.html">Thin</a> HTTP server used to served request. It
|
130
|
-
listen for incoming request on a given port and forward all request to all
|
131
|
-
the handlers in the order they were registered. Based on HTTP 1.1 protocol
|
132
|
-
specs <a
|
133
|
-
href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">www.w3.org/Protocols/rfc2616/rfc2616.html</a>
|
134
|
-
</p>
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
<h4>Includes</h4>
|
140
|
-
<ul>
|
141
|
-
<li><a href="Logging.html">Logging</a></li>
|
142
|
-
<li><a href="Daemonizable.html">Daemonizable</a></li>
|
143
|
-
</ul>
|
144
|
-
|
145
|
-
<h2 class="ruled">Methods</h2>
|
146
|
-
<h4 class="ruled">
|
147
|
-
<span class="method-type" title="Public Class method">Public Class</span>
|
148
|
-
<strong><a name="M000041" href="#M000041" title="Permalink to Public Class method: new">new(host, port, *handlers)</a></strong>
|
149
|
-
</h4>
|
150
|
-
|
151
|
-
<p>
|
152
|
-
Creates a <a href="Server.html#M000041">new</a> server binded to
|
153
|
-
<tt>host:port</tt> that will pass request to <tt>handlers</tt>.
|
154
|
-
</p>
|
155
|
-
|
156
|
-
<div class="sourcecode">
|
157
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000041_source')" id="l_M000041_source">show source</a> ]</p>
|
158
|
-
<div id="M000041_source" class="dyn-source">
|
159
|
-
<pre>
|
160
|
-
<span class="ruby-comment cmt"># File lib/thin/server.rb, line 25</span>
|
161
|
-
25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">handlers</span>)
|
162
|
-
26: <span class="ruby-ivar">@host</span> = <span class="ruby-identifier">host</span>
|
163
|
-
27: <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">port</span>
|
164
|
-
28: <span class="ruby-ivar">@handlers</span> = <span class="ruby-identifier">handlers</span>
|
165
|
-
29: <span class="ruby-ivar">@timeout</span> = <span class="ruby-value">60</span> <span class="ruby-comment cmt"># sec, max time to read and parse a request</span>
|
166
|
-
30: <span class="ruby-ivar">@trace</span> = <span class="ruby-keyword kw">false</span>
|
167
|
-
31:
|
168
|
-
32: <span class="ruby-ivar">@stop</span> = <span class="ruby-keyword kw">true</span> <span class="ruby-comment cmt"># true is server is stopped</span>
|
169
|
-
33: <span class="ruby-ivar">@processing</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-comment cmt"># true is processing a request</span>
|
170
|
-
34:
|
171
|
-
35: <span class="ruby-ivar">@socket</span> = <span class="ruby-constant">TCPServer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>)
|
172
|
-
36: <span class="ruby-keyword kw">end</span>
|
173
|
-
</pre>
|
174
|
-
</div>
|
175
|
-
</div>
|
176
|
-
<h4 class="ruled">
|
177
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
178
|
-
<strong><a name="M000044" href="#M000044" title="Permalink to Public Instance method: listen!">listen!()</a></strong>
|
179
|
-
</h4>
|
180
|
-
|
181
|
-
<p>
|
182
|
-
Start listening for connections
|
183
|
-
</p>
|
184
|
-
|
185
|
-
<div class="sourcecode">
|
186
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000044_source')" id="l_M000044_source">show source</a> ]</p>
|
187
|
-
<div id="M000044_source" class="dyn-source">
|
188
|
-
<pre>
|
189
|
-
<span class="ruby-comment cmt"># File lib/thin/server.rb, line 56</span>
|
190
|
-
56: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">listen!</span>
|
191
|
-
57: <span class="ruby-ivar">@stop</span> = <span class="ruby-keyword kw">false</span>
|
192
|
-
58: <span class="ruby-identifier">trap</span>(<span class="ruby-value str">'INT'</span>) <span class="ruby-keyword kw">do</span>
|
193
|
-
59: <span class="ruby-identifier">log</span> <span class="ruby-value str">'>> Caught INT signal, stopping ...'</span>
|
194
|
-
60: <span class="ruby-identifier">stop</span>
|
195
|
-
61: <span class="ruby-keyword kw">end</span>
|
196
|
-
62:
|
197
|
-
63: <span class="ruby-identifier">log</span> <span class="ruby-node">">> Listening on #{host}:#{port}, CTRL+C to stop"</span>
|
198
|
-
64: <span class="ruby-keyword kw">until</span> <span class="ruby-ivar">@stop</span>
|
199
|
-
65: <span class="ruby-ivar">@processing</span> = <span class="ruby-keyword kw">false</span>
|
200
|
-
66: <span class="ruby-identifier">client</span> = <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">accept</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
|
201
|
-
67: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">closed?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">client</span>.<span class="ruby-identifier">nil?</span>
|
202
|
-
68: <span class="ruby-ivar">@processing</span> = <span class="ruby-keyword kw">true</span>
|
203
|
-
69: <span class="ruby-identifier">process</span>(<span class="ruby-identifier">client</span>)
|
204
|
-
70: <span class="ruby-keyword kw">end</span>
|
205
|
-
71: <span class="ruby-keyword kw">ensure</span>
|
206
|
-
72: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">closed?</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
|
207
|
-
73: <span class="ruby-keyword kw">end</span>
|
208
|
-
</pre>
|
209
|
-
</div>
|
210
|
-
</div>
|
211
|
-
<h4 class="ruled">
|
212
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
213
|
-
<strong><a name="M000045" href="#M000045" title="Permalink to Public Instance method: process">process(client)</a></strong>
|
214
|
-
</h4>
|
215
|
-
|
216
|
-
<p>
|
217
|
-
<a href="../Process.html">Process</a> one request from a client
|
218
|
-
</p>
|
219
|
-
|
220
|
-
<div class="sourcecode">
|
221
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000045_source')" id="l_M000045_source">show source</a> ]</p>
|
222
|
-
<div id="M000045_source" class="dyn-source">
|
223
|
-
<pre>
|
224
|
-
<span class="ruby-comment cmt"># File lib/thin/server.rb, line 76</span>
|
225
|
-
76: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">client</span>)
|
226
|
-
77: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">client</span>.<span class="ruby-identifier">eof?</span>
|
227
|
-
78:
|
228
|
-
79: <span class="ruby-identifier">trace</span> { <span class="ruby-value str">'Request started'</span>.<span class="ruby-identifier">center</span>(<span class="ruby-value">80</span>, <span class="ruby-value str">'='</span>) }
|
229
|
-
80:
|
230
|
-
81: <span class="ruby-identifier">request</span> = <span class="ruby-constant">Request</span>.<span class="ruby-identifier">new</span>
|
231
|
-
82: <span class="ruby-identifier">response</span> = <span class="ruby-constant">Response</span>.<span class="ruby-identifier">new</span>
|
232
|
-
83:
|
233
|
-
84: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">trace</span> = <span class="ruby-ivar">@trace</span>
|
234
|
-
85: <span class="ruby-identifier">trace</span> { <span class="ruby-value str">">> Tracing request parsing ... "</span> }
|
235
|
-
86:
|
236
|
-
87: <span class="ruby-comment cmt"># Parse the request checking for timeout to prevent DOS attacks</span>
|
237
|
-
88: <span class="ruby-constant">Timeout</span>.<span class="ruby-identifier">timeout</span>(<span class="ruby-ivar">@timeout</span>) { <span class="ruby-identifier">request</span>.<span class="ruby-identifier">parse!</span>(<span class="ruby-identifier">client</span>) }
|
238
|
-
89: <span class="ruby-identifier">trace</span> { <span class="ruby-identifier">request</span>.<span class="ruby-identifier">raw</span> }
|
239
|
-
90:
|
240
|
-
91: <span class="ruby-comment cmt"># Add client info to the request env</span>
|
241
|
-
92: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-value str">'REMOTE_ADDR'</span>] = <span class="ruby-identifier">client</span>.<span class="ruby-identifier">peeraddr</span>.<span class="ruby-identifier">last</span>
|
242
|
-
93:
|
243
|
-
94: <span class="ruby-comment cmt"># Add server info to the request env</span>
|
244
|
-
95: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-value str">'SERVER_SOFTWARE'</span>] = <span class="ruby-constant">SERVER</span>
|
245
|
-
96: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-value str">'SERVER_PORT'</span>] = <span class="ruby-ivar">@port</span>.<span class="ruby-identifier">to_s</span>
|
246
|
-
97:
|
247
|
-
98: <span class="ruby-identifier">served</span> = <span class="ruby-keyword kw">false</span>
|
248
|
-
99: <span class="ruby-ivar">@handlers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">handler</span><span class="ruby-operator">|</span>
|
249
|
-
100: <span class="ruby-identifier">served</span> = <span class="ruby-identifier">handler</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
|
250
|
-
101: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">served</span>
|
251
|
-
102: <span class="ruby-keyword kw">end</span>
|
252
|
-
103:
|
253
|
-
104: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">served</span>
|
254
|
-
105: <span class="ruby-identifier">trace</span> { <span class="ruby-value str">">> Sending response:\n"</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">to_s</span> }
|
255
|
-
106: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">client</span>
|
256
|
-
107: <span class="ruby-keyword kw">else</span>
|
257
|
-
108: <span class="ruby-identifier">client</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">ERROR_404_RESPONSE</span>
|
258
|
-
109: <span class="ruby-keyword kw">end</span>
|
259
|
-
110:
|
260
|
-
111: <span class="ruby-identifier">trace</span> { <span class="ruby-value str">'Request finished'</span>.<span class="ruby-identifier">center</span>(<span class="ruby-value">80</span>, <span class="ruby-value str">'='</span>) }
|
261
|
-
112:
|
262
|
-
113: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">EOFError</span>, <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ECONNRESET</span>, <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EPIPE</span>, <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EINVAL</span>, <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EBADF</span>
|
263
|
-
114: <span class="ruby-comment cmt"># Can't do anything sorry, closing the socket in the ensure block</span>
|
264
|
-
115: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">InvalidRequest</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
265
|
-
116: <span class="ruby-identifier">log</span> <span class="ruby-node">"Invalid request: #{e.message}"</span>
|
266
|
-
117: <span class="ruby-identifier">trace</span> { <span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>) }
|
267
|
-
118: <span class="ruby-identifier">client</span> <span class="ruby-operator"><<</span> <span class="ruby-constant">ERROR_400_RESPONSE</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
|
268
|
-
119: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Object</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
269
|
-
120: <span class="ruby-identifier">log</span> <span class="ruby-node">"Unexpected error while processing request: #{e.message}"</span>
|
270
|
-
121: <span class="ruby-identifier">log</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>)
|
271
|
-
122: <span class="ruby-keyword kw">ensure</span>
|
272
|
-
123: <span class="ruby-identifier">request</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">request</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
|
273
|
-
124: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">response</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
|
274
|
-
125: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">client</span>.<span class="ruby-identifier">closed?</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
|
275
|
-
126: <span class="ruby-keyword kw">end</span>
|
276
|
-
</pre>
|
277
|
-
</div>
|
278
|
-
</div>
|
279
|
-
<h4 class="ruled">
|
280
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
281
|
-
<strong><a name="M000042" href="#M000042" title="Permalink to Public Instance method: start">start()</a></strong>
|
282
|
-
</h4>
|
283
|
-
|
284
|
-
<p>
|
285
|
-
Starts the handlers.
|
286
|
-
</p>
|
287
|
-
|
288
|
-
<div class="sourcecode">
|
289
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000042_source')" id="l_M000042_source">show source</a> ]</p>
|
290
|
-
<div id="M000042_source" class="dyn-source">
|
291
|
-
<pre>
|
292
|
-
<span class="ruby-comment cmt"># File lib/thin/server.rb, line 39</span>
|
293
|
-
39: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start</span>
|
294
|
-
40: <span class="ruby-identifier">log</span> <span class="ruby-node">">> Thin web server (v#{VERSION::STRING})"</span>
|
295
|
-
41: <span class="ruby-identifier">trace</span> <span class="ruby-value str">">> Tracing ON"</span>
|
296
|
-
42:
|
297
|
-
43: <span class="ruby-ivar">@handlers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">handler</span><span class="ruby-operator">|</span>
|
298
|
-
44: <span class="ruby-identifier">log</span> <span class="ruby-node">">> Starting #{handler} ..."</span>
|
299
|
-
45: <span class="ruby-identifier">handler</span>.<span class="ruby-identifier">start</span>
|
300
|
-
46: <span class="ruby-keyword kw">end</span>
|
301
|
-
47: <span class="ruby-keyword kw">end</span>
|
302
|
-
</pre>
|
303
|
-
</div>
|
304
|
-
</div>
|
305
|
-
<h4 class="ruled">
|
306
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
307
|
-
<strong><a name="M000043" href="#M000043" title="Permalink to Public Instance method: start!">start!()</a></strong>
|
308
|
-
</h4>
|
309
|
-
|
310
|
-
<p>
|
311
|
-
Start the server and listen for connections
|
312
|
-
</p>
|
313
|
-
|
314
|
-
<div class="sourcecode">
|
315
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000043_source')" id="l_M000043_source">show source</a> ]</p>
|
316
|
-
<div id="M000043_source" class="dyn-source">
|
317
|
-
<pre>
|
318
|
-
<span class="ruby-comment cmt"># File lib/thin/server.rb, line 50</span>
|
319
|
-
50: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start!</span>
|
320
|
-
51: <span class="ruby-identifier">start</span>
|
321
|
-
52: <span class="ruby-identifier">listen!</span>
|
322
|
-
53: <span class="ruby-keyword kw">end</span>
|
323
|
-
</pre>
|
324
|
-
</div>
|
325
|
-
</div>
|
326
|
-
<h4 class="ruled">
|
327
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
328
|
-
<strong><a name="M000046" href="#M000046" title="Permalink to Public Instance method: stop">stop()</a></strong>
|
329
|
-
</h4>
|
330
|
-
|
331
|
-
<p>
|
332
|
-
Stop the server from accepting <a href="Server.html#M000041">new</a>
|
333
|
-
request. If a request is processing, wait for this to finish and shutdown
|
334
|
-
the server.
|
335
|
-
</p>
|
336
|
-
|
337
|
-
<div class="sourcecode">
|
338
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000046_source')" id="l_M000046_source">show source</a> ]</p>
|
339
|
-
<div id="M000046_source" class="dyn-source">
|
340
|
-
<pre>
|
341
|
-
<span class="ruby-comment cmt"># File lib/thin/server.rb, line 131</span>
|
342
|
-
131: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop</span>
|
343
|
-
132: <span class="ruby-ivar">@stop</span> = <span class="ruby-keyword kw">true</span>
|
344
|
-
133: <span class="ruby-identifier">stop!</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@processing</span> <span class="ruby-comment cmt"># Not processing a request, so we can stop now</span>
|
345
|
-
134: <span class="ruby-keyword kw">end</span>
|
346
|
-
</pre>
|
347
|
-
</div>
|
348
|
-
</div>
|
349
|
-
<h4 class="ruled">
|
350
|
-
<span class="method-type" title="Public Instance method">Public Instance</span>
|
351
|
-
<strong><a name="M000047" href="#M000047" title="Permalink to Public Instance method: stop!">stop!()</a></strong>
|
352
|
-
</h4>
|
353
|
-
|
354
|
-
<p>
|
355
|
-
Force the server to <a href="Server.html#M000046">stop</a> right now!
|
356
|
-
</p>
|
357
|
-
|
358
|
-
<div class="sourcecode">
|
359
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000047_source')" id="l_M000047_source">show source</a> ]</p>
|
360
|
-
<div id="M000047_source" class="dyn-source">
|
361
|
-
<pre>
|
362
|
-
<span class="ruby-comment cmt"># File lib/thin/server.rb, line 137</span>
|
363
|
-
137: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop!</span>
|
364
|
-
138: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># break the accept loop by closing the socket</span>
|
365
|
-
139: <span class="ruby-keyword kw">end</span>
|
366
|
-
</pre>
|
367
|
-
</div>
|
368
|
-
</div>
|
369
|
-
|
370
|
-
</div>
|
371
|
-
</div>
|
372
|
-
|
373
|
-
|
374
|
-
</div>
|
375
|
-
</div>
|
376
|
-
<div id="footer">
|
377
|
-
<hr />
|
378
|
-
© <a href="http://macournoyer.com">Marc-André Cournoyer</a>
|
379
|
-
</div>
|
380
|
-
</body>
|
381
|
-
</html>
|