serverside 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/CHANGELOG +10 -0
  2. data/README +3 -3
  3. data/Rakefile +4 -4
  4. data/bin/serverside +4 -4
  5. data/doc/rdoc/classes/Daemon.html +4 -4
  6. data/doc/rdoc/classes/ServerSide.html +14 -74
  7. data/doc/rdoc/classes/ServerSide/Application.html +13 -13
  8. data/doc/rdoc/classes/ServerSide/{Connection.html → HTTP.html} +12 -18
  9. data/doc/rdoc/classes/ServerSide/HTTP/Connection.html +200 -0
  10. data/doc/rdoc/classes/ServerSide/{Connection → HTTP}/Const.html +6 -6
  11. data/doc/rdoc/classes/ServerSide/{Connection/Base.html → HTTP/Request.html} +213 -164
  12. data/doc/rdoc/classes/ServerSide/{Server.html → HTTP/Server.html} +22 -22
  13. data/doc/rdoc/classes/ServerSide/Router.html +496 -0
  14. data/doc/rdoc/classes/ServerSide/StaticFiles.html +31 -30
  15. data/doc/rdoc/classes/ServerSide/Template.html +12 -12
  16. data/doc/rdoc/created.rid +1 -1
  17. data/doc/rdoc/files/CHANGELOG.html +22 -4
  18. data/doc/rdoc/files/COPYING.html +1 -1
  19. data/doc/rdoc/files/README.html +4 -4
  20. data/doc/rdoc/files/lib/serverside/application_rb.html +1 -1
  21. data/doc/rdoc/files/lib/serverside/cluster_rb.html +1 -1
  22. data/doc/rdoc/files/lib/serverside/connection_rb.html +1 -1
  23. data/doc/rdoc/files/lib/serverside/core_ext_rb.html +1 -1
  24. data/doc/rdoc/files/lib/serverside/daemon_rb.html +1 -1
  25. data/doc/rdoc/files/lib/serverside/request_rb.html +101 -0
  26. data/doc/rdoc/files/lib/serverside/routing_rb.html +1 -1
  27. data/doc/rdoc/files/lib/serverside/server_rb.html +1 -1
  28. data/doc/rdoc/files/lib/serverside/static_rb.html +1 -1
  29. data/doc/rdoc/files/lib/serverside/template_rb.html +1 -1
  30. data/doc/rdoc/files/lib/serverside_rb.html +1 -1
  31. data/doc/rdoc/fr_class_index.html +6 -5
  32. data/doc/rdoc/fr_file_index.html +1 -0
  33. data/doc/rdoc/fr_method_index.html +31 -31
  34. data/lib/serverside/application.rb +1 -1
  35. data/lib/serverside/connection.rb +12 -141
  36. data/lib/serverside/request.rb +150 -0
  37. data/lib/serverside/routing.rb +117 -126
  38. data/lib/serverside/server.rb +13 -12
  39. data/lib/serverside/static.rb +1 -1
  40. data/test/functional/primitive_static_server_test.rb +3 -3
  41. data/test/functional/routing_server.rb +1 -1
  42. data/test/functional/routing_server_test.rb +1 -1
  43. data/test/functional/static_profile.rb +1 -1
  44. data/test/functional/static_server_test.rb +2 -2
  45. data/test/unit/connection_test.rb +30 -224
  46. data/test/unit/request_test.rb +248 -0
  47. data/test/unit/routing_test.rb +4 -4
  48. data/test/unit/server_test.rb +10 -8
  49. data/test/unit/static_test.rb +1 -1
  50. metadata +61 -56
  51. data/doc/rdoc/classes/ServerSide/Connection/Router.html +0 -493
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ *SVN*
2
+
3
+ * Refactored HTTP-related code into a new HTTP::Request class and a simplified HTTP::Connection.
4
+
5
+ * Another small change to docs.
6
+
7
+ * Fixed small error in Rakefile that prevented doc_rforge task from updating the docs.
8
+
9
+ * Fixed minor documentation error.
10
+
1
11
  *0.2.5*
2
12
 
3
13
  * Added template serving to static file module.
data/README CHANGED
@@ -12,9 +12,9 @@ clusters of servers.
12
12
  * {Bug tracking}[http://code.google.com/p/serverside/issues/list]
13
13
  * {RubyForge page}[http://rubyforge.org/projects/serverside/]
14
14
 
15
- To check out the repository, just perform:
15
+ To check out the source code:
16
16
 
17
- svn co {http://serverside.googlecode.com/svn/}[http://serverside.googlecode.com/svn/]
17
+ svn co http://serverside.googlecode.com/svn/trunk
18
18
 
19
19
  == Installation
20
20
 
@@ -48,7 +48,7 @@ By default ServerSide serves static files, but you can change the behavior by
48
48
  creating custom {routing rules}[classes/ServerSide/Connection/Router.html].
49
49
  Here's a simple routing rule:
50
50
 
51
- ServerSide.route(:path => '/hello/:name') {
51
+ ServerSide::Router.route(:path => '/hello/:name') {
52
52
  send_response(200, 'text', "Hello #{@parameters[:name]}!")
53
53
  }
54
54
 
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'fileutils'
7
7
  include FileUtils
8
8
 
9
9
  NAME = "serverside"
10
- VERS = "0.2.5"
10
+ VERS = "0.2.6"
11
11
  CLEAN.include ['**/.*.sw?', '*.gem', '.config']
12
12
  RDOC_OPTS = ['--quiet', '--title', "ServerSide Documentation",
13
13
  "--opname", "index.html",
@@ -68,7 +68,7 @@ task :uninstall => [:clean] do
68
68
  end
69
69
 
70
70
  task :doc_rforge do
71
- Rake::Task['doc'].execute
71
+ sh %{rake doc}
72
72
  sh %{scp -r doc/rdoc/* ciconia@rubyforge.org:/var/www/gforge-projects/serverside}
73
73
  end
74
74
 
@@ -105,8 +105,8 @@ end
105
105
 
106
106
  desc 'Run all tests, specs and finish with rcov'
107
107
  task :aok do
108
- Rake::Task['rcov'].execute
109
- Rake::Task['spec'].execute
108
+ sh %{rake rcov}
109
+ sh %{rake spec}
110
110
  end
111
111
 
112
112
  ##############################################################################
@@ -64,8 +64,8 @@ else
64
64
  fn = File.join(path, 'serverside.rb')
65
65
  require fn if File.file?(fn)
66
66
  end
67
- unless ServerSide::Connection::Router.has_routes?
68
- ServerSide.route_default {serve_static('.'/@path)}
67
+ unless ServerSide::Router.has_routes?
68
+ ServerSide::Router.route_default {serve_static('.'/@path)}
69
69
  end
70
70
 
71
71
  if $cmd == 'serve'
@@ -75,8 +75,8 @@ if $cmd == 'serve'
75
75
  end
76
76
  puts "Serving at #{$cmd_config[:host]}:#{$cmd_config[:ports].begin}..."
77
77
  trap('INT') {exit}
78
- ServerSide::Server.new($cmd_config[:host], $cmd_config[:ports].begin,
79
- ServerSide::Connection::Router)
78
+ ServerSide::HTTP::Server.new($cmd_config[:host], $cmd_config[:ports].begin,
79
+ ServerSide::Router)
80
80
  else
81
81
  ServerSide::Application.daemonize($cmd_config, $cmd)
82
82
  end
@@ -55,13 +55,13 @@
55
55
  <tr class="top-aligned-row">
56
56
  <td><strong>In:</strong></td>
57
57
  <td>
58
- <a href="../files/lib/serverside/daemon_rb.html">
59
- lib/serverside/daemon.rb
60
- </a>
61
- <br />
62
58
  <a href="../files/lib/serverside/cluster_rb.html">
63
59
  lib/serverside/cluster.rb
64
60
  </a>
61
+ <br />
62
+ <a href="../files/lib/serverside/daemon_rb.html">
63
+ lib/serverside/daemon.rb
64
+ </a>
65
65
  <br />
66
66
  </td>
67
67
  </tr>
@@ -58,10 +58,6 @@
58
58
  <a href="../files/lib/serverside_rb.html">
59
59
  lib/serverside.rb
60
60
  </a>
61
- <br />
62
- <a href="../files/lib/serverside/server_rb.html">
63
- lib/serverside/server.rb
64
- </a>
65
61
  <br />
66
62
  <a href="../files/lib/serverside/application_rb.html">
67
63
  lib/serverside/application.rb
@@ -71,13 +67,21 @@
71
67
  lib/serverside/connection.rb
72
68
  </a>
73
69
  <br />
74
- <a href="../files/lib/serverside/static_rb.html">
75
- lib/serverside/static.rb
70
+ <a href="../files/lib/serverside/request_rb.html">
71
+ lib/serverside/request.rb
76
72
  </a>
77
73
  <br />
78
74
  <a href="../files/lib/serverside/routing_rb.html">
79
75
  lib/serverside/routing.rb
80
76
  </a>
77
+ <br />
78
+ <a href="../files/lib/serverside/server_rb.html">
79
+ lib/serverside/server.rb
80
+ </a>
81
+ <br />
82
+ <a href="../files/lib/serverside/static_rb.html">
83
+ lib/serverside/static.rb
84
+ </a>
81
85
  <br />
82
86
  <a href="../files/lib/serverside/template_rb.html">
83
87
  lib/serverside/template.rb
@@ -103,7 +107,8 @@ easy to create custom light-weight web applications. It contains the
103
107
  following functionalities:
104
108
  </p>
105
109
  <ol>
106
- <li>A fast multithreaded HTTP server with support for persistent connections
110
+ <li>A fast multithreaded <a href="ServerSide/HTTP.html">HTTP</a> server with
111
+ support for persistent connections
107
112
 
108
113
  </li>
109
114
  </ol>
@@ -130,14 +135,6 @@ and streaming.
130
135
 
131
136
  </div>
132
137
 
133
- <div id="method-list">
134
- <h3 class="section-bar">Methods</h3>
135
-
136
- <div class="name-list">
137
- <a href="#M000022">route</a>&nbsp;&nbsp;
138
- <a href="#M000023">route_default</a>&nbsp;&nbsp;
139
- </div>
140
- </div>
141
138
 
142
139
  </div>
143
140
 
@@ -150,9 +147,9 @@ and streaming.
150
147
  <h3 class="section-bar">Classes and Modules</h3>
151
148
 
152
149
  Module <a href="ServerSide/Application.html" class="link">ServerSide::Application</a><br />
153
- Module <a href="ServerSide/Connection.html" class="link">ServerSide::Connection</a><br />
150
+ Module <a href="ServerSide/HTTP.html" class="link">ServerSide::HTTP</a><br />
154
151
  Module <a href="ServerSide/StaticFiles.html" class="link">ServerSide::StaticFiles</a><br />
155
- Class <a href="ServerSide/Server.html" class="link">ServerSide::Server</a><br />
152
+ Class <a href="ServerSide/Router.html" class="link">ServerSide::Router</a><br />
156
153
  Class <a href="ServerSide/Template.html" class="link">ServerSide::Template</a><br />
157
154
 
158
155
  </div>
@@ -164,63 +161,6 @@ Class <a href="ServerSide/Template.html" class="link">ServerSide::Template</a><b
164
161
 
165
162
 
166
163
  <!-- if method_list -->
167
- <div id="methods">
168
- <h3 class="section-bar">Public Class methods</h3>
169
-
170
- <div id="method-M000022" class="method-detail">
171
- <a name="M000022"></a>
172
-
173
- <div class="method-heading">
174
- <a href="#M000022" class="method-signature">
175
- <span class="method-name">route</span><span class="method-args">(rule, &amp;block)</span>
176
- </a>
177
- </div>
178
-
179
- <div class="method-description">
180
- <p>
181
- Adds a routing rule. This is a convenience method.
182
- </p>
183
- <p><a class="source-toggle" href="#"
184
- onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
185
- <div class="method-source-code" id="M000022-source">
186
- <pre>
187
- <span class="ruby-comment cmt"># File lib/serverside/routing.rb, line 132</span>
188
- 132: <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>)
189
- 133: <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>)
190
- 134: <span class="ruby-keyword kw">end</span>
191
- </pre>
192
- </div>
193
- </div>
194
- </div>
195
-
196
- <div id="method-M000023" class="method-detail">
197
- <a name="M000023"></a>
198
-
199
- <div class="method-heading">
200
- <a href="#M000023" class="method-signature">
201
- <span class="method-name">route_default</span><span class="method-args">(&amp;block)</span>
202
- </a>
203
- </div>
204
-
205
- <div class="method-description">
206
- <p>
207
- Sets the default request handler. This is a convenience method.
208
- </p>
209
- <p><a class="source-toggle" href="#"
210
- onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
211
- <div class="method-source-code" id="M000023-source">
212
- <pre>
213
- <span class="ruby-comment cmt"># File lib/serverside/routing.rb, line 137</span>
214
- 137: <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>)
215
- 138: <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>)
216
- 139: <span class="ruby-keyword kw">end</span>
217
- </pre>
218
- </div>
219
- </div>
220
- </div>
221
-
222
-
223
- </div>
224
164
 
225
165
 
226
166
  </div>
@@ -80,8 +80,8 @@
80
80
  <h3 class="section-bar">Methods</h3>
81
81
 
82
82
  <div class="name-list">
83
- <a href="#M000028">config=</a>&nbsp;&nbsp;
84
- <a href="#M000029">daemonize</a>&nbsp;&nbsp;
83
+ <a href="#M000026">config=</a>&nbsp;&nbsp;
84
+ <a href="#M000027">daemonize</a>&nbsp;&nbsp;
85
85
  </div>
86
86
  </div>
87
87
 
@@ -103,19 +103,19 @@
103
103
  <div id="methods">
104
104
  <h3 class="section-bar">Public Class methods</h3>
105
105
 
106
- <div id="method-M000028" class="method-detail">
107
- <a name="M000028"></a>
106
+ <div id="method-M000026" class="method-detail">
107
+ <a name="M000026"></a>
108
108
 
109
109
  <div class="method-heading">
110
- <a href="#M000028" class="method-signature">
110
+ <a href="#M000026" class="method-signature">
111
111
  <span class="method-name">config=</span><span class="method-args">(c)</span>
112
112
  </a>
113
113
  </div>
114
114
 
115
115
  <div class="method-description">
116
116
  <p><a class="source-toggle" href="#"
117
- onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
118
- <div class="method-source-code" id="M000028-source">
117
+ onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
118
+ <div class="method-source-code" id="M000026-source">
119
119
  <pre>
120
120
  <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 9</span>
121
121
  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>)
@@ -126,19 +126,19 @@
126
126
  </div>
127
127
  </div>
128
128
 
129
- <div id="method-M000029" class="method-detail">
130
- <a name="M000029"></a>
129
+ <div id="method-M000027" class="method-detail">
130
+ <a name="M000027"></a>
131
131
 
132
132
  <div class="method-heading">
133
- <a href="#M000029" class="method-signature">
133
+ <a href="#M000027" class="method-signature">
134
134
  <span class="method-name">daemonize</span><span class="method-args">(config, cmd)</span>
135
135
  </a>
136
136
  </div>
137
137
 
138
138
  <div class="method-description">
139
139
  <p><a class="source-toggle" href="#"
140
- onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
141
- <div class="method-source-code" id="M000029-source">
140
+ onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
141
+ <div class="method-source-code" id="M000027-source">
142
142
  <pre>
143
143
  <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 13</span>
144
144
  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>)
@@ -146,7 +146,7 @@
146
146
  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>
147
147
  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>}
148
148
  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>
149
- 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>)
149
+ 18: <span class="ruby-constant">ServerSide</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</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">Router</span>)
150
150
  19: <span class="ruby-keyword kw">end</span>
151
151
  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>]}
152
152
  21: <span class="ruby-keyword kw">end</span>
@@ -5,7 +5,7 @@
5
5
 
6
6
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
7
  <head>
8
- <title>Module: ServerSide::Connection</title>
8
+ <title>Module: ServerSide::HTTP</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
10
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
11
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
@@ -50,7 +50,7 @@
50
50
  <table class="header-table">
51
51
  <tr class="top-aligned-row">
52
52
  <td><strong>Module</strong></td>
53
- <td class="class-name-in-header">ServerSide::Connection</td>
53
+ <td class="class-name-in-header">ServerSide::HTTP</td>
54
54
  </tr>
55
55
  <tr class="top-aligned-row">
56
56
  <td><strong>In:</strong></td>
@@ -59,8 +59,12 @@
59
59
  lib/serverside/connection.rb
60
60
  </a>
61
61
  <br />
62
- <a href="../../files/lib/serverside/routing_rb.html">
63
- lib/serverside/routing.rb
62
+ <a href="../../files/lib/serverside/request_rb.html">
63
+ lib/serverside/request.rb
64
+ </a>
65
+ <br />
66
+ <a href="../../files/lib/serverside/server_rb.html">
67
+ lib/serverside/server.rb
64
68
  </a>
65
69
  <br />
66
70
  </td>
@@ -76,17 +80,6 @@
76
80
 
77
81
  <div id="contextContent">
78
82
 
79
- <div id="description">
80
- <p>
81
- The <a href="Connection.html">Connection</a> module takes care of HTTP
82
- connection. While most HTTP servers (at least the OO ones) will define
83
- separate classes for request and response, I chose to use the concept of a
84
- connection both for better performance, and also because a single
85
- connection might handle multiple requests, if using HTTP 1.1 persistent
86
- connection.
87
- </p>
88
-
89
- </div>
90
83
 
91
84
 
92
85
  </div>
@@ -102,9 +95,10 @@ connection.
102
95
  <div id="class-list">
103
96
  <h3 class="section-bar">Classes and Modules</h3>
104
97
 
105
- Module <a href="Connection/Const.html" class="link">ServerSide::Connection::Const</a><br />
106
- Class <a href="Connection/Base.html" class="link">ServerSide::Connection::Base</a><br />
107
- Class <a href="Connection/Router.html" class="link">ServerSide::Connection::Router</a><br />
98
+ Module <a href="HTTP/Const.html" class="link">ServerSide::HTTP::Const</a><br />
99
+ Class <a href="HTTP/Connection.html" class="link">ServerSide::HTTP::Connection</a><br />
100
+ Class <a href="HTTP/Request.html" class="link">ServerSide::HTTP::Request</a><br />
101
+ Class <a href="HTTP/Server.html" class="link">ServerSide::HTTP::Server</a><br />
108
102
 
109
103
  </div>
110
104
 
@@ -0,0 +1,200 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: ServerSide::HTTP::Connection</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">ServerSide::HTTP::Connection</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../files/lib/serverside/connection_rb.html">
59
+ lib/serverside/connection.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ <a href="../../Object.html">
69
+ Object
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </div>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+
79
+
80
+
81
+ <div id="contextContent">
82
+
83
+ <div id="description">
84
+ <p>
85
+ The <a href="Connection.html">Connection</a> class represents <a
86
+ href="../HTTP.html">HTTP</a> connections. Each connection instance creates
87
+ a separate thread for execution and processes incoming requests in a loop
88
+ until the connection is closed by either server or client, thus
89
+ implementing <a href="../HTTP.html">HTTP</a> 1.1 persistent connections.
90
+ </p>
91
+
92
+ </div>
93
+
94
+
95
+ </div>
96
+
97
+ <div id="method-list">
98
+ <h3 class="section-bar">Methods</h3>
99
+
100
+ <div class="name-list">
101
+ <a href="#M000039">new</a>&nbsp;&nbsp;
102
+ <a href="#M000040">process</a>&nbsp;&nbsp;
103
+ </div>
104
+ </div>
105
+
106
+ </div>
107
+
108
+
109
+ <!-- if includes -->
110
+
111
+ <div id="section">
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+ <!-- if method_list -->
121
+ <div id="methods">
122
+ <h3 class="section-bar">Public Class methods</h3>
123
+
124
+ <div id="method-M000039" class="method-detail">
125
+ <a name="M000039"></a>
126
+
127
+ <div class="method-heading">
128
+ <a href="#M000039" class="method-signature">
129
+ <span class="method-name">new</span><span class="method-args">(conn, request_class)</span>
130
+ </a>
131
+ </div>
132
+
133
+ <div class="method-description">
134
+ <p>
135
+ Initializes the request instance. A new thread is created for processing
136
+ requests.
137
+ </p>
138
+ <p><a class="source-toggle" href="#"
139
+ onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
140
+ <div class="method-source-code" id="M000039-source">
141
+ <pre>
142
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 13</span>
143
+ 13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">conn</span>, <span class="ruby-identifier">request_class</span>)
144
+ 14: <span class="ruby-ivar">@conn</span>, <span class="ruby-ivar">@request_class</span> = <span class="ruby-identifier">conn</span>, <span class="ruby-identifier">request_class</span>
145
+ 15: <span class="ruby-ivar">@thread</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> {<span class="ruby-identifier">process</span>}
146
+ 16: <span class="ruby-keyword kw">end</span>
147
+ </pre>
148
+ </div>
149
+ </div>
150
+ </div>
151
+
152
+ <h3 class="section-bar">Public Instance methods</h3>
153
+
154
+ <div id="method-M000040" class="method-detail">
155
+ <a name="M000040"></a>
156
+
157
+ <div class="method-heading">
158
+ <a href="#M000040" class="method-signature">
159
+ <span class="method-name">process</span><span class="method-args">()</span>
160
+ </a>
161
+ </div>
162
+
163
+ <div class="method-description">
164
+ <p>
165
+ Processes incoming requests by parsing them and then responding. If any
166
+ error occurs, or the connection is not persistent, the connection is
167
+ closed.
168
+ </p>
169
+ <p><a class="source-toggle" href="#"
170
+ onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
171
+ <div class="method-source-code" id="M000040-source">
172
+ <pre>
173
+ <span class="ruby-comment cmt"># File lib/serverside/connection.rb, line 21</span>
174
+ 21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>
175
+ 22: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
176
+ 23: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@request_class</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@conn</span>).<span class="ruby-identifier">process</span>
177
+ 24: <span class="ruby-keyword kw">end</span>
178
+ 25: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
179
+ 26: <span class="ruby-comment cmt"># We don't care. Just close the connection.</span>
180
+ 27: <span class="ruby-keyword kw">ensure</span>
181
+ 28: <span class="ruby-ivar">@conn</span>.<span class="ruby-identifier">close</span>
182
+ 29: <span class="ruby-keyword kw">end</span>
183
+ </pre>
184
+ </div>
185
+ </div>
186
+ </div>
187
+
188
+
189
+ </div>
190
+
191
+
192
+ </div>
193
+
194
+
195
+ <div id="validator-badges">
196
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
197
+ </div>
198
+
199
+ </body>
200
+ </html>