serverside 0.1.59 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/CHANGELOG +21 -1
  2. data/Rakefile +69 -40
  3. data/bin/serverside +7 -15
  4. data/doc/rdoc/classes/Daemon.html +18 -18
  5. data/doc/rdoc/classes/Daemon/Base.html +8 -6
  6. data/doc/rdoc/classes/Daemon/Cluster.html +36 -36
  7. data/doc/rdoc/classes/Daemon/Cluster/PidFile.html +20 -18
  8. data/doc/rdoc/classes/Daemon/PidFile.html +12 -12
  9. data/doc/rdoc/classes/Object.html +151 -0
  10. data/doc/rdoc/classes/Proc.html +151 -0
  11. data/doc/rdoc/classes/ServerSide.html +69 -0
  12. data/doc/rdoc/classes/ServerSide/Application.html +43 -11
  13. data/doc/rdoc/classes/ServerSide/Application/Base.html +30 -30
  14. data/doc/rdoc/classes/ServerSide/Application/Static.html +20 -18
  15. data/doc/rdoc/classes/ServerSide/Connection.html +3 -3
  16. data/doc/rdoc/classes/ServerSide/Connection/Base.html +142 -99
  17. data/doc/rdoc/classes/ServerSide/Connection/Const.html +11 -13
  18. data/doc/rdoc/classes/ServerSide/Connection/Router.html +464 -0
  19. data/doc/rdoc/classes/ServerSide/Server.html +8 -6
  20. data/doc/rdoc/classes/ServerSide/StaticFiles.html +75 -43
  21. data/doc/rdoc/classes/ServerSide/StaticFiles/Const.html +5 -0
  22. data/doc/rdoc/classes/String.html +20 -18
  23. data/doc/rdoc/classes/Symbol.html +2 -0
  24. data/doc/rdoc/created.rid +1 -1
  25. data/doc/rdoc/files/CHANGELOG.html +32 -2
  26. data/doc/rdoc/files/lib/serverside/application_rb.html +1 -1
  27. data/doc/rdoc/files/lib/serverside/connection_rb.html +1 -1
  28. data/doc/rdoc/files/lib/serverside/core_ext_rb.html +1 -1
  29. data/doc/rdoc/files/lib/serverside/daemon_rb.html +1 -1
  30. data/doc/rdoc/files/lib/serverside/routing_rb.html +101 -0
  31. data/doc/rdoc/files/lib/serverside/static_rb.html +1 -1
  32. data/doc/rdoc/fr_class_index.html +3 -1
  33. data/doc/rdoc/fr_file_index.html +1 -0
  34. data/doc/rdoc/fr_method_index.html +49 -33
  35. data/lib/serverside/application.rb +17 -4
  36. data/lib/serverside/connection.rb +23 -3
  37. data/lib/serverside/core_ext.rb +16 -1
  38. data/lib/serverside/routing.rb +119 -0
  39. data/lib/serverside/static.rb +9 -23
  40. data/test/functional/routing_server.rb +14 -0
  41. data/test/functional/routing_server_test.rb +41 -0
  42. data/test/functional/static_server_test.rb +8 -2
  43. data/test/unit/connection_test.rb +13 -0
  44. data/test/unit/core_ext_test.rb +14 -0
  45. data/test/unit/routing_test.rb +171 -0
  46. data/test/unit/static_test.rb +34 -1
  47. metadata +10 -3
  48. data/doc/rdoc/classes/ServerSide/Connection/Static.html +0 -172
@@ -74,6 +74,10 @@
74
74
  <a href="../files/lib/serverside/static_rb.html">
75
75
  lib/serverside/static.rb
76
76
  </a>
77
+ <br />
78
+ <a href="../files/lib/serverside/routing_rb.html">
79
+ lib/serverside/routing.rb
80
+ </a>
77
81
  <br />
78
82
  </td>
79
83
  </tr>
@@ -122,6 +126,14 @@ and streaming.
122
126
 
123
127
  </div>
124
128
 
129
+ <div id="method-list">
130
+ <h3 class="section-bar">Methods</h3>
131
+
132
+ <div class="name-list">
133
+ <a href="#M000022">route</a>&nbsp;&nbsp;
134
+ <a href="#M000023">route_default</a>&nbsp;&nbsp;
135
+ </div>
136
+ </div>
125
137
 
126
138
  </div>
127
139
 
@@ -147,6 +159,63 @@ Class <a href="ServerSide/Server.html" class="link">ServerSide::Server</a><br />
147
159
 
148
160
 
149
161
  <!-- if method_list -->
162
+ <div id="methods">
163
+ <h3 class="section-bar">Public Class methods</h3>
164
+
165
+ <div id="method-M000022" class="method-detail">
166
+ <a name="M000022"></a>
167
+
168
+ <div class="method-heading">
169
+ <a href="#M000022" class="method-signature">
170
+ <span class="method-name">route</span><span class="method-args">(rule, &amp;block)</span>
171
+ </a>
172
+ </div>
173
+
174
+ <div class="method-description">
175
+ <p>
176
+ Adds a routing rule. This is a convenience method.
177
+ </p>
178
+ <p><a class="source-toggle" href="#"
179
+ onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
180
+ <div class="method-source-code" id="M000022-source">
181
+ <pre>
182
+ <span class="ruby-comment cmt"># File lib/serverside/routing.rb, line 111</span>
183
+ 111: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">route</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
184
+ 112: <span class="ruby-constant">Connection</span><span class="ruby-operator">::</span><span class="ruby-constant">Router</span>.<span class="ruby-identifier">route</span>(<span class="ruby-identifier">rule</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
185
+ 113: <span class="ruby-keyword kw">end</span>
186
+ </pre>
187
+ </div>
188
+ </div>
189
+ </div>
190
+
191
+ <div id="method-M000023" class="method-detail">
192
+ <a name="M000023"></a>
193
+
194
+ <div class="method-heading">
195
+ <a href="#M000023" class="method-signature">
196
+ <span class="method-name">route_default</span><span class="method-args">(&amp;block)</span>
197
+ </a>
198
+ </div>
199
+
200
+ <div class="method-description">
201
+ <p>
202
+ Sets the default request handler. This is a convenience method.
203
+ </p>
204
+ <p><a class="source-toggle" href="#"
205
+ onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
206
+ <div class="method-source-code" id="M000023-source">
207
+ <pre>
208
+ <span class="ruby-comment cmt"># File lib/serverside/routing.rb, line 116</span>
209
+ 116: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">route_default</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
210
+ 117: <span class="ruby-constant">Connection</span><span class="ruby-operator">::</span><span class="ruby-constant">Router</span>.<span class="ruby-identifier">route_default</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
211
+ 118: <span class="ruby-keyword kw">end</span>
212
+ </pre>
213
+ </div>
214
+ </div>
215
+ </div>
216
+
217
+
218
+ </div>
150
219
 
151
220
 
152
221
  </div>
@@ -80,7 +80,8 @@
80
80
  <h3 class="section-bar">Methods</h3>
81
81
 
82
82
  <div class="name-list">
83
- <a href="#M000022">daemonize</a>&nbsp;&nbsp;
83
+ <a href="#M000027">config=</a>&nbsp;&nbsp;
84
+ <a href="#M000028">daemonize</a>&nbsp;&nbsp;
84
85
  </div>
85
86
  </div>
86
87
 
@@ -109,24 +110,55 @@ Class <a href="Application/Static.html" class="link">ServerSide::Application::St
109
110
  <div id="methods">
110
111
  <h3 class="section-bar">Public Class methods</h3>
111
112
 
112
- <div id="method-M000022" class="method-detail">
113
- <a name="M000022"></a>
113
+ <div id="method-M000027" class="method-detail">
114
+ <a name="M000027"></a>
114
115
 
115
116
  <div class="method-heading">
116
- <a href="#M000022" class="method-signature">
117
- <span class="method-name">daemonize</span><span class="method-args">()</span>
117
+ <a href="#M000027" class="method-signature">
118
+ <span class="method-name">config=</span><span class="method-args">(c)</span>
118
119
  </a>
119
120
  </div>
120
121
 
121
122
  <div class="method-description">
122
123
  <p><a class="source-toggle" href="#"
123
- onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
124
- <div class="method-source-code" id="M000022-source">
124
+ onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
125
+ <div class="method-source-code" id="M000027-source">
125
126
  <pre>
126
- <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 36</span>
127
- 36: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">daemonize</span>
128
- 37:
129
- 38: <span class="ruby-keyword kw">end</span>
127
+ <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 9</span>
128
+ 9: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">config=</span>(<span class="ruby-identifier">c</span>)
129
+ 10: <span class="ruby-ivar">@@config</span> = <span class="ruby-identifier">c</span>
130
+ 11: <span class="ruby-keyword kw">end</span>
131
+ </pre>
132
+ </div>
133
+ </div>
134
+ </div>
135
+
136
+ <div id="method-M000028" class="method-detail">
137
+ <a name="M000028"></a>
138
+
139
+ <div class="method-heading">
140
+ <a href="#M000028" class="method-signature">
141
+ <span class="method-name">daemonize</span><span class="method-args">(config, cmd)</span>
142
+ </a>
143
+ </div>
144
+
145
+ <div class="method-description">
146
+ <p><a class="source-toggle" href="#"
147
+ onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
148
+ <div class="method-source-code" id="M000028-source">
149
+ <pre>
150
+ <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 13</span>
151
+ 13: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">daemonize</span>(<span class="ruby-identifier">config</span>, <span class="ruby-identifier">cmd</span>)
152
+ 14: <span class="ruby-identifier">config</span> = <span class="ruby-ivar">@@config</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">config</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@@config</span>
153
+ 15: <span class="ruby-identifier">daemon_class</span> = <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Daemon</span><span class="ruby-operator">::</span><span class="ruby-constant">Cluster</span>) <span class="ruby-keyword kw">do</span>
154
+ 16: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:pid_fn</span>) {<span class="ruby-constant">Daemon</span><span class="ruby-operator">::</span><span class="ruby-constant">WorkingDirectory</span><span class="ruby-operator">/</span><span class="ruby-value str">'serverside.pid'</span>}
155
+ 17: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:server_loop</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">port</span><span class="ruby-operator">|</span>
156
+ 18: <span class="ruby-constant">ServerSide</span><span class="ruby-operator">::</span><span class="ruby-constant">Server</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">config</span>[<span class="ruby-identifier">:host</span>], <span class="ruby-identifier">port</span>, <span class="ruby-constant">ServerSide</span><span class="ruby-operator">::</span><span class="ruby-constant">Connection</span><span class="ruby-operator">::</span><span class="ruby-constant">Router</span>)
157
+ 19: <span class="ruby-keyword kw">end</span>
158
+ 20: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:ports</span>) {<span class="ruby-identifier">config</span>[<span class="ruby-identifier">:ports</span>]}
159
+ 21: <span class="ruby-keyword kw">end</span>
160
+ 22: <span class="ruby-constant">Daemon</span>.<span class="ruby-identifier">control</span>(<span class="ruby-identifier">daemon_class</span>, <span class="ruby-identifier">cmd</span>)
161
+ 23: <span class="ruby-keyword kw">end</span>
130
162
  </pre>
131
163
  </div>
132
164
  </div>
@@ -88,9 +88,9 @@
88
88
  <h3 class="section-bar">Methods</h3>
89
89
 
90
90
  <div class="name-list">
91
- <a href="#M000024">configuration</a>&nbsp;&nbsp;
92
- <a href="#M000023">configure</a>&nbsp;&nbsp;
93
- <a href="#M000025">new</a>&nbsp;&nbsp;
91
+ <a href="#M000030">configuration</a>&nbsp;&nbsp;
92
+ <a href="#M000029">configure</a>&nbsp;&nbsp;
93
+ <a href="#M000031">new</a>&nbsp;&nbsp;
94
94
  </div>
95
95
  </div>
96
96
 
@@ -112,70 +112,70 @@
112
112
  <div id="methods">
113
113
  <h3 class="section-bar">Public Class methods</h3>
114
114
 
115
- <div id="method-M000024" class="method-detail">
116
- <a name="M000024"></a>
115
+ <div id="method-M000030" class="method-detail">
116
+ <a name="M000030"></a>
117
117
 
118
118
  <div class="method-heading">
119
- <a href="#M000024" class="method-signature">
119
+ <a href="#M000030" class="method-signature">
120
120
  <span class="method-name">configuration</span><span class="method-args">()</span>
121
121
  </a>
122
122
  </div>
123
123
 
124
124
  <div class="method-description">
125
125
  <p><a class="source-toggle" href="#"
126
- onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
127
- <div class="method-source-code" id="M000024-source">
126
+ onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
127
+ <div class="method-source-code" id="M000030-source">
128
128
  <pre>
129
- <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 13</span>
130
- 13: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">configuration</span>
131
- 14: <span class="ruby-ivar">@config</span>
132
- 15: <span class="ruby-keyword kw">end</span>
129
+ <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 30</span>
130
+ 30: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">configuration</span>
131
+ 31: <span class="ruby-ivar">@config</span>
132
+ 32: <span class="ruby-keyword kw">end</span>
133
133
  </pre>
134
134
  </div>
135
135
  </div>
136
136
  </div>
137
137
 
138
- <div id="method-M000023" class="method-detail">
139
- <a name="M000023"></a>
138
+ <div id="method-M000029" class="method-detail">
139
+ <a name="M000029"></a>
140
140
 
141
141
  <div class="method-heading">
142
- <a href="#M000023" class="method-signature">
142
+ <a href="#M000029" class="method-signature">
143
143
  <span class="method-name">configure</span><span class="method-args">(options)</span>
144
144
  </a>
145
145
  </div>
146
146
 
147
147
  <div class="method-description">
148
148
  <p><a class="source-toggle" href="#"
149
- onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
150
- <div class="method-source-code" id="M000023-source">
149
+ onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
150
+ <div class="method-source-code" id="M000029-source">
151
151
  <pre>
152
- <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 9</span>
153
- 9: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">configure</span>(<span class="ruby-identifier">options</span>)
154
- 10: <span class="ruby-ivar">@config</span> = <span class="ruby-identifier">options</span>
155
- 11: <span class="ruby-keyword kw">end</span>
152
+ <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 26</span>
153
+ 26: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">configure</span>(<span class="ruby-identifier">options</span>)
154
+ 27: <span class="ruby-ivar">@config</span> = <span class="ruby-identifier">options</span>
155
+ 28: <span class="ruby-keyword kw">end</span>
156
156
  </pre>
157
157
  </div>
158
158
  </div>
159
159
  </div>
160
160
 
161
- <div id="method-M000025" class="method-detail">
162
- <a name="M000025"></a>
161
+ <div id="method-M000031" class="method-detail">
162
+ <a name="M000031"></a>
163
163
 
164
164
  <div class="method-heading">
165
- <a href="#M000025" class="method-signature">
165
+ <a href="#M000031" class="method-signature">
166
166
  <span class="method-name">new</span><span class="method-args">(host, port)</span>
167
167
  </a>
168
168
  </div>
169
169
 
170
170
  <div class="method-description">
171
171
  <p><a class="source-toggle" href="#"
172
- onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
173
- <div class="method-source-code" id="M000025-source">
172
+ onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
173
+ <div class="method-source-code" id="M000031-source">
174
174
  <pre>
175
- <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 17</span>
176
- 17: <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>)
177
- 18: <span class="ruby-constant">ServerSide</span><span class="ruby-operator">::</span><span class="ruby-constant">Server</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">make_request_class</span>)
178
- 19: <span class="ruby-keyword kw">end</span>
175
+ <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 34</span>
176
+ 34: <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>)
177
+ 35: <span class="ruby-constant">ServerSide</span><span class="ruby-operator">::</span><span class="ruby-constant">Server</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">make_request_class</span>)
178
+ 36: <span class="ruby-keyword kw">end</span>
179
179
  </pre>
180
180
  </div>
181
181
  </div>
@@ -65,7 +65,9 @@
65
65
  <tr class="top-aligned-row">
66
66
  <td><strong>Parent:</strong></td>
67
67
  <td>
68
+ <a href="../../Object.html">
68
69
  Object
70
+ </a>
69
71
  </td>
70
72
  </tr>
71
73
  </table>
@@ -86,7 +88,7 @@
86
88
  <h3 class="section-bar">Methods</h3>
87
89
 
88
90
  <div class="name-list">
89
- <a href="#M000026">daemonize</a>&nbsp;&nbsp;
91
+ <a href="#M000032">daemonize</a>&nbsp;&nbsp;
90
92
  </div>
91
93
  </div>
92
94
 
@@ -108,32 +110,32 @@
108
110
  <div id="methods">
109
111
  <h3 class="section-bar">Public Class methods</h3>
110
112
 
111
- <div id="method-M000026" class="method-detail">
112
- <a name="M000026"></a>
113
+ <div id="method-M000032" class="method-detail">
114
+ <a name="M000032"></a>
113
115
 
114
116
  <div class="method-heading">
115
- <a href="#M000026" class="method-signature">
117
+ <a href="#M000032" class="method-signature">
116
118
  <span class="method-name">daemonize</span><span class="method-args">(config, cmd)</span>
117
119
  </a>
118
120
  </div>
119
121
 
120
122
  <div class="method-description">
121
123
  <p><a class="source-toggle" href="#"
122
- onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
123
- <div class="method-source-code" id="M000026-source">
124
+ onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
125
+ <div class="method-source-code" id="M000032-source">
124
126
  <pre>
125
- <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 23</span>
126
- 23: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">daemonize</span>(<span class="ruby-identifier">config</span>, <span class="ruby-identifier">cmd</span>)
127
- 24: <span class="ruby-identifier">daemon_class</span> = <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Daemon</span><span class="ruby-operator">::</span><span class="ruby-constant">Cluster</span>) <span class="ruby-keyword kw">do</span>
128
- 25: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:pid_fn</span>) {<span class="ruby-constant">Daemon</span><span class="ruby-operator">::</span><span class="ruby-constant">WorkingDirectory</span><span class="ruby-operator">/</span><span class="ruby-value str">'serverside.pid'</span>}
129
- 26: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:server_loop</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">port</span><span class="ruby-operator">|</span>
130
- 27: <span class="ruby-constant">ServerSide</span><span class="ruby-operator">::</span><span class="ruby-constant">Server</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">config</span>[<span class="ruby-identifier">:host</span>], <span class="ruby-identifier">port</span>, <span class="ruby-constant">ServerSide</span><span class="ruby-operator">::</span><span class="ruby-constant">Connection</span><span class="ruby-operator">::</span><span class="ruby-constant">Static</span>)
131
- 28: <span class="ruby-keyword kw">end</span>
132
- 29: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:ports</span>) {<span class="ruby-identifier">$cmd_config</span>[<span class="ruby-identifier">:ports</span>]}
133
- 30: <span class="ruby-keyword kw">end</span>
134
- 31:
135
- 32: <span class="ruby-constant">Daemon</span>.<span class="ruby-identifier">control</span>(<span class="ruby-identifier">daemon_class</span>, <span class="ruby-identifier">cmd</span>)
136
- 33: <span class="ruby-keyword kw">end</span>
127
+ <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 40</span>
128
+ 40: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">daemonize</span>(<span class="ruby-identifier">config</span>, <span class="ruby-identifier">cmd</span>)
129
+ 41: <span class="ruby-identifier">daemon_class</span> = <span class="ruby-constant">Class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Daemon</span><span class="ruby-operator">::</span><span class="ruby-constant">Cluster</span>) <span class="ruby-keyword kw">do</span>
130
+ 42: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:pid_fn</span>) {<span class="ruby-constant">Daemon</span><span class="ruby-operator">::</span><span class="ruby-constant">WorkingDirectory</span><span class="ruby-operator">/</span><span class="ruby-value str">'serverside.pid'</span>}
131
+ 43: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:server_loop</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">port</span><span class="ruby-operator">|</span>
132
+ 44: <span class="ruby-constant">ServerSide</span><span class="ruby-operator">::</span><span class="ruby-constant">Server</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">config</span>[<span class="ruby-identifier">:host</span>], <span class="ruby-identifier">port</span>, <span class="ruby-constant">ServerSide</span><span class="ruby-operator">::</span><span class="ruby-constant">Connection</span><span class="ruby-operator">::</span><span class="ruby-constant">Static</span>)
133
+ 45: <span class="ruby-keyword kw">end</span>
134
+ 46: <span class="ruby-identifier">meta_def</span>(<span class="ruby-identifier">:ports</span>) {<span class="ruby-identifier">$cmd_config</span>[<span class="ruby-identifier">:ports</span>]}
135
+ 47: <span class="ruby-keyword kw">end</span>
136
+ 48:
137
+ 49: <span class="ruby-constant">Daemon</span>.<span class="ruby-identifier">control</span>(<span class="ruby-identifier">daemon_class</span>, <span class="ruby-identifier">cmd</span>)
138
+ 50: <span class="ruby-keyword kw">end</span>
137
139
  </pre>
138
140
  </div>
139
141
  </div>
@@ -59,8 +59,8 @@
59
59
  lib/serverside/connection.rb
60
60
  </a>
61
61
  <br />
62
- <a href="../../files/lib/serverside/static_rb.html">
63
- lib/serverside/static.rb
62
+ <a href="../../files/lib/serverside/routing_rb.html">
63
+ lib/serverside/routing.rb
64
64
  </a>
65
65
  <br />
66
66
  </td>
@@ -104,7 +104,7 @@ connection.
104
104
 
105
105
  Module <a href="Connection/Const.html" class="link">ServerSide::Connection::Const</a><br />
106
106
  Class <a href="Connection/Base.html" class="link">ServerSide::Connection::Base</a><br />
107
- Class <a href="Connection/Static.html" class="link">ServerSide::Connection::Static</a><br />
107
+ Class <a href="Connection/Router.html" class="link">ServerSide::Connection::Router</a><br />
108
108
 
109
109
  </div>
110
110
 
@@ -65,7 +65,9 @@
65
65
  <tr class="top-aligned-row">
66
66
  <td><strong>Parent:</strong></td>
67
67
  <td>
68
+ <a href="../../Object.html">
68
69
  Object
70
+ </a>
69
71
  </td>
70
72
  </tr>
71
73
  </table>
@@ -97,12 +99,13 @@ create application-specific behavior.
97
99
  <h3 class="section-bar">Methods</h3>
98
100
 
99
101
  <div class="name-list">
100
- <a href="#M000027">new</a>&nbsp;&nbsp;
101
- <a href="#M000030">parse_parameters</a>&nbsp;&nbsp;
102
- <a href="#M000029">parse_request</a>&nbsp;&nbsp;
103
- <a href="#M000028">process</a>&nbsp;&nbsp;
104
- <a href="#M000031">send_response</a>&nbsp;&nbsp;
105
- <a href="#M000032">stream</a>&nbsp;&nbsp;
102
+ <a href="#M000033">new</a>&nbsp;&nbsp;
103
+ <a href="#M000036">parse_parameters</a>&nbsp;&nbsp;
104
+ <a href="#M000035">parse_request</a>&nbsp;&nbsp;
105
+ <a href="#M000034">process</a>&nbsp;&nbsp;
106
+ <a href="#M000038">redirect</a>&nbsp;&nbsp;
107
+ <a href="#M000037">send_response</a>&nbsp;&nbsp;
108
+ <a href="#M000039">stream</a>&nbsp;&nbsp;
106
109
  </div>
107
110
  </div>
108
111
 
@@ -110,6 +113,13 @@ create application-specific behavior.
110
113
 
111
114
 
112
115
  <!-- if includes -->
116
+ <div id="includes">
117
+ <h3 class="section-bar">Included Modules</h3>
118
+
119
+ <div id="includes-list">
120
+ <span class="include-name"><a href="../StaticFiles.html">StaticFiles</a></span>
121
+ </div>
122
+ </div>
113
123
 
114
124
  <div id="section">
115
125
 
@@ -124,11 +134,11 @@ create application-specific behavior.
124
134
  <div id="methods">
125
135
  <h3 class="section-bar">Public Class methods</h3>
126
136
 
127
- <div id="method-M000027" class="method-detail">
128
- <a name="M000027"></a>
137
+ <div id="method-M000033" class="method-detail">
138
+ <a name="M000033"></a>
129
139
 
130
140
  <div class="method-heading">
131
- <a href="#M000027" class="method-signature">
141
+ <a href="#M000033" class="method-signature">
132
142
  <span class="method-name">new</span><span class="method-args">(conn)</span>
133
143
  </a>
134
144
  </div>
@@ -139,14 +149,14 @@ Initializes the request instance. A new thread is created for processing
139
149
  requests.
140
150
  </p>
141
151
  <p><a class="source-toggle" href="#"
142
- onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
143
- <div class="method-source-code" id="M000027-source">
152
+ onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
153
+ <div class="method-source-code" id="M000033-source">
144
154
  <pre>
145
- <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 40</span>
146
- 40: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">conn</span>)
147
- 41: <span class="ruby-ivar">@conn</span> = <span class="ruby-identifier">conn</span>
148
- 42: <span class="ruby-ivar">@thread</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> {<span class="ruby-identifier">process</span>}
149
- 43: <span class="ruby-keyword kw">end</span>
155
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 48</span>
156
+ 48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">conn</span>)
157
+ 49: <span class="ruby-ivar">@conn</span> = <span class="ruby-identifier">conn</span>
158
+ 50: <span class="ruby-ivar">@thread</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> {<span class="ruby-identifier">process</span>}
159
+ 51: <span class="ruby-keyword kw">end</span>
150
160
  </pre>
151
161
  </div>
152
162
  </div>
@@ -154,11 +164,11 @@ requests.
154
164
 
155
165
  <h3 class="section-bar">Public Instance methods</h3>
156
166
 
157
- <div id="method-M000030" class="method-detail">
158
- <a name="M000030"></a>
167
+ <div id="method-M000036" class="method-detail">
168
+ <a name="M000036"></a>
159
169
 
160
170
  <div class="method-heading">
161
- <a href="#M000030" class="method-signature">
171
+ <a href="#M000036" class="method-signature">
162
172
  <span class="method-name">parse_parameters</span><span class="method-args">(query)</span>
163
173
  </a>
164
174
  </div>
@@ -169,28 +179,28 @@ Parses query parameters by splitting the query string and unescaping
169
179
  parameter values.
170
180
  </p>
171
181
  <p><a class="source-toggle" href="#"
172
- onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
173
- <div class="method-source-code" id="M000030-source">
182
+ onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
183
+ <div class="method-source-code" id="M000036-source">
174
184
  <pre>
175
- <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 82</span>
176
- 82: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_parameters</span>(<span class="ruby-identifier">query</span>)
177
- 83: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">split</span>(<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Ampersand</span>).<span class="ruby-identifier">inject</span>({}) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">m</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
178
- 84: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">ParameterRegexp</span>
179
- 85: <span class="ruby-identifier">m</span>[<span class="ruby-identifier">$1</span>.<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">uri_unescape</span>
180
- 86: <span class="ruby-keyword kw">end</span>
181
- 87: <span class="ruby-identifier">m</span>
182
- 88: <span class="ruby-keyword kw">end</span>
183
- 89: <span class="ruby-keyword kw">end</span>
185
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 94</span>
186
+ 94: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_parameters</span>(<span class="ruby-identifier">query</span>)
187
+ 95: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">split</span>(<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Ampersand</span>).<span class="ruby-identifier">inject</span>({}) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">m</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
188
+ 96: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">ParameterRegexp</span>
189
+ 97: <span class="ruby-identifier">m</span>[<span class="ruby-identifier">$1</span>.<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">uri_unescape</span>
190
+ 98: <span class="ruby-keyword kw">end</span>
191
+ 99: <span class="ruby-identifier">m</span>
192
+ 100: <span class="ruby-keyword kw">end</span>
193
+ 101: <span class="ruby-keyword kw">end</span>
184
194
  </pre>
185
195
  </div>
186
196
  </div>
187
197
  </div>
188
198
 
189
- <div id="method-M000029" class="method-detail">
190
- <a name="M000029"></a>
199
+ <div id="method-M000035" class="method-detail">
200
+ <a name="M000035"></a>
191
201
 
192
202
  <div class="method-heading">
193
- <a href="#M000029" class="method-signature">
203
+ <a href="#M000035" class="method-signature">
194
204
  <span class="method-name">parse_request</span><span class="method-args">()</span>
195
205
  </a>
196
206
  </div>
@@ -203,35 +213,35 @@ connection is persistent (by checking the HTTP version and the &#8216;<a
203
213
  href="../Connection.html">Connection</a>&#8217; header).
204
214
  </p>
205
215
  <p><a class="source-toggle" href="#"
206
- onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
207
- <div class="method-source-code" id="M000029-source">
216
+ onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
217
+ <div class="method-source-code" id="M000035-source">
208
218
  <pre>
209
- <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 64</span>
210
- 64: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_request</span>
211
- 65: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@conn</span>.<span class="ruby-identifier">gets</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">RequestRegexp</span>
212
- 66: <span class="ruby-ivar">@method</span>, <span class="ruby-ivar">@path</span>, <span class="ruby-ivar">@query</span>, <span class="ruby-ivar">@version</span> = <span class="ruby-identifier">$1</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-identifier">$2</span>, <span class="ruby-identifier">$5</span>, <span class="ruby-identifier">$6</span>
213
- 67: <span class="ruby-ivar">@parameters</span> = <span class="ruby-ivar">@query</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">parse_parameters</span>(<span class="ruby-ivar">@query</span>) <span class="ruby-operator">:</span> {}
214
- 68: <span class="ruby-ivar">@headers</span> = {}
215
- 69: <span class="ruby-keyword kw">while</span> (<span class="ruby-identifier">line</span> = <span class="ruby-ivar">@conn</span>.<span class="ruby-identifier">gets</span>)
216
- 70: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">line</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">LineBreak</span>)
217
- 71: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HeaderRegexp</span>
218
- 72: <span class="ruby-ivar">@headers</span>[<span class="ruby-identifier">$1</span>.<span class="ruby-identifier">freeze</span>] = <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">freeze</span>
219
- 73: <span class="ruby-keyword kw">end</span>
220
- 74: <span class="ruby-keyword kw">end</span>
221
- 75: <span class="ruby-ivar">@persistent</span> = (<span class="ruby-ivar">@version</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Version_1_1</span>) <span class="ruby-operator">&amp;&amp;</span>
222
- 76: (<span class="ruby-ivar">@headers</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Connection</span>] <span class="ruby-operator">!=</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Close</span>)
223
- 77: <span class="ruby-ivar">@headers</span>
224
- 78: <span class="ruby-keyword kw">end</span>
219
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 76</span>
220
+ 76: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_request</span>
221
+ 77: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@conn</span>.<span class="ruby-identifier">gets</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">RequestRegexp</span>
222
+ 78: <span class="ruby-ivar">@method</span>, <span class="ruby-ivar">@path</span>, <span class="ruby-ivar">@query</span>, <span class="ruby-ivar">@version</span> = <span class="ruby-identifier">$1</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">to_sym</span>, <span class="ruby-identifier">$2</span>, <span class="ruby-identifier">$3</span>, <span class="ruby-identifier">$4</span>
223
+ 79: <span class="ruby-ivar">@parameters</span> = <span class="ruby-ivar">@query</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">parse_parameters</span>(<span class="ruby-ivar">@query</span>) <span class="ruby-operator">:</span> {}
224
+ 80: <span class="ruby-ivar">@headers</span> = {}
225
+ 81: <span class="ruby-keyword kw">while</span> (<span class="ruby-identifier">line</span> = <span class="ruby-ivar">@conn</span>.<span class="ruby-identifier">gets</span>)
226
+ 82: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">line</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">LineBreak</span>)
227
+ 83: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HeaderRegexp</span>
228
+ 84: <span class="ruby-ivar">@headers</span>[<span class="ruby-identifier">$1</span>.<span class="ruby-identifier">freeze</span>] = <span class="ruby-identifier">$2</span>.<span class="ruby-identifier">freeze</span>
229
+ 85: <span class="ruby-keyword kw">end</span>
230
+ 86: <span class="ruby-keyword kw">end</span>
231
+ 87: <span class="ruby-ivar">@persistent</span> = (<span class="ruby-ivar">@version</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Version_1_1</span>) <span class="ruby-operator">&amp;&amp;</span>
232
+ 88: (<span class="ruby-ivar">@headers</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Connection</span>] <span class="ruby-operator">!=</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Close</span>)
233
+ 89: <span class="ruby-ivar">@headers</span>
234
+ 90: <span class="ruby-keyword kw">end</span>
225
235
  </pre>
226
236
  </div>
227
237
  </div>
228
238
  </div>
229
239
 
230
- <div id="method-M000028" class="method-detail">
231
- <a name="M000028"></a>
240
+ <div id="method-M000034" class="method-detail">
241
+ <a name="M000034"></a>
232
242
 
233
243
  <div class="method-heading">
234
- <a href="#M000028" class="method-signature">
244
+ <a href="#M000034" class="method-signature">
235
245
  <span class="method-name">process</span><span class="method-args">()</span>
236
246
  </a>
237
247
  </div>
@@ -243,31 +253,64 @@ error occurs, or the connection is not persistent, the connection is
243
253
  closed.
244
254
  </p>
245
255
  <p><a class="source-toggle" href="#"
246
- onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
247
- <div class="method-source-code" id="M000028-source">
256
+ onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
257
+ <div class="method-source-code" id="M000034-source">
248
258
  <pre>
249
- <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 48</span>
250
- 48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>
251
- 49: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
252
- 50: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">parse_request</span>
253
- 51: <span class="ruby-identifier">respond</span>
254
- 52: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@persistent</span>
255
- 53: <span class="ruby-keyword kw">end</span>
256
- 54: <span class="ruby-keyword kw">rescue</span>
257
- 55: <span class="ruby-comment cmt"># We don't care. Just close the connection.</span>
258
- 56: <span class="ruby-keyword kw">ensure</span>
259
- 57: <span class="ruby-ivar">@conn</span>.<span class="ruby-identifier">close</span>
260
- 58: <span class="ruby-keyword kw">end</span>
259
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 56</span>
260
+ 56: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>
261
+ 57: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
262
+ 58: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">parse_request</span>
263
+ 59: <span class="ruby-identifier">respond</span>
264
+ 60: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@persistent</span>
265
+ 61: <span class="ruby-keyword kw">end</span>
266
+ 62: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
267
+ 63: <span class="ruby-identifier">puts</span> <span class="ruby-value str">'*******************'</span>
268
+ 64: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>
269
+ 65: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">first</span>
270
+ 66: <span class="ruby-identifier">puts</span> <span class="ruby-value str">'*******************'</span>
271
+ 67: <span class="ruby-comment cmt"># We don't care. Just close the connection.</span>
272
+ 68: <span class="ruby-keyword kw">ensure</span>
273
+ 69: <span class="ruby-ivar">@conn</span>.<span class="ruby-identifier">close</span>
274
+ 70: <span class="ruby-keyword kw">end</span>
275
+ </pre>
276
+ </div>
277
+ </div>
278
+ </div>
279
+
280
+ <div id="method-M000038" class="method-detail">
281
+ <a name="M000038"></a>
282
+
283
+ <div class="method-heading">
284
+ <a href="#M000038" class="method-signature">
285
+ <span class="method-name">redirect</span><span class="method-args">(location, permanent = false)</span>
286
+ </a>
287
+ </div>
288
+
289
+ <div class="method-description">
290
+ <p>
291
+ Send a redirect response.
292
+ </p>
293
+ <p><a class="source-toggle" href="#"
294
+ onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
295
+ <div class="method-source-code" id="M000038-source">
296
+ <pre>
297
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 122</span>
298
+ 122: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">redirect</span>(<span class="ruby-identifier">location</span>, <span class="ruby-identifier">permanent</span> = <span class="ruby-keyword kw">false</span>)
299
+ 123: <span class="ruby-ivar">@conn</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">StatusRedirect</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">permanent</span> <span class="ruby-value">? </span><span class="ruby-value">301</span> <span class="ruby-operator">:</span> <span class="ruby-value">302</span>, <span class="ruby-identifier">location</span>])
300
+ 124: <span class="ruby-keyword kw">rescue</span>
301
+ 125: <span class="ruby-keyword kw">ensure</span>
302
+ 126: <span class="ruby-ivar">@persistent</span> = <span class="ruby-keyword kw">false</span>
303
+ 127: <span class="ruby-keyword kw">end</span>
261
304
  </pre>
262
305
  </div>
263
306
  </div>
264
307
  </div>
265
308
 
266
- <div id="method-M000031" class="method-detail">
267
- <a name="M000031"></a>
309
+ <div id="method-M000037" class="method-detail">
310
+ <a name="M000037"></a>
268
311
 
269
312
  <div class="method-heading">
270
- <a href="#M000031" class="method-signature">
313
+ <a href="#M000037" class="method-signature">
271
314
  <span class="method-name">send_response</span><span class="method-args">(status, content_type, body = nil, content_length = nil, headers = nil)</span>
272
315
  </a>
273
316
  </div>
@@ -277,36 +320,36 @@ closed.
277
320
  Sends an HTTP response.
278
321
  </p>
279
322
  <p><a class="source-toggle" href="#"
280
- onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
281
- <div class="method-source-code" id="M000031-source">
323
+ onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
324
+ <div class="method-source-code" id="M000037-source">
282
325
  <pre>
283
- <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 92</span>
284
- 92: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_response</span>(<span class="ruby-identifier">status</span>, <span class="ruby-identifier">content_type</span>, <span class="ruby-identifier">body</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">content_length</span> = <span class="ruby-keyword kw">nil</span>,
285
- 93: <span class="ruby-identifier">headers</span> = <span class="ruby-keyword kw">nil</span>)
286
- 94: <span class="ruby-identifier">h</span> = <span class="ruby-identifier">headers</span> <span class="ruby-value">? </span>
287
- 95: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value str">''</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">m</span>, <span class="ruby-identifier">kv</span><span class="ruby-operator">|</span> <span class="ruby-identifier">m</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Header</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">kv</span>)} <span class="ruby-operator">:</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Empty</span>
288
- 96:
289
- 97: <span class="ruby-identifier">content_length</span> = <span class="ruby-identifier">body</span>.<span class="ruby-identifier">length</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">content_length</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">body</span>
290
- 98: <span class="ruby-ivar">@persistent</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">content_length</span>.<span class="ruby-identifier">nil?</span>
291
- 99:
292
- 100: <span class="ruby-comment cmt"># Select the right format to use according to circumstances.</span>
293
- 101: <span class="ruby-ivar">@conn</span> <span class="ruby-operator">&lt;&lt;</span> ((<span class="ruby-ivar">@persistent</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">StatusPersist</span> <span class="ruby-operator">:</span>
294
- 102: (<span class="ruby-identifier">body</span> <span class="ruby-value">? </span><span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">StatusClose</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">StatusStream</span>)) <span class="ruby-operator">%</span>
295
- 103: [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">content_type</span>, <span class="ruby-identifier">h</span>, <span class="ruby-identifier">content_length</span>])
296
- 104: <span class="ruby-ivar">@conn</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">body</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>
297
- 105: <span class="ruby-keyword kw">rescue</span>
298
- 106: <span class="ruby-ivar">@persistent</span> = <span class="ruby-keyword kw">false</span>
299
- 107: <span class="ruby-keyword kw">end</span>
326
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 104</span>
327
+ 104: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_response</span>(<span class="ruby-identifier">status</span>, <span class="ruby-identifier">content_type</span>, <span class="ruby-identifier">body</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">content_length</span> = <span class="ruby-keyword kw">nil</span>,
328
+ 105: <span class="ruby-identifier">headers</span> = <span class="ruby-keyword kw">nil</span>)
329
+ 106: <span class="ruby-identifier">h</span> = <span class="ruby-identifier">headers</span> <span class="ruby-value">? </span>
330
+ 107: <span class="ruby-identifier">headers</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value str">''</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">m</span>, <span class="ruby-identifier">kv</span><span class="ruby-operator">|</span> <span class="ruby-identifier">m</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Header</span> <span class="ruby-operator">%</span> <span class="ruby-identifier">kv</span>)} <span class="ruby-operator">:</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Empty</span>
331
+ 108:
332
+ 109: <span class="ruby-identifier">content_length</span> = <span class="ruby-identifier">body</span>.<span class="ruby-identifier">length</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">content_length</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">body</span>
333
+ 110: <span class="ruby-ivar">@persistent</span> = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">content_length</span>.<span class="ruby-identifier">nil?</span>
334
+ 111:
335
+ 112: <span class="ruby-comment cmt"># Select the right format to use according to circumstances.</span>
336
+ 113: <span class="ruby-ivar">@conn</span> <span class="ruby-operator">&lt;&lt;</span> ((<span class="ruby-ivar">@persistent</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">StatusPersist</span> <span class="ruby-operator">:</span>
337
+ 114: (<span class="ruby-identifier">body</span> <span class="ruby-value">? </span><span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">StatusClose</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">StatusStream</span>)) <span class="ruby-operator">%</span>
338
+ 115: [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">content_type</span>, <span class="ruby-identifier">h</span>, <span class="ruby-identifier">content_length</span>])
339
+ 116: <span class="ruby-ivar">@conn</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">body</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>
340
+ 117: <span class="ruby-keyword kw">rescue</span>
341
+ 118: <span class="ruby-ivar">@persistent</span> = <span class="ruby-keyword kw">false</span>
342
+ 119: <span class="ruby-keyword kw">end</span>
300
343
  </pre>
301
344
  </div>
302
345
  </div>
303
346
  </div>
304
347
 
305
- <div id="method-M000032" class="method-detail">
306
- <a name="M000032"></a>
348
+ <div id="method-M000039" class="method-detail">
349
+ <a name="M000039"></a>
307
350
 
308
351
  <div class="method-heading">
309
- <a href="#M000032" class="method-signature">
352
+ <a href="#M000039" class="method-signature">
310
353
  <span class="method-name">stream</span><span class="method-args">(body)</span>
311
354
  </a>
312
355
  </div>
@@ -316,13 +359,13 @@ Sends an HTTP response.
316
359
  Streams additional data to the client.
317
360
  </p>
318
361
  <p><a class="source-toggle" href="#"
319
- onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
320
- <div class="method-source-code" id="M000032-source">
362
+ onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
363
+ <div class="method-source-code" id="M000039-source">
321
364
  <pre>
322
- <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 110</span>
323
- 110: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stream</span>(<span class="ruby-identifier">body</span>)
324
- 111: (<span class="ruby-ivar">@conn</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">body</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>) <span class="ruby-keyword kw">rescue</span> (<span class="ruby-ivar">@persistent</span> = <span class="ruby-keyword kw">false</span>)
325
- 112: <span class="ruby-keyword kw">end</span>
365
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 130</span>
366
+ 130: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stream</span>(<span class="ruby-identifier">body</span>)
367
+ 131: (<span class="ruby-ivar">@conn</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">body</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">body</span>) <span class="ruby-keyword kw">rescue</span> (<span class="ruby-ivar">@persistent</span> = <span class="ruby-keyword kw">false</span>)
368
+ 132: <span class="ruby-keyword kw">end</span>
326
369
  </pre>
327
370
  </div>
328
371
  </div>