mongrel 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/README +1 -1
  2. data/Rakefile +20 -2
  3. data/bin/mongrel_rails +7 -53
  4. data/doc/rdoc/classes/Mongrel.html +1 -0
  5. data/doc/rdoc/classes/Mongrel/CGIWrapper.html +300 -0
  6. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000047.html +23 -0
  7. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000048.html +27 -0
  8. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000049.html +22 -0
  9. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000050.html +26 -0
  10. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000051.html +18 -0
  11. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000052.html +18 -0
  12. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000053.html +18 -0
  13. data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000054.html +19 -0
  14. data/doc/rdoc/classes/Mongrel/Const.html +1 -1
  15. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000022.html +6 -6
  16. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000023.html +28 -28
  17. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000024.html +26 -26
  18. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000025.html +17 -17
  19. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000026.html +24 -24
  20. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000027.html +4 -4
  21. data/doc/rdoc/classes/Mongrel/Error404Handler.html +10 -10
  22. data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000047.html → M000055.html} +4 -4
  23. data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000048.html → M000056.html} +4 -4
  24. data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000033.html +4 -4
  25. data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000034.html +7 -7
  26. data/doc/rdoc/classes/Mongrel/HttpHandler.src/M000039.html +3 -3
  27. data/doc/rdoc/classes/Mongrel/HttpRequest.html +5 -5
  28. data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000049.html → M000057.html} +17 -17
  29. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000040.html +7 -7
  30. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000041.html +6 -6
  31. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000042.html +5 -5
  32. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000043.html +5 -4
  33. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000044.html +6 -6
  34. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000045.html +6 -7
  35. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000046.html +6 -6
  36. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000028.html +24 -24
  37. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000029.html +48 -48
  38. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000030.html +9 -9
  39. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000031.html +4 -4
  40. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000032.html +4 -4
  41. data/doc/rdoc/created.rid +1 -1
  42. data/doc/rdoc/files/README.html +2 -2
  43. data/doc/rdoc/files/lib/mongrel_rb.html +2 -1
  44. data/doc/rdoc/fr_class_index.html +1 -0
  45. data/doc/rdoc/fr_method_index.html +17 -9
  46. data/lib/mongrel.rb +89 -3
  47. data/lib/mongrel/command.rb +1 -1
  48. data/tools/rakehelp.rb +17 -9
  49. metadata +17 -7
data/README CHANGED
@@ -71,7 +71,7 @@ example:
71
71
 
72
72
  h = Mongrel::HttpServer.new("0.0.0.0", "3000")
73
73
  h.register("/test", SimpleHandler.new)
74
- h.register("/files", DirHandler.new("."))
74
+ h.register("/files", Mongrel::DirHandler.new("."))
75
75
  h.run.join
76
76
 
77
77
  If you run this and access port 3000 with a browser it will say
data/Rakefile CHANGED
@@ -8,7 +8,8 @@ require 'fileutils'
8
8
  include FileUtils
9
9
 
10
10
  setup_tests
11
- setup_clean ["ext/http11/Makefile", "pkg", "lib/*.bundle", "ext/http11/*.bundle", "doc/site/output"]
11
+ setup_clean ["ext/http11/*.{bundle,so,obj,pdb,lib,def,exp}", "ext/http11/Makefile", "pkg", "lib/*.bundle", "*.gem", "doc/site/output", ".config"]
12
+
12
13
  setup_rdoc ['README', 'LICENSE', 'COPYING', 'lib/*.rb', 'doc/**/*.rdoc', 'ext/http11/http11.c']
13
14
 
14
15
  desc "Does a full compile, test run"
@@ -29,8 +30,25 @@ end
29
30
 
30
31
  setup_extension("http11", "http11")
31
32
 
33
+ version="0.3.4"
32
34
  summary = "A small fast HTTP library and server that runs Rails, Camping, and Nitro apps."
33
35
  test_file = "test/test_ws.rb"
34
- setup_gem("mongrel", "0.3.3", "Zed A. Shaw", summary, ['mongrel_rails'], test_file) do |spec|
36
+ author="Zed A. Shaw"
37
+ name="mongrel"
38
+
39
+ setup_gem(name, version, author, summary, ['mongrel_rails'], test_file) do |spec|
35
40
  spec.add_dependency('daemons', '>= 0.4.2')
36
41
  end
42
+
43
+ desc "Build a binary gem for Win32"
44
+ task :win32_gem => [:clean, :compile, :test, :package_win32]
45
+
46
+ task :package_win32 do
47
+ setup_win32_gem(name, version, version, summary, ['mongrel_rails'], test_file) do |spec|
48
+ spec.add_dependency('daemons', '>= 0.4.2')
49
+ spec.files << 'ext/http11/http11.so'
50
+ spec.extensions = []
51
+ spec.platform = Gem::Platform::WIN32
52
+ end
53
+ end
54
+
@@ -1,55 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'mongrel'
3
- require 'cgi'
4
3
  require 'daemons/daemonize'
5
4
  require 'mongrel/command'
6
5
 
7
6
 
8
- class CGIFixed < ::CGI
9
- public :env_table
10
- attr_reader :options
11
-
12
- def initialize(params, data, out, *args)
13
- @env_table = params
14
- @args = *args
15
- @input = StringIO.new(data)
16
- @out = out
17
- @options = {}
18
- super(*args)
19
- end
20
-
21
- def header(options = "text/html")
22
- if options.class == Hash
23
- # passing in a header so need to keep the status around and other options
24
- @options = options
25
- end
26
-
27
- super(options)
28
- end
29
-
30
- def status
31
- s = @options["Status"] || @options["status"]
32
- s[0 .. s.index(' ')] || "200"
33
- end
34
-
35
- def args
36
- @args
37
- end
38
-
39
- def env_table
40
- @env_table
41
- end
42
-
43
- def stdinput
44
- @input
45
- end
46
-
47
- def stdoutput
48
- @out
49
- end
50
- end
51
-
52
-
53
7
  class RailsHandler < Mongrel::HttpHandler
54
8
 
55
9
  def initialize(dir, mime_map = {})
@@ -63,26 +17,26 @@ class RailsHandler < Mongrel::HttpHandler
63
17
  def process(request, response)
64
18
  # not static, need to talk to rails
65
19
  return if response.socket.closed?
66
-
20
+
67
21
  if @files.can_serve(request.params["PATH_INFO"])
68
22
  @files.process(request,response)
69
23
  else
70
- cgi = CGIFixed.new(request.params, request.body, response.socket)
24
+ cgi = Mongrel::CGIWrapper.new(request, response)
25
+
71
26
  begin
72
-
73
27
  @guard.synchronize do
74
28
  # Rails is not thread safe so must be run entirely within synchronize
75
29
  Dispatcher.dispatch(cgi, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, response.body)
76
30
  end
77
-
78
- response.status = cgi.status
79
- response.send_status
80
- response.send_body
31
+
32
+ # This finalizes the output using the proper HttpResponse way
33
+ cgi.out {""}
81
34
  rescue Object => rails_error
82
35
  STDERR.puts "calling Dispatcher.dispatch #{rails_error}"
83
36
  STDERR.puts rails_error.backtrace.join("\n")
84
37
  end
85
38
  end
39
+
86
40
  end
87
41
  end
88
42
 
@@ -101,6 +101,7 @@ to service web application requests fast as possible.
101
101
  <h3 class="section-bar">Classes and Modules</h3>
102
102
 
103
103
  Module <a href="Mongrel/Const.html" class="link">Mongrel::Const</a><br />
104
+ Class <a href="Mongrel/CGIWrapper.html" class="link">Mongrel::CGIWrapper</a><br />
104
105
  Class <a href="Mongrel/DirHandler.html" class="link">Mongrel::DirHandler</a><br />
105
106
  Class <a href="Mongrel/Error404Handler.html" class="link">Mongrel::Error404Handler</a><br />
106
107
  Class <a href="Mongrel/HeaderOut.html" class="link">Mongrel::HeaderOut</a><br />
@@ -0,0 +1,300 @@
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: Mongrel::CGIWrapper</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">Mongrel::CGIWrapper</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/mongrel_rb.html">
59
+ lib/mongrel.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
+ ::CGI
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+ <div id="description">
82
+ <p>
83
+ The beginning of a complete wrapper around <a
84
+ href="../Mongrel.html">Mongrel</a>&#8217;s internal HTTP processing system
85
+ but maintaining the original Ruby CGI module. Use this only as a crutch to
86
+ get existing CGI based systems working. It should handle everything, but
87
+ please notify me if you see special warnings. This work is still very alpha
88
+ so I need testers to help work out the various corner cases.
89
+ </p>
90
+
91
+ </div>
92
+
93
+
94
+ </div>
95
+
96
+ <div id="method-list">
97
+ <h3 class="section-bar">Methods</h3>
98
+
99
+ <div class="name-list">
100
+ <a href="#M000051">args</a>&nbsp;&nbsp;
101
+ <a href="#M000052">env_table</a>&nbsp;&nbsp;
102
+ <a href="#M000048">header</a>&nbsp;&nbsp;
103
+ <a href="#M000047">new</a>&nbsp;&nbsp;
104
+ <a href="#M000049">out</a>&nbsp;&nbsp;
105
+ <a href="#M000050">status</a>&nbsp;&nbsp;
106
+ <a href="#M000053">stdinput</a>&nbsp;&nbsp;
107
+ <a href="#M000054">stdoutput</a>&nbsp;&nbsp;
108
+ </div>
109
+ </div>
110
+
111
+ </div>
112
+
113
+
114
+ <!-- if includes -->
115
+
116
+ <div id="section">
117
+
118
+
119
+
120
+
121
+
122
+ <div id="attribute-list">
123
+ <h3 class="section-bar">Attributes</h3>
124
+
125
+ <div class="name-list">
126
+ <table>
127
+ <tr class="top-aligned-row context-row">
128
+ <td class="context-item-name">options</td>
129
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
130
+ <td class="context-item-desc"></td>
131
+ </tr>
132
+ </table>
133
+ </div>
134
+ </div>
135
+
136
+
137
+
138
+ <!-- if method_list -->
139
+ <div id="methods">
140
+ <h3 class="section-bar">Public Class methods</h3>
141
+
142
+ <div id="method-M000047" class="method-detail">
143
+ <a name="M000047"></a>
144
+
145
+ <div class="method-heading">
146
+ <a href="CGIWrapper.src/M000047.html" target="Code" class="method-signature"
147
+ onclick="popupCode('CGIWrapper.src/M000047.html');return false;">
148
+ <span class="method-name">new</span><span class="method-args">(request, response, *args)</span>
149
+ </a>
150
+ </div>
151
+
152
+ <div class="method-description">
153
+ </div>
154
+ </div>
155
+
156
+ <h3 class="section-bar">Public Instance methods</h3>
157
+
158
+ <div id="method-M000051" class="method-detail">
159
+ <a name="M000051"></a>
160
+
161
+ <div class="method-heading">
162
+ <a href="CGIWrapper.src/M000051.html" target="Code" class="method-signature"
163
+ onclick="popupCode('CGIWrapper.src/M000051.html');return false;">
164
+ <span class="method-name">args</span><span class="method-args">()</span>
165
+ </a>
166
+ </div>
167
+
168
+ <div class="method-description">
169
+ <p>
170
+ Used to wrap the normal args variable used inside CGI.
171
+ </p>
172
+ </div>
173
+ </div>
174
+
175
+ <div id="method-M000052" class="method-detail">
176
+ <a name="M000052"></a>
177
+
178
+ <div class="method-heading">
179
+ <a href="CGIWrapper.src/M000052.html" target="Code" class="method-signature"
180
+ onclick="popupCode('CGIWrapper.src/M000052.html');return false;">
181
+ <span class="method-name">env_table</span><span class="method-args">()</span>
182
+ </a>
183
+ </div>
184
+
185
+ <div class="method-description">
186
+ <p>
187
+ Used to wrap the normal <a href="CGIWrapper.html#M000052">env_table</a>
188
+ variable used inside CGI.
189
+ </p>
190
+ </div>
191
+ </div>
192
+
193
+ <div id="method-M000048" class="method-detail">
194
+ <a name="M000048"></a>
195
+
196
+ <div class="method-heading">
197
+ <a href="CGIWrapper.src/M000048.html" target="Code" class="method-signature"
198
+ onclick="popupCode('CGIWrapper.src/M000048.html');return false;">
199
+ <span class="method-name">header</span><span class="method-args">(options = &quot;text/html&quot;)</span>
200
+ </a>
201
+ </div>
202
+
203
+ <div class="method-description">
204
+ <p>
205
+ The header is typically called to send back the header. In our case we
206
+ collect it into a hash for later usage. Options passed to this function are
207
+ capitalized properly (unlike CGI), sanitized and then just stored.
208
+ </p>
209
+ </div>
210
+ </div>
211
+
212
+ <div id="method-M000049" class="method-detail">
213
+ <a name="M000049"></a>
214
+
215
+ <div class="method-heading">
216
+ <a href="CGIWrapper.src/M000049.html" target="Code" class="method-signature"
217
+ onclick="popupCode('CGIWrapper.src/M000049.html');return false;">
218
+ <span class="method-name">out</span><span class="method-args">(options = &quot;text/html&quot;) {||| &quot;&quot;)| ...}</span>
219
+ </a>
220
+ </div>
221
+
222
+ <div class="method-description">
223
+ <p>
224
+ The dumb thing is people can call header or this or both and in any order.
225
+ So, we just reuse header and then finalize the <a
226
+ href="HttpResponse.html">HttpResponse</a> the right way. Status is taken
227
+ from the various options and converted to what <a
228
+ href="../Mongrel.html">Mongrel</a> needs via the <a
229
+ href="CGIWrapper.html#M000050">CGIWrapper.status</a> function.
230
+ </p>
231
+ </div>
232
+ </div>
233
+
234
+ <div id="method-M000050" class="method-detail">
235
+ <a name="M000050"></a>
236
+
237
+ <div class="method-heading">
238
+ <a href="CGIWrapper.src/M000050.html" target="Code" class="method-signature"
239
+ onclick="popupCode('CGIWrapper.src/M000050.html');return false;">
240
+ <span class="method-name">status</span><span class="method-args">()</span>
241
+ </a>
242
+ </div>
243
+
244
+ <div class="method-description">
245
+ <p>
246
+ Computes the status once, but lazily so that people who call header twice
247
+ don&#8217;t get penalized. Because CGI insists on including the options
248
+ status message in the status we have to do a bit of parsing.
249
+ </p>
250
+ </div>
251
+ </div>
252
+
253
+ <div id="method-M000053" class="method-detail">
254
+ <a name="M000053"></a>
255
+
256
+ <div class="method-heading">
257
+ <a href="CGIWrapper.src/M000053.html" target="Code" class="method-signature"
258
+ onclick="popupCode('CGIWrapper.src/M000053.html');return false;">
259
+ <span class="method-name">stdinput</span><span class="method-args">()</span>
260
+ </a>
261
+ </div>
262
+
263
+ <div class="method-description">
264
+ <p>
265
+ Used to wrap the normal stdinput variable used inside CGI.
266
+ </p>
267
+ </div>
268
+ </div>
269
+
270
+ <div id="method-M000054" class="method-detail">
271
+ <a name="M000054"></a>
272
+
273
+ <div class="method-heading">
274
+ <a href="CGIWrapper.src/M000054.html" target="Code" class="method-signature"
275
+ onclick="popupCode('CGIWrapper.src/M000054.html');return false;">
276
+ <span class="method-name">stdoutput</span><span class="method-args">()</span>
277
+ </a>
278
+ </div>
279
+
280
+ <div class="method-description">
281
+ <p>
282
+ The stdoutput should be completely bypassed but we&#8217;ll drop a warning
283
+ just in case
284
+ </p>
285
+ </div>
286
+ </div>
287
+
288
+
289
+ </div>
290
+
291
+
292
+ </div>
293
+
294
+
295
+ <div id="validator-badges">
296
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
297
+ </div>
298
+
299
+ </body>
300
+ </html>
@@ -0,0 +1,23 @@
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>
7
+ <head>
8
+ <title>new (Mongrel::CGIWrapper)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 605</span>
14
+ 605: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
15
+ 606: <span class="ruby-ivar">@request</span> = <span class="ruby-identifier">request</span>
16
+ 607: <span class="ruby-ivar">@response</span> = <span class="ruby-identifier">response</span>
17
+ 608: <span class="ruby-ivar">@args</span> = <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>
18
+ 609: <span class="ruby-ivar">@input</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">request</span>.<span class="ruby-identifier">body</span>)
19
+ 610: <span class="ruby-ivar">@options</span> = {}
20
+ 611: <span class="ruby-keyword kw">super</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
21
+ 612: <span class="ruby-keyword kw">end</span></pre>
22
+ </body>
23
+ </html>