serverside 0.2.0 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/CHANGELOG +26 -0
  2. data/README +39 -22
  3. data/Rakefile +18 -2
  4. data/bin/serverside +21 -5
  5. data/doc/rdoc/classes/ServerSide/Application.html +12 -19
  6. data/doc/rdoc/classes/ServerSide/Connection/Base.html +203 -116
  7. data/doc/rdoc/classes/ServerSide/Connection/Const.html +35 -5
  8. data/doc/rdoc/classes/ServerSide/Connection/Router.html +107 -78
  9. data/doc/rdoc/classes/ServerSide/Server.html +1 -1
  10. data/doc/rdoc/classes/ServerSide/StaticFiles/Const.html +10 -0
  11. data/doc/rdoc/classes/ServerSide/StaticFiles.html +73 -43
  12. data/doc/rdoc/classes/ServerSide/Template.html +200 -0
  13. data/doc/rdoc/classes/ServerSide.html +13 -8
  14. data/doc/rdoc/created.rid +1 -1
  15. data/doc/rdoc/files/CHANGELOG.html +44 -1
  16. data/doc/rdoc/files/README.html +63 -35
  17. data/doc/rdoc/files/lib/serverside/application_rb.html +1 -1
  18. data/doc/rdoc/files/lib/serverside/connection_rb.html +1 -1
  19. data/doc/rdoc/files/lib/serverside/routing_rb.html +1 -1
  20. data/doc/rdoc/files/lib/serverside/server_rb.html +1 -1
  21. data/doc/rdoc/files/lib/serverside/static_rb.html +1 -1
  22. data/doc/rdoc/files/lib/serverside/template_rb.html +108 -0
  23. data/doc/rdoc/fr_class_index.html +1 -2
  24. data/doc/rdoc/fr_file_index.html +1 -0
  25. data/doc/rdoc/fr_method_index.html +18 -16
  26. data/lib/serverside/application.rb +0 -28
  27. data/lib/serverside/connection.rb +38 -12
  28. data/lib/serverside/routing.rb +23 -2
  29. data/lib/serverside/server.rb +1 -1
  30. data/lib/serverside/static.rb +12 -0
  31. data/lib/serverside/template.rb +36 -0
  32. data/test/functional/primitive_static_server_test.rb +26 -2
  33. data/test/functional/static_rfuzz.rb +3 -39
  34. data/test/spec/core_ext_spec.rb +68 -0
  35. data/test/unit/connection_test.rb +37 -1
  36. data/test/unit/template_test.rb +78 -0
  37. metadata +8 -6
  38. data/doc/rdoc/classes/ServerSide/Application/Base.html +0 -196
  39. data/doc/rdoc/classes/ServerSide/Application/Static.html +0 -156
  40. data/test/unit/application_test.rb +0 -16
@@ -99,13 +99,16 @@ create application-specific behavior.
99
99
  <h3 class="section-bar">Methods</h3>
100
100
 
101
101
  <div class="name-list">
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;
102
+ <a href="#M000039">delete_cookie</a>&nbsp;&nbsp;
103
+ <a href="#M000030">new</a>&nbsp;&nbsp;
104
+ <a href="#M000034">parse_cookies</a>&nbsp;&nbsp;
105
+ <a href="#M000033">parse_parameters</a>&nbsp;&nbsp;
106
+ <a href="#M000032">parse_request</a>&nbsp;&nbsp;
107
+ <a href="#M000031">process</a>&nbsp;&nbsp;
108
+ <a href="#M000036">redirect</a>&nbsp;&nbsp;
109
+ <a href="#M000035">send_response</a>&nbsp;&nbsp;
110
+ <a href="#M000038">set_cookie</a>&nbsp;&nbsp;
111
+ <a href="#M000037">stream</a>&nbsp;&nbsp;
109
112
  </div>
110
113
  </div>
111
114
 
@@ -134,11 +137,11 @@ create application-specific behavior.
134
137
  <div id="methods">
135
138
  <h3 class="section-bar">Public Class methods</h3>
136
139
 
137
- <div id="method-M000033" class="method-detail">
138
- <a name="M000033"></a>
140
+ <div id="method-M000030" class="method-detail">
141
+ <a name="M000030"></a>
139
142
 
140
143
  <div class="method-heading">
141
- <a href="#M000033" class="method-signature">
144
+ <a href="#M000030" class="method-signature">
142
145
  <span class="method-name">new</span><span class="method-args">(conn)</span>
143
146
  </a>
144
147
  </div>
@@ -149,14 +152,14 @@ Initializes the request instance. A new thread is created for processing
149
152
  requests.
150
153
  </p>
151
154
  <p><a class="source-toggle" href="#"
152
- onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
153
- <div class="method-source-code" id="M000033-source">
155
+ onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
156
+ <div class="method-source-code" id="M000030-source">
154
157
  <pre>
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>
158
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 54</span>
159
+ 54: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">conn</span>)
160
+ 55: <span class="ruby-ivar">@conn</span> = <span class="ruby-identifier">conn</span>
161
+ 56: <span class="ruby-ivar">@thread</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> {<span class="ruby-identifier">process</span>}
162
+ 57: <span class="ruby-keyword kw">end</span>
160
163
  </pre>
161
164
  </div>
162
165
  </div>
@@ -164,11 +167,69 @@ requests.
164
167
 
165
168
  <h3 class="section-bar">Public Instance methods</h3>
166
169
 
167
- <div id="method-M000036" class="method-detail">
168
- <a name="M000036"></a>
170
+ <div id="method-M000039" class="method-detail">
171
+ <a name="M000039"></a>
169
172
 
170
173
  <div class="method-heading">
171
- <a href="#M000036" class="method-signature">
174
+ <a href="#M000039" class="method-signature">
175
+ <span class="method-name">delete_cookie</span><span class="method-args">(name)</span>
176
+ </a>
177
+ </div>
178
+
179
+ <div class="method-description">
180
+ <p>
181
+ Marks a cookie as deleted. The cookie is given an expires stamp in the
182
+ past.
183
+ </p>
184
+ <p><a class="source-toggle" href="#"
185
+ onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
186
+ <div class="method-source-code" id="M000039-source">
187
+ <pre>
188
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 156</span>
189
+ 156: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_cookie</span>(<span class="ruby-identifier">name</span>)
190
+ 157: <span class="ruby-identifier">set_cookie</span>(<span class="ruby-identifier">name</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">CookieExpiredTime</span>)
191
+ 158: <span class="ruby-keyword kw">end</span>
192
+ </pre>
193
+ </div>
194
+ </div>
195
+ </div>
196
+
197
+ <div id="method-M000034" class="method-detail">
198
+ <a name="M000034"></a>
199
+
200
+ <div class="method-heading">
201
+ <a href="#M000034" class="method-signature">
202
+ <span class="method-name">parse_cookies</span><span class="method-args">()</span>
203
+ </a>
204
+ </div>
205
+
206
+ <div class="method-description">
207
+ <p>
208
+ Parses cookie values passed in the request
209
+ </p>
210
+ <p><a class="source-toggle" href="#"
211
+ onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
212
+ <div class="method-source-code" id="M000034-source">
213
+ <pre>
214
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 109</span>
215
+ 109: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_cookies</span>
216
+ 110: <span class="ruby-ivar">@headers</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Cookie</span>].<span class="ruby-identifier">split</span>(<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">CookieSplit</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>
217
+ 111: <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">CookieRegexp</span>
218
+ 112: <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>
219
+ 113: <span class="ruby-keyword kw">end</span>
220
+ 114: <span class="ruby-identifier">m</span>
221
+ 115: <span class="ruby-keyword kw">end</span>
222
+ 116: <span class="ruby-keyword kw">end</span>
223
+ </pre>
224
+ </div>
225
+ </div>
226
+ </div>
227
+
228
+ <div id="method-M000033" class="method-detail">
229
+ <a name="M000033"></a>
230
+
231
+ <div class="method-heading">
232
+ <a href="#M000033" class="method-signature">
172
233
  <span class="method-name">parse_parameters</span><span class="method-args">(query)</span>
173
234
  </a>
174
235
  </div>
@@ -179,28 +240,28 @@ Parses query parameters by splitting the query string and unescaping
179
240
  parameter values.
180
241
  </p>
181
242
  <p><a class="source-toggle" href="#"
182
- onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
183
- <div class="method-source-code" id="M000036-source">
243
+ onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
244
+ <div class="method-source-code" id="M000033-source">
184
245
  <pre>
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>
246
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 99</span>
247
+ 99: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_parameters</span>(<span class="ruby-identifier">query</span>)
248
+ 100: <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>
249
+ 101: <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>
250
+ 102: <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>
251
+ 103: <span class="ruby-keyword kw">end</span>
252
+ 104: <span class="ruby-identifier">m</span>
253
+ 105: <span class="ruby-keyword kw">end</span>
254
+ 106: <span class="ruby-keyword kw">end</span>
194
255
  </pre>
195
256
  </div>
196
257
  </div>
197
258
  </div>
198
259
 
199
- <div id="method-M000035" class="method-detail">
200
- <a name="M000035"></a>
260
+ <div id="method-M000032" class="method-detail">
261
+ <a name="M000032"></a>
201
262
 
202
263
  <div class="method-heading">
203
- <a href="#M000035" class="method-signature">
264
+ <a href="#M000032" class="method-signature">
204
265
  <span class="method-name">parse_request</span><span class="method-args">()</span>
205
266
  </a>
206
267
  </div>
@@ -213,35 +274,38 @@ connection is persistent (by checking the HTTP version and the &#8216;<a
213
274
  href="../Connection.html">Connection</a>&#8217; header).
214
275
  </p>
215
276
  <p><a class="source-toggle" href="#"
216
- onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
217
- <div class="method-source-code" id="M000035-source">
277
+ onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
278
+ <div class="method-source-code" id="M000032-source">
218
279
  <pre>
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>
280
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 78</span>
281
+ 78: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">parse_request</span>
282
+ 79: <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>
283
+ 80: <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>
284
+ 81: <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> {}
285
+ 82: <span class="ruby-ivar">@headers</span> = {}
286
+ 83: <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>)
287
+ 84: <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>)
288
+ 85: <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>
289
+ 86: <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>
290
+ 87: <span class="ruby-keyword kw">end</span>
291
+ 88: <span class="ruby-keyword kw">end</span>
292
+ 89: <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>
293
+ 90: (<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>)
294
+ 91: <span class="ruby-ivar">@cookies</span> = <span class="ruby-ivar">@headers</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">Cookie</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">parse_cookies</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">EmptyHash</span>
295
+ 92: <span class="ruby-ivar">@response_cookies</span> = <span class="ruby-keyword kw">nil</span>
296
+ 93:
297
+ 94: <span class="ruby-ivar">@headers</span>
298
+ 95: <span class="ruby-keyword kw">end</span>
235
299
  </pre>
236
300
  </div>
237
301
  </div>
238
302
  </div>
239
303
 
240
- <div id="method-M000034" class="method-detail">
241
- <a name="M000034"></a>
304
+ <div id="method-M000031" class="method-detail">
305
+ <a name="M000031"></a>
242
306
 
243
307
  <div class="method-heading">
244
- <a href="#M000034" class="method-signature">
308
+ <a href="#M000031" class="method-signature">
245
309
  <span class="method-name">process</span><span class="method-args">()</span>
246
310
  </a>
247
311
  </div>
@@ -253,35 +317,31 @@ error occurs, or the connection is not persistent, the connection is
253
317
  closed.
254
318
  </p>
255
319
  <p><a class="source-toggle" href="#"
256
- onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
257
- <div class="method-source-code" id="M000034-source">
320
+ onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
321
+ <div class="method-source-code" id="M000031-source">
258
322
  <pre>
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>
323
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 62</span>
324
+ 62: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>
325
+ 63: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
326
+ 64: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">parse_request</span>
327
+ 65: <span class="ruby-identifier">respond</span>
328
+ 66: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@persistent</span>
329
+ 67: <span class="ruby-keyword kw">end</span>
330
+ 68: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
331
+ 69: <span class="ruby-comment cmt"># We don't care. Just close the connection.</span>
332
+ 70: <span class="ruby-keyword kw">ensure</span>
333
+ 71: <span class="ruby-ivar">@conn</span>.<span class="ruby-identifier">close</span>
334
+ 72: <span class="ruby-keyword kw">end</span>
275
335
  </pre>
276
336
  </div>
277
337
  </div>
278
338
  </div>
279
339
 
280
- <div id="method-M000038" class="method-detail">
281
- <a name="M000038"></a>
340
+ <div id="method-M000036" class="method-detail">
341
+ <a name="M000036"></a>
282
342
 
283
343
  <div class="method-heading">
284
- <a href="#M000038" class="method-signature">
344
+ <a href="#M000036" class="method-signature">
285
345
  <span class="method-name">redirect</span><span class="method-args">(location, permanent = false)</span>
286
346
  </a>
287
347
  </div>
@@ -291,26 +351,26 @@ closed.
291
351
  Send a redirect response.
292
352
  </p>
293
353
  <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">
354
+ onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
355
+ <div class="method-source-code" id="M000036-source">
296
356
  <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>
357
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 137</span>
358
+ 137: <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>)
359
+ 138: <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>])
360
+ 139: <span class="ruby-keyword kw">rescue</span>
361
+ 140: <span class="ruby-keyword kw">ensure</span>
362
+ 141: <span class="ruby-ivar">@persistent</span> = <span class="ruby-keyword kw">false</span>
363
+ 142: <span class="ruby-keyword kw">end</span>
304
364
  </pre>
305
365
  </div>
306
366
  </div>
307
367
  </div>
308
368
 
309
- <div id="method-M000037" class="method-detail">
310
- <a name="M000037"></a>
369
+ <div id="method-M000035" class="method-detail">
370
+ <a name="M000035"></a>
311
371
 
312
372
  <div class="method-heading">
313
- <a href="#M000037" class="method-signature">
373
+ <a href="#M000035" class="method-signature">
314
374
  <span class="method-name">send_response</span><span class="method-args">(status, content_type, body = nil, content_length = nil, headers = nil)</span>
315
375
  </a>
316
376
  </div>
@@ -320,36 +380,63 @@ Send a redirect response.
320
380
  Sends an HTTP response.
321
381
  </p>
322
382
  <p><a class="source-toggle" href="#"
323
- onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
324
- <div class="method-source-code" id="M000037-source">
383
+ onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
384
+ <div class="method-source-code" id="M000035-source">
325
385
  <pre>
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>
386
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 119</span>
387
+ 119: <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>,
388
+ 120: <span class="ruby-identifier">headers</span> = <span class="ruby-keyword kw">nil</span>)
389
+ 121: <span class="ruby-identifier">h</span> = <span class="ruby-identifier">headers</span> <span class="ruby-value">? </span>
390
+ 122: <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-value str">''</span>
391
+ 123:
392
+ 124: <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>
393
+ 125: <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>
394
+ 126:
395
+ 127: <span class="ruby-comment cmt"># Select the right format to use according to circumstances.</span>
396
+ 128: <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>
397
+ 129: (<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>
398
+ 130: [<span class="ruby-identifier">status</span>, <span class="ruby-identifier">content_type</span>, <span class="ruby-identifier">h</span>, <span class="ruby-ivar">@response_cookies</span>, <span class="ruby-identifier">content_length</span>])
399
+ 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>
400
+ 132: <span class="ruby-keyword kw">rescue</span>
401
+ 133: <span class="ruby-ivar">@persistent</span> = <span class="ruby-keyword kw">false</span>
402
+ 134: <span class="ruby-keyword kw">end</span>
343
403
  </pre>
344
404
  </div>
345
405
  </div>
346
406
  </div>
347
407
 
348
- <div id="method-M000039" class="method-detail">
349
- <a name="M000039"></a>
408
+ <div id="method-M000038" class="method-detail">
409
+ <a name="M000038"></a>
350
410
 
351
411
  <div class="method-heading">
352
- <a href="#M000039" class="method-signature">
412
+ <a href="#M000038" class="method-signature">
413
+ <span class="method-name">set_cookie</span><span class="method-args">(name, value, expires)</span>
414
+ </a>
415
+ </div>
416
+
417
+ <div class="method-description">
418
+ <p>
419
+ Sets a cookie to be included in the response.
420
+ </p>
421
+ <p><a class="source-toggle" href="#"
422
+ onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
423
+ <div class="method-source-code" id="M000038-source">
424
+ <pre>
425
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 150</span>
426
+ 150: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_cookie</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">expires</span>)
427
+ 151: <span class="ruby-ivar">@response_cookies</span> <span class="ruby-operator">||=</span> <span class="ruby-value str">&quot;&quot;</span>
428
+ 152: <span class="ruby-ivar">@response_cookies</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">SetCookie</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">uri_escape</span>, <span class="ruby-identifier">expires</span>.<span class="ruby-identifier">rfc2822</span>])
429
+ 153: <span class="ruby-keyword kw">end</span>
430
+ </pre>
431
+ </div>
432
+ </div>
433
+ </div>
434
+
435
+ <div id="method-M000037" class="method-detail">
436
+ <a name="M000037"></a>
437
+
438
+ <div class="method-heading">
439
+ <a href="#M000037" class="method-signature">
353
440
  <span class="method-name">stream</span><span class="method-args">(body)</span>
354
441
  </a>
355
442
  </div>
@@ -359,13 +446,13 @@ Sends an HTTP response.
359
446
  Streams additional data to the client.
360
447
  </p>
361
448
  <p><a class="source-toggle" href="#"
362
- onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
363
- <div class="method-source-code" id="M000039-source">
449
+ onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
450
+ <div class="method-source-code" id="M000037-source">
364
451
  <pre>
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>
452
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 145</span>
453
+ 145: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stream</span>(<span class="ruby-identifier">body</span>)
454
+ 146: (<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>)
455
+ 147: <span class="ruby-keyword kw">end</span>
369
456
  </pre>
370
457
  </div>
371
458
  </div>
@@ -167,17 +167,17 @@ Regexp for parsing URI parameters.
167
167
  <tr class="top-aligned-row context-row">
168
168
  <td class="context-item-name">StatusClose</td>
169
169
  <td>=</td>
170
- <td class="context-item-value">&quot;HTTP/1.1 %d\r\nConnection: close\r\nContent-Type: %s\r\n%sContent-Length: %d\r\n\r\n&quot;.freeze</td>
170
+ <td class="context-item-value">&quot;HTTP/1.1 %d\r\nConnection: close\r\nContent-Type: %s\r\n%s%sContent-Length: %d\r\n\r\n&quot;.freeze</td>
171
171
  </tr>
172
172
  <tr class="top-aligned-row context-row">
173
173
  <td class="context-item-name">StatusStream</td>
174
174
  <td>=</td>
175
- <td class="context-item-value">&quot;HTTP/1.1 %d\r\nConnection: close\r\nContent-Type: %s\r\n%s\r\n&quot;.freeze</td>
175
+ <td class="context-item-value">&quot;HTTP/1.1 %d\r\nConnection: close\r\nContent-Type: %s\r\n%s%s\r\n&quot;.freeze</td>
176
176
  </tr>
177
177
  <tr class="top-aligned-row context-row">
178
178
  <td class="context-item-name">StatusPersist</td>
179
179
  <td>=</td>
180
- <td class="context-item-value">&quot;HTTP/1.1 %d\r\nContent-Type: %s\r\n%sContent-Length: %d\r\n\r\n&quot;.freeze</td>
180
+ <td class="context-item-value">&quot;HTTP/1.1 %d\r\nContent-Type: %s\r\n%s%sContent-Length: %d\r\n\r\n&quot;.freeze</td>
181
181
  </tr>
182
182
  <tr class="top-aligned-row context-row">
183
183
  <td class="context-item-name">StatusRedirect</td>
@@ -190,10 +190,15 @@ Regexp for parsing URI parameters.
190
190
  <td class="context-item-value">&quot;%s: %s\r\n&quot;.freeze</td>
191
191
  </tr>
192
192
  <tr class="top-aligned-row context-row">
193
- <td class="context-item-name">Empty</td>
193
+ <td class="context-item-name">EmptyString</td>
194
194
  <td>=</td>
195
195
  <td class="context-item-value">''.freeze</td>
196
196
  </tr>
197
+ <tr class="top-aligned-row context-row">
198
+ <td class="context-item-name">EmptyHash</td>
199
+ <td>=</td>
200
+ <td class="context-item-value">{}.freeze</td>
201
+ </tr>
197
202
  <tr class="top-aligned-row context-row">
198
203
  <td class="context-item-name">Slash</td>
199
204
  <td>=</td>
@@ -202,7 +207,32 @@ Regexp for parsing URI parameters.
202
207
  <tr class="top-aligned-row context-row">
203
208
  <td class="context-item-name">Location</td>
204
209
  <td>=</td>
205
- <td class="context-item-value">'Location'</td>
210
+ <td class="context-item-value">'Location'.freeze</td>
211
+ </tr>
212
+ <tr class="top-aligned-row context-row">
213
+ <td class="context-item-name">Cookie</td>
214
+ <td>=</td>
215
+ <td class="context-item-value">'Cookie'</td>
216
+ </tr>
217
+ <tr class="top-aligned-row context-row">
218
+ <td class="context-item-name">SetCookie</td>
219
+ <td>=</td>
220
+ <td class="context-item-value">&quot;Set-Cookie: %s=%s; path=/; expires=%s\r\n&quot;.freeze</td>
221
+ </tr>
222
+ <tr class="top-aligned-row context-row">
223
+ <td class="context-item-name">CookieSplit</td>
224
+ <td>=</td>
225
+ <td class="context-item-value">/[;,] */n.freeze</td>
226
+ </tr>
227
+ <tr class="top-aligned-row context-row">
228
+ <td class="context-item-name">CookieRegexp</td>
229
+ <td>=</td>
230
+ <td class="context-item-value">/\s*(.+)=(.*)\s*/.freeze</td>
231
+ </tr>
232
+ <tr class="top-aligned-row context-row">
233
+ <td class="context-item-name">CookieExpiredTime</td>
234
+ <td>=</td>
235
+ <td class="context-item-value">Time.at(0).freeze</td>
206
236
  </tr>
207
237
  </table>
208
238
  </div>