mongrel 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/README +10 -2
  2. data/Rakefile +1 -1
  3. data/doc/rdoc/classes/Mongrel.html +11 -1
  4. data/doc/rdoc/classes/Mongrel/Const.html +342 -0
  5. data/doc/rdoc/classes/Mongrel/DirHandler.html +201 -0
  6. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000008.html +20 -0
  7. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000009.html +31 -0
  8. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000010.html +22 -0
  9. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000011.html +39 -0
  10. data/doc/rdoc/classes/Mongrel/Error404Handler.html +10 -10
  11. data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000023.html → M000028.html} +4 -4
  12. data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000024.html → M000029.html} +4 -4
  13. data/doc/rdoc/classes/Mongrel/HeaderOut.html +28 -10
  14. data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000013.html → M000017.html} +4 -4
  15. data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000018.html +21 -0
  16. data/doc/rdoc/classes/Mongrel/HttpHandler.html +5 -18
  17. data/doc/rdoc/classes/Mongrel/HttpHandler.src/{M000019.html → M000023.html} +3 -3
  18. data/doc/rdoc/classes/Mongrel/HttpRequest.html +8 -8
  19. data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000030.html +31 -0
  20. data/doc/rdoc/classes/Mongrel/HttpResponse.html +89 -15
  21. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000020.html → M000024.html} +7 -7
  22. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000021.html → M000025.html} +6 -6
  23. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000026.html +19 -0
  24. data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000022.html → M000027.html} +11 -11
  25. data/doc/rdoc/classes/Mongrel/HttpServer.html +32 -76
  26. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000012.html +18 -5
  27. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000013.html +64 -0
  28. data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000010.html → M000014.html} +9 -8
  29. data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000011.html → M000015.html} +4 -4
  30. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000016.html +18 -0
  31. data/doc/rdoc/classes/Mongrel/URIClassifier.html +25 -23
  32. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000015.html → M000019.html} +0 -0
  33. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000016.html → M000020.html} +3 -2
  34. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000017.html → M000021.html} +0 -0
  35. data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000018.html → M000022.html} +1 -1
  36. data/doc/rdoc/created.rid +1 -1
  37. data/doc/rdoc/files/README.html +14 -2
  38. data/doc/rdoc/files/ext/http11/http11_c.html +1 -1
  39. data/doc/rdoc/files/lib/mongrel_rb.html +1 -1
  40. data/doc/rdoc/fr_class_index.html +2 -0
  41. data/doc/rdoc/fr_method_index.html +23 -18
  42. data/examples/simpletest.rb +2 -1
  43. data/ext/http11/http11.c +10 -9
  44. data/ext/http11/http11_parser.c +10 -10
  45. data/ext/http11/http11_parser.h +5 -1
  46. data/lib/#mongrel.rb# +493 -0
  47. data/lib/mongrel.rb +242 -48
  48. metadata +28 -19
  49. data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000014.html +0 -21
  50. data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000025.html +0 -30
  51. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000008.html +0 -26
  52. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000009.html +0 -58
@@ -0,0 +1,20 @@
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::DirHandler)</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 433</span>
14
+ 433: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">listing_allowed</span>=<span class="ruby-keyword kw">true</span>)
15
+ 434: <span class="ruby-ivar">@path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">path</span>)
16
+ 435: <span class="ruby-ivar">@listing_allowed</span>=<span class="ruby-identifier">listing_allowed</span>
17
+ 436: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;DIR: #@path&quot;</span>
18
+ 437: <span class="ruby-keyword kw">end</span></pre>
19
+ </body>
20
+ </html>
@@ -0,0 +1,31 @@
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>send_dir_listing (Mongrel::DirHandler)</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 439</span>
14
+ 439: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_dir_listing</span>(<span class="ruby-identifier">base</span>, <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">response</span>)
15
+ 440: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@listing_allowed</span>
16
+ 441: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">200</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
17
+ 442: <span class="ruby-identifier">head</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-value str">&quot;text/html&quot;</span>
18
+ 443: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;Directory Listing&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&quot;</span>
19
+ 444: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">entries</span>(<span class="ruby-identifier">dir</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
20
+ 445: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;a href=\&quot;#{base}/#{child}\&quot;&gt;#{child}&lt;/a&gt;&lt;br/&gt;&quot;</span>
21
+ 446: <span class="ruby-keyword kw">end</span>
22
+ 447: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/body&gt;&lt;/html&gt;&quot;</span>
23
+ 448: <span class="ruby-keyword kw">end</span>
24
+ 449: <span class="ruby-keyword kw">else</span>
25
+ 450: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">403</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
26
+ 451: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">&quot;Directory listings not allowed&quot;</span>)
27
+ 452: <span class="ruby-keyword kw">end</span>
28
+ 453: <span class="ruby-keyword kw">end</span>
29
+ 454: <span class="ruby-keyword kw">end</span></pre>
30
+ </body>
31
+ </html>
@@ -0,0 +1,22 @@
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>send_file (Mongrel::DirHandler)</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 457</span>
14
+ 457: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_file</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">response</span>)
15
+ 458: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">200</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
16
+ 459: <span class="ruby-identifier">open</span>(<span class="ruby-identifier">req</span>, <span class="ruby-value str">&quot;r&quot;</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
17
+ 460: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>)
18
+ 461: <span class="ruby-keyword kw">end</span>
19
+ 462: <span class="ruby-keyword kw">end</span>
20
+ 463: <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,39 @@
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>process (Mongrel::DirHandler)</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 466</span>
14
+ 466: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
15
+ 467: <span class="ruby-identifier">req</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-value str">&quot;.&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-value str">'PATH_INFO'</span>], <span class="ruby-ivar">@path</span>)
16
+ 468: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;FIND: #{req}&quot;</span>
17
+ 469: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">req</span>.<span class="ruby-identifier">index</span>(<span class="ruby-ivar">@path</span>) <span class="ruby-operator">!=</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">or</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span> <span class="ruby-identifier">req</span>
18
+ 470: <span class="ruby-comment cmt"># not found, return a 404</span>
19
+ 471: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">404</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
20
+ 472: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;File not found&quot;</span>
21
+ 473: <span class="ruby-keyword kw">end</span>
22
+ 474: <span class="ruby-keyword kw">else</span>
23
+ 475: <span class="ruby-keyword kw">begin</span>
24
+ 476: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span> <span class="ruby-identifier">req</span>
25
+ 477: <span class="ruby-identifier">send_dir_listing</span>(<span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-value str">&quot;REQUEST_URI&quot;</span>],<span class="ruby-identifier">req</span>, <span class="ruby-identifier">response</span>)
26
+ 478: <span class="ruby-keyword kw">else</span>
27
+ 479: <span class="ruby-identifier">send_file</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">response</span>)
28
+ 480: <span class="ruby-keyword kw">end</span>
29
+ 481: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">details</span>
30
+ 482: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">reset</span>
31
+ 483: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">start</span>(<span class="ruby-value">403</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">head</span>,<span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
32
+ 484: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;Error accessing file&quot;</span>
33
+ 485: <span class="ruby-keyword kw">end</span>
34
+ 486: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;ERROR: #{details}&quot;</span>
35
+ 487: <span class="ruby-keyword kw">end</span>
36
+ 488: <span class="ruby-keyword kw">end</span>
37
+ 489: <span class="ruby-keyword kw">end</span></pre>
38
+ </body>
39
+ </html>
@@ -96,8 +96,8 @@ custom message for special URIs.
96
96
  <h3 class="section-bar">Methods</h3>
97
97
 
98
98
  <div class="name-list">
99
- <a href="#M000023">new</a>&nbsp;&nbsp;
100
- <a href="#M000024">process</a>&nbsp;&nbsp;
99
+ <a href="#M000028">new</a>&nbsp;&nbsp;
100
+ <a href="#M000029">process</a>&nbsp;&nbsp;
101
101
  </div>
102
102
  </div>
103
103
 
@@ -119,12 +119,12 @@ custom message for special URIs.
119
119
  <div id="methods">
120
120
  <h3 class="section-bar">Public Class methods</h3>
121
121
 
122
- <div id="method-M000023" class="method-detail">
123
- <a name="M000023"></a>
122
+ <div id="method-M000028" class="method-detail">
123
+ <a name="M000028"></a>
124
124
 
125
125
  <div class="method-heading">
126
- <a href="Error404Handler.src/M000023.html" target="Code" class="method-signature"
127
- onclick="popupCode('Error404Handler.src/M000023.html');return false;">
126
+ <a href="Error404Handler.src/M000028.html" target="Code" class="method-signature"
127
+ onclick="popupCode('Error404Handler.src/M000028.html');return false;">
128
128
  <span class="method-name">new</span><span class="method-args">(msg)</span>
129
129
  </a>
130
130
  </div>
@@ -139,12 +139,12 @@ it&#8217;s pretty efficient.
139
139
 
140
140
  <h3 class="section-bar">Public Instance methods</h3>
141
141
 
142
- <div id="method-M000024" class="method-detail">
143
- <a name="M000024"></a>
142
+ <div id="method-M000029" class="method-detail">
143
+ <a name="M000029"></a>
144
144
 
145
145
  <div class="method-heading">
146
- <a href="Error404Handler.src/M000024.html" target="Code" class="method-signature"
147
- onclick="popupCode('Error404Handler.src/M000024.html');return false;">
146
+ <a href="Error404Handler.src/M000029.html" target="Code" class="method-signature"
147
+ onclick="popupCode('Error404Handler.src/M000029.html');return false;">
148
148
  <span class="method-name">process</span><span class="method-args">(request, response)</span>
149
149
  </a>
150
150
  </div>
@@ -10,9 +10,9 @@
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 153</span>
14
- 153: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">msg</span>)
15
- 154: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">HttpServer</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR_404_RESPONSE</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">msg</span>
16
- 155: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 410</span>
14
+ 410: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">msg</span>)
15
+ 411: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">HttpServer</span><span class="ruby-operator">::</span><span class="ruby-constant">ERROR_404_RESPONSE</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">msg</span>
16
+ 412: <span class="ruby-keyword kw">end</span></pre>
17
17
  </body>
18
18
  </html>
@@ -10,9 +10,9 @@
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 158</span>
14
- 158: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
15
- 159: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-ivar">@response</span>)
16
- 160: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 415</span>
14
+ 415: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
15
+ 416: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-ivar">@response</span>)
16
+ 417: <span class="ruby-keyword kw">end</span></pre>
17
17
  </body>
18
18
  </html>
@@ -78,6 +78,21 @@
78
78
 
79
79
  <div id="contextContent">
80
80
 
81
+ <div id="description">
82
+ <p>
83
+ This class implements a simple way of constructing the HTTP headers
84
+ dynamically via a Hash syntax. Think of it as a write-only Hash. Refer to
85
+ <a href="HttpResponse.html">HttpResponse</a> for information on how this is
86
+ used.
87
+ </p>
88
+ <p>
89
+ One consequence of this write-only nature is that you can write multiple
90
+ headers by just doing them twice (which is sometimes needed in HTTP), but
91
+ that the normal semantics for Hash (where doing an insert replaces) is not
92
+ there.
93
+ </p>
94
+
95
+ </div>
81
96
 
82
97
 
83
98
  </div>
@@ -86,8 +101,8 @@
86
101
  <h3 class="section-bar">Methods</h3>
87
102
 
88
103
  <div class="name-list">
89
- <a href="#M000014">[]=</a>&nbsp;&nbsp;
90
- <a href="#M000013">new</a>&nbsp;&nbsp;
104
+ <a href="#M000018">[]=</a>&nbsp;&nbsp;
105
+ <a href="#M000017">new</a>&nbsp;&nbsp;
91
106
  </div>
92
107
  </div>
93
108
 
@@ -122,12 +137,12 @@
122
137
  <div id="methods">
123
138
  <h3 class="section-bar">Public Class methods</h3>
124
139
 
125
- <div id="method-M000013" class="method-detail">
126
- <a name="M000013"></a>
140
+ <div id="method-M000017" class="method-detail">
141
+ <a name="M000017"></a>
127
142
 
128
143
  <div class="method-heading">
129
- <a href="HeaderOut.src/M000013.html" target="Code" class="method-signature"
130
- onclick="popupCode('HeaderOut.src/M000013.html');return false;">
144
+ <a href="HeaderOut.src/M000017.html" target="Code" class="method-signature"
145
+ onclick="popupCode('HeaderOut.src/M000017.html');return false;">
131
146
  <span class="method-name">new</span><span class="method-args">(out)</span>
132
147
  </a>
133
148
  </div>
@@ -138,17 +153,20 @@
138
153
 
139
154
  <h3 class="section-bar">Public Instance methods</h3>
140
155
 
141
- <div id="method-M000014" class="method-detail">
142
- <a name="M000014"></a>
156
+ <div id="method-M000018" class="method-detail">
157
+ <a name="M000018"></a>
143
158
 
144
159
  <div class="method-heading">
145
- <a href="HeaderOut.src/M000014.html" target="Code" class="method-signature"
146
- onclick="popupCode('HeaderOut.src/M000014.html');return false;">
160
+ <a href="HeaderOut.src/M000018.html" target="Code" class="method-signature"
161
+ onclick="popupCode('HeaderOut.src/M000018.html');return false;">
147
162
  <span class="method-name">[]=</span><span class="method-args">(key,value)</span>
148
163
  </a>
149
164
  </div>
150
165
 
151
166
  <div class="method-description">
167
+ <p>
168
+ Simply writes &quot;#{key}: #{value}&quot; to an output buffer.
169
+ </p>
152
170
  </div>
153
171
  </div>
154
172
 
@@ -10,9 +10,9 @@
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 88</span>
14
- 88: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">out</span>)
15
- 89: <span class="ruby-ivar">@out</span> = <span class="ruby-identifier">out</span>
16
- 90: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 169</span>
14
+ 169: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">out</span>)
15
+ 170: <span class="ruby-ivar">@out</span> = <span class="ruby-identifier">out</span>
16
+ 171: <span class="ruby-keyword kw">end</span></pre>
17
17
  </body>
18
18
  </html>
@@ -0,0 +1,21 @@
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>[]= (Mongrel::HeaderOut)</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 174</span>
14
+ 174: <span class="ruby-keyword kw">def</span><span class="ruby-operator">[]=</span>(<span class="ruby-identifier">key</span>,<span class="ruby-identifier">value</span>)
15
+ 175: <span class="ruby-ivar">@out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">key</span>)
16
+ 176: <span class="ruby-ivar">@out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">&quot;: &quot;</span>)
17
+ 177: <span class="ruby-ivar">@out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">value</span>)
18
+ 178: <span class="ruby-ivar">@out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">&quot;\r\n&quot;</span>)
19
+ 179: <span class="ruby-keyword kw">end</span></pre>
20
+ </body>
21
+ </html>
@@ -95,7 +95,7 @@ back a response. Look at the <a href="HttpRequest.html">HttpRequest</a> and
95
95
  <h3 class="section-bar">Methods</h3>
96
96
 
97
97
  <div class="name-list">
98
- <a href="#M000019">process</a>&nbsp;&nbsp;
98
+ <a href="#M000023">process</a>&nbsp;&nbsp;
99
99
  </div>
100
100
  </div>
101
101
 
@@ -110,19 +110,6 @@ back a response. Look at the <a href="HttpRequest.html">HttpRequest</a> and
110
110
 
111
111
 
112
112
 
113
- <div id="attribute-list">
114
- <h3 class="section-bar">Attributes</h3>
115
-
116
- <div class="name-list">
117
- <table>
118
- <tr class="top-aligned-row context-row">
119
- <td class="context-item-name">script_name</td>
120
- <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
121
- <td class="context-item-desc"></td>
122
- </tr>
123
- </table>
124
- </div>
125
- </div>
126
113
 
127
114
 
128
115
 
@@ -130,12 +117,12 @@ back a response. Look at the <a href="HttpRequest.html">HttpRequest</a> and
130
117
  <div id="methods">
131
118
  <h3 class="section-bar">Public Instance methods</h3>
132
119
 
133
- <div id="method-M000019" class="method-detail">
134
- <a name="M000019"></a>
120
+ <div id="method-M000023" class="method-detail">
121
+ <a name="M000023"></a>
135
122
 
136
123
  <div class="method-heading">
137
- <a href="HttpHandler.src/M000019.html" target="Code" class="method-signature"
138
- onclick="popupCode('HttpHandler.src/M000019.html');return false;">
124
+ <a href="HttpHandler.src/M000023.html" target="Code" class="method-signature"
125
+ onclick="popupCode('HttpHandler.src/M000023.html');return false;">
139
126
  <span class="method-name">process</span><span class="method-args">(request, response)</span>
140
127
  </a>
141
128
  </div>
@@ -10,8 +10,8 @@
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 141</span>
14
- 141: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
15
- 142: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 262</span>
14
+ 262: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>)
15
+ 263: <span class="ruby-keyword kw">end</span></pre>
16
16
  </body>
17
17
  </html>
@@ -88,9 +88,9 @@ HttpRequest.body which is a string containing the request body (raw for
88
88
  now).
89
89
  </p>
90
90
  <p>
91
- <a href="../Mongrel.html">Mongrel</a> really only support small-ish request
92
- bodies right now since really huge ones have to be completely read off the
93
- wire and put into a string. Later there will be several options for
91
+ <a href="../Mongrel.html">Mongrel</a> really only supports small-ish
92
+ request bodies right now since really huge ones have to be completely read
93
+ off the wire and put into a string. Later there will be several options for
94
94
  efficiently handling large file uploads.
95
95
  </p>
96
96
 
@@ -103,7 +103,7 @@ efficiently handling large file uploads.
103
103
  <h3 class="section-bar">Methods</h3>
104
104
 
105
105
  <div class="name-list">
106
- <a href="#M000025">new</a>&nbsp;&nbsp;
106
+ <a href="#M000030">new</a>&nbsp;&nbsp;
107
107
  </div>
108
108
  </div>
109
109
 
@@ -143,12 +143,12 @@ efficiently handling large file uploads.
143
143
  <div id="methods">
144
144
  <h3 class="section-bar">Public Class methods</h3>
145
145
 
146
- <div id="method-M000025" class="method-detail">
147
- <a name="M000025"></a>
146
+ <div id="method-M000030" class="method-detail">
147
+ <a name="M000030"></a>
148
148
 
149
149
  <div class="method-heading">
150
- <a href="HttpRequest.src/M000025.html" target="Code" class="method-signature"
151
- onclick="popupCode('HttpRequest.src/M000025.html');return false;">
150
+ <a href="HttpRequest.src/M000030.html" target="Code" class="method-signature"
151
+ onclick="popupCode('HttpRequest.src/M000030.html');return false;">
152
152
  <span class="method-name">new</span><span class="method-args">(params, initial_body, socket)</span>
153
153
  </a>
154
154
  </div>
@@ -0,0 +1,31 @@
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::HttpRequest)</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 140</span>
14
+ 140: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">initial_body</span>, <span class="ruby-identifier">socket</span>)
15
+ 141: <span class="ruby-ivar">@body</span> = <span class="ruby-identifier">initial_body</span> <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;&quot;</span>
16
+ 142: <span class="ruby-ivar">@params</span> = <span class="ruby-identifier">params</span>
17
+ 143: <span class="ruby-ivar">@socket</span> = <span class="ruby-identifier">socket</span>
18
+ 144:
19
+ 145: <span class="ruby-comment cmt"># fix up the CGI requirements</span>
20
+ 146: <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">CONTENT_LENGTH</span>] = <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP_CONTENT_LENGTH</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
21
+ 147: <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">CONTENT_TYPE</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP_CONTENT_TYPE</span>]
22
+ 148:
23
+ 149: <span class="ruby-comment cmt"># now, if the initial_body isn't long enough for the content length we have to fill it</span>
24
+ 150: <span class="ruby-comment cmt"># TODO: adapt for big ass stuff by writing to a temp file</span>
25
+ 151: <span class="ruby-identifier">clen</span> = <span class="ruby-identifier">params</span>[<span class="ruby-constant">Const</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP_CONTENT_LENGTH</span>].<span class="ruby-identifier">to_i</span>
26
+ 152: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">clen</span>
27
+ 153: <span class="ruby-ivar">@body</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">clen</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">length</span>)
28
+ 154: <span class="ruby-keyword kw">end</span>
29
+ 155: <span class="ruby-keyword kw">end</span></pre>
30
+ </body>
31
+ </html>
@@ -78,6 +78,51 @@
78
78
 
79
79
  <div id="contextContent">
80
80
 
81
+ <div id="description">
82
+ <p>
83
+ Writes and controls your response to the client using the HTTP/1.1
84
+ specification. You use it by simply doing:
85
+ </p>
86
+ <pre>
87
+ response.start(200) do |head,out|
88
+ head['Content-Type'] = 'text/plain'
89
+ out.write(&quot;hello\n&quot;)
90
+ end
91
+ </pre>
92
+ <p>
93
+ The parameter to start is the response code&#8212;which <a
94
+ href="../Mongrel.html">Mongrel</a> will translate for you based on
95
+ HTTP_STATUS_CODES. The head parameter is how you write custom headers. The
96
+ out parameter is where you write your body. The default status code for <a
97
+ href="HttpResponse.html#M000025">HttpResponse.start</a> is 200 so the above
98
+ example is redundant.
99
+ </p>
100
+ <p>
101
+ As you can see, it&#8217;s just like using a Hash and as you do this it
102
+ writes the proper header to the output on the fly. You can even intermix
103
+ specifying headers and writing content. The <a
104
+ href="HttpResponse.html">HttpResponse</a> class with write the things in
105
+ the proper order once the HttpResponse.block is ended.
106
+ </p>
107
+ <p>
108
+ You may also work the <a href="HttpResponse.html">HttpResponse</a> object
109
+ directly using the various attributes available for the raw socket, body,
110
+ header, and status codes. If you do this you&#8217;re on your own. A design
111
+ decision was made to force the client to not pipeline requests. HTTP/1.1
112
+ pipelining really kills the performance due to how it has to be handled and
113
+ how unclear the standard is. To fix this the <a
114
+ href="HttpResponse.html">HttpResponse</a> gives a &quot;Connection:
115
+ close&quot; header which forces the client to close right away. The bonus
116
+ for this is that it gives a pretty nice speed boost to most clients since
117
+ they can close their connection immediately.
118
+ </p>
119
+ <p>
120
+ One additional caveat is that you don&#8217;t have to specify the
121
+ Content-length header as the <a href="HttpResponse.html">HttpResponse</a>
122
+ will write this for you based on the out length.
123
+ </p>
124
+
125
+ </div>
81
126
 
82
127
 
83
128
  </div>
@@ -86,9 +131,10 @@
86
131
  <h3 class="section-bar">Methods</h3>
87
132
 
88
133
  <div class="name-list">
89
- <a href="#M000022">finished</a>&nbsp;&nbsp;
90
- <a href="#M000020">new</a>&nbsp;&nbsp;
91
- <a href="#M000021">start</a>&nbsp;&nbsp;
134
+ <a href="#M000027">finished</a>&nbsp;&nbsp;
135
+ <a href="#M000024">new</a>&nbsp;&nbsp;
136
+ <a href="#M000026">reset</a>&nbsp;&nbsp;
137
+ <a href="#M000025">start</a>&nbsp;&nbsp;
92
138
  </div>
93
139
  </div>
94
140
 
@@ -143,12 +189,12 @@
143
189
  <div id="methods">
144
190
  <h3 class="section-bar">Public Class methods</h3>
145
191
 
146
- <div id="method-M000020" class="method-detail">
147
- <a name="M000020"></a>
192
+ <div id="method-M000024" class="method-detail">
193
+ <a name="M000024"></a>
148
194
 
149
195
  <div class="method-heading">
150
- <a href="HttpResponse.src/M000020.html" target="Code" class="method-signature"
151
- onclick="popupCode('HttpResponse.src/M000020.html');return false;">
196
+ <a href="HttpResponse.src/M000024.html" target="Code" class="method-signature"
197
+ onclick="popupCode('HttpResponse.src/M000024.html');return false;">
152
198
  <span class="method-name">new</span><span class="method-args">(socket)</span>
153
199
  </a>
154
200
  </div>
@@ -159,31 +205,59 @@
159
205
 
160
206
  <h3 class="section-bar">Public Instance methods</h3>
161
207
 
162
- <div id="method-M000022" class="method-detail">
163
- <a name="M000022"></a>
208
+ <div id="method-M000027" class="method-detail">
209
+ <a name="M000027"></a>
164
210
 
165
211
  <div class="method-heading">
166
- <a href="HttpResponse.src/M000022.html" target="Code" class="method-signature"
167
- onclick="popupCode('HttpResponse.src/M000022.html');return false;">
212
+ <a href="HttpResponse.src/M000027.html" target="Code" class="method-signature"
213
+ onclick="popupCode('HttpResponse.src/M000027.html');return false;">
168
214
  <span class="method-name">finished</span><span class="method-args">()</span>
169
215
  </a>
170
216
  </div>
171
217
 
172
218
  <div class="method-description">
219
+ <p>
220
+ This takes whatever has been done to header and body and then writes it in
221
+ the proper format to make an HTTP/1.1 response.
222
+ </p>
223
+ </div>
224
+ </div>
225
+
226
+ <div id="method-M000026" class="method-detail">
227
+ <a name="M000026"></a>
228
+
229
+ <div class="method-heading">
230
+ <a href="HttpResponse.src/M000026.html" target="Code" class="method-signature"
231
+ onclick="popupCode('HttpResponse.src/M000026.html');return false;">
232
+ <span class="method-name">reset</span><span class="method-args">()</span>
233
+ </a>
234
+ </div>
235
+
236
+ <div class="method-description">
237
+ <p>
238
+ Primarily used in exception handling to reset the response output in order
239
+ to write an alternative response.
240
+ </p>
173
241
  </div>
174
242
  </div>
175
243
 
176
- <div id="method-M000021" class="method-detail">
177
- <a name="M000021"></a>
244
+ <div id="method-M000025" class="method-detail">
245
+ <a name="M000025"></a>
178
246
 
179
247
  <div class="method-heading">
180
- <a href="HttpResponse.src/M000021.html" target="Code" class="method-signature"
181
- onclick="popupCode('HttpResponse.src/M000021.html');return false;">
248
+ <a href="HttpResponse.src/M000025.html" target="Code" class="method-signature"
249
+ onclick="popupCode('HttpResponse.src/M000025.html');return false;">
182
250
  <span class="method-name">start</span><span class="method-args">(status=200) {|@header, @body| ...}</span>
183
251
  </a>
184
252
  </div>
185
253
 
186
254
  <div class="method-description">
255
+ <p>
256
+ Receives a block passing it the header and body for you to work with. When
257
+ the block is finished it writes everything you&#8217;ve done to the socket
258
+ in the proper order. This lets you intermix header and body content as
259
+ needed.
260
+ </p>
187
261
  </div>
188
262
  </div>
189
263