serverside 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/CHANGELOG +16 -0
  2. data/Rakefile +16 -1
  3. data/lib/serverside/caching.rb +56 -0
  4. data/lib/serverside/request.rb +8 -4
  5. data/lib/serverside/static.rb +29 -51
  6. data/test/functional/static_server.rb +7 -0
  7. data/test/spec/caching_spec.rb +101 -0
  8. data/test/spec/connection_spec.rb +0 -2
  9. data/test/unit/request_test.rb +31 -1
  10. data/test/unit/static_test.rb +21 -25
  11. metadata +30 -75
  12. data/doc/rdoc/classes/Daemon/Base.html +0 -148
  13. data/doc/rdoc/classes/Daemon/Cluster/PidFile.html +0 -230
  14. data/doc/rdoc/classes/Daemon/Cluster.html +0 -308
  15. data/doc/rdoc/classes/Daemon/PidFile.html +0 -178
  16. data/doc/rdoc/classes/Daemon.html +0 -253
  17. data/doc/rdoc/classes/Object.html +0 -151
  18. data/doc/rdoc/classes/Proc.html +0 -151
  19. data/doc/rdoc/classes/ServerSide/Application.html +0 -172
  20. data/doc/rdoc/classes/ServerSide/HTTP/Connection.html +0 -202
  21. data/doc/rdoc/classes/ServerSide/HTTP/Request.html +0 -768
  22. data/doc/rdoc/classes/ServerSide/HTTP/Server.html +0 -164
  23. data/doc/rdoc/classes/ServerSide/HTTP.html +0 -121
  24. data/doc/rdoc/classes/ServerSide/Router.html +0 -496
  25. data/doc/rdoc/classes/ServerSide/StaticFiles/Const.html +0 -204
  26. data/doc/rdoc/classes/ServerSide/StaticFiles.html +0 -282
  27. data/doc/rdoc/classes/ServerSide/Template.html +0 -200
  28. data/doc/rdoc/classes/ServerSide.html +0 -174
  29. data/doc/rdoc/classes/String.html +0 -212
  30. data/doc/rdoc/classes/Symbol.html +0 -158
  31. data/doc/rdoc/created.rid +0 -1
  32. data/doc/rdoc/files/CHANGELOG.html +0 -356
  33. data/doc/rdoc/files/COPYING.html +0 -129
  34. data/doc/rdoc/files/README.html +0 -199
  35. data/doc/rdoc/files/lib/serverside/application_rb.html +0 -109
  36. data/doc/rdoc/files/lib/serverside/cluster_rb.html +0 -101
  37. data/doc/rdoc/files/lib/serverside/connection_rb.html +0 -101
  38. data/doc/rdoc/files/lib/serverside/core_ext_rb.html +0 -107
  39. data/doc/rdoc/files/lib/serverside/daemon_rb.html +0 -108
  40. data/doc/rdoc/files/lib/serverside/request_rb.html +0 -108
  41. data/doc/rdoc/files/lib/serverside/routing_rb.html +0 -101
  42. data/doc/rdoc/files/lib/serverside/server_rb.html +0 -108
  43. data/doc/rdoc/files/lib/serverside/static_rb.html +0 -108
  44. data/doc/rdoc/files/lib/serverside/template_rb.html +0 -108
  45. data/doc/rdoc/files/lib/serverside_rb.html +0 -131
  46. data/doc/rdoc/fr_class_index.html +0 -45
  47. data/doc/rdoc/fr_file_index.html +0 -40
  48. data/doc/rdoc/fr_method_index.html +0 -79
  49. data/doc/rdoc/index.html +0 -24
  50. data/doc/rdoc/rdoc-style.css +0 -208
@@ -1,172 +0,0 @@
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>Module: ServerSide::Application</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>Module</strong></td>
53
- <td class="class-name-in-header">ServerSide::Application</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../../files/lib/serverside/application_rb.html">
59
- lib/serverside/application.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- </table>
66
- </div>
67
- <!-- banner header -->
68
-
69
- <div id="bodyContent">
70
-
71
-
72
-
73
- <div id="contextContent">
74
-
75
-
76
-
77
- </div>
78
-
79
- <div id="method-list">
80
- <h3 class="section-bar">Methods</h3>
81
-
82
- <div class="name-list">
83
- <a href="#M000026">config=</a>&nbsp;&nbsp;
84
- <a href="#M000027">daemonize</a>&nbsp;&nbsp;
85
- </div>
86
- </div>
87
-
88
- </div>
89
-
90
-
91
- <!-- if includes -->
92
-
93
- <div id="section">
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
- <!-- if method_list -->
103
- <div id="methods">
104
- <h3 class="section-bar">Public Class methods</h3>
105
-
106
- <div id="method-M000026" class="method-detail">
107
- <a name="M000026"></a>
108
-
109
- <div class="method-heading">
110
- <a href="#M000026" class="method-signature">
111
- <span class="method-name">config=</span><span class="method-args">(c)</span>
112
- </a>
113
- </div>
114
-
115
- <div class="method-description">
116
- <p><a class="source-toggle" href="#"
117
- onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
118
- <div class="method-source-code" id="M000026-source">
119
- <pre>
120
- <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 9</span>
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>)
122
- 10: <span class="ruby-ivar">@@config</span> = <span class="ruby-identifier">c</span>
123
- 11: <span class="ruby-keyword kw">end</span>
124
- </pre>
125
- </div>
126
- </div>
127
- </div>
128
-
129
- <div id="method-M000027" class="method-detail">
130
- <a name="M000027"></a>
131
-
132
- <div class="method-heading">
133
- <a href="#M000027" class="method-signature">
134
- <span class="method-name">daemonize</span><span class="method-args">(config, cmd)</span>
135
- </a>
136
- </div>
137
-
138
- <div class="method-description">
139
- <p><a class="source-toggle" href="#"
140
- onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
141
- <div class="method-source-code" id="M000027-source">
142
- <pre>
143
- <span class="ruby-comment cmt"># File lib/serverside/application.rb, line 13</span>
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>)
145
- 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>
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
- 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
- 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">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
- 19: <span class="ruby-keyword kw">end</span>
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
- 21: <span class="ruby-keyword kw">end</span>
153
- 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>)
154
- 23: <span class="ruby-keyword kw">end</span>
155
- </pre>
156
- </div>
157
- </div>
158
- </div>
159
-
160
-
161
- </div>
162
-
163
-
164
- </div>
165
-
166
-
167
- <div id="validator-badges">
168
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
169
- </div>
170
-
171
- </body>
172
- </html>
@@ -1,202 +0,0 @@
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="#M000040">new</a>&nbsp;&nbsp;
102
- <a href="#M000041">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-M000040" class="method-detail">
125
- <a name="M000040"></a>
126
-
127
- <div class="method-heading">
128
- <a href="#M000040" class="method-signature">
129
- <span class="method-name">new</span><span class="method-args">(socket, 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('M000040-source');return false;">[Source]</a></p>
140
- <div class="method-source-code" id="M000040-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">socket</span>, <span class="ruby-identifier">request_class</span>)
144
- 14: <span class="ruby-ivar">@socket</span>, <span class="ruby-ivar">@request_class</span> = <span class="ruby-identifier">socket</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-M000041" class="method-detail">
155
- <a name="M000041"></a>
156
-
157
- <div class="method-heading">
158
- <a href="#M000041" 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('M000041-source');return false;">[Source]</a></p>
171
- <div class="method-source-code" id="M000041-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-comment cmt"># the process function is expected to return true or a non-nil value</span>
177
- 24: <span class="ruby-comment cmt"># if the connection is to persist.</span>
178
- 25: <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">@socket</span>).<span class="ruby-identifier">process</span>
179
- 26: <span class="ruby-keyword kw">end</span>
180
- 27: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
181
- 28: <span class="ruby-comment cmt"># We don't care. Just close the connection.</span>
182
- 29: <span class="ruby-keyword kw">ensure</span>
183
- 30: <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">close</span>
184
- 31: <span class="ruby-keyword kw">end</span>
185
- </pre>
186
- </div>
187
- </div>
188
- </div>
189
-
190
-
191
- </div>
192
-
193
-
194
- </div>
195
-
196
-
197
- <div id="validator-badges">
198
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
199
- </div>
200
-
201
- </body>
202
- </html>