mongrel 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +10 -2
- data/Rakefile +1 -1
- data/doc/rdoc/classes/Mongrel.html +11 -1
- data/doc/rdoc/classes/Mongrel/Const.html +342 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.html +201 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000008.html +20 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000009.html +31 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000010.html +22 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000011.html +39 -0
- data/doc/rdoc/classes/Mongrel/Error404Handler.html +10 -10
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000023.html → M000028.html} +4 -4
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000024.html → M000029.html} +4 -4
- data/doc/rdoc/classes/Mongrel/HeaderOut.html +28 -10
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000013.html → M000017.html} +4 -4
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000018.html +21 -0
- data/doc/rdoc/classes/Mongrel/HttpHandler.html +5 -18
- data/doc/rdoc/classes/Mongrel/HttpHandler.src/{M000019.html → M000023.html} +3 -3
- data/doc/rdoc/classes/Mongrel/HttpRequest.html +8 -8
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000030.html +31 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.html +89 -15
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000020.html → M000024.html} +7 -7
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000021.html → M000025.html} +6 -6
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000026.html +19 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/{M000022.html → M000027.html} +11 -11
- data/doc/rdoc/classes/Mongrel/HttpServer.html +32 -76
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000012.html +18 -5
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000013.html +64 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000010.html → M000014.html} +9 -8
- data/doc/rdoc/classes/Mongrel/HttpServer.src/{M000011.html → M000015.html} +4 -4
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000016.html +18 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.html +25 -23
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000015.html → M000019.html} +0 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000016.html → M000020.html} +3 -2
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000017.html → M000021.html} +0 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/{M000018.html → M000022.html} +1 -1
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README.html +14 -2
- data/doc/rdoc/files/ext/http11/http11_c.html +1 -1
- data/doc/rdoc/files/lib/mongrel_rb.html +1 -1
- data/doc/rdoc/fr_class_index.html +2 -0
- data/doc/rdoc/fr_method_index.html +23 -18
- data/examples/simpletest.rb +2 -1
- data/ext/http11/http11.c +10 -9
- data/ext/http11/http11_parser.c +10 -10
- data/ext/http11/http11_parser.h +5 -1
- data/lib/#mongrel.rb# +493 -0
- data/lib/mongrel.rb +242 -48
- metadata +28 -19
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000014.html +0 -21
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000025.html +0 -30
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000008.html +0 -26
- 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">"DIR: #@path"</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">"text/html"</span>
|
18
|
+
443: <span class="ruby-identifier">out</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"<html><head><title>Directory Listing</title></head><body>"</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"><<</span> <span class="ruby-node">"<a href=\"#{base}/#{child}\">#{child}</a><br/>"</span>
|
21
|
+
446: <span class="ruby-keyword kw">end</span>
|
22
|
+
447: <span class="ruby-identifier">out</span> <span class="ruby-operator"><<</span> <span class="ruby-value str">"</body></html>"</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">"Directory listings not allowed"</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">"r"</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">"."</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">"FIND: #{req}"</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"><<</span> <span class="ruby-value str">"File not found"</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">"REQUEST_URI"</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">></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"><<</span> <span class="ruby-value str">"Error accessing file"</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">"ERROR: #{details}"</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="#
|
100
|
-
<a href="#
|
99
|
+
<a href="#M000028">new</a>
|
100
|
+
<a href="#M000029">process</a>
|
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-
|
123
|
-
<a name="
|
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/
|
127
|
-
onclick="popupCode('Error404Handler.src/
|
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’s pretty efficient.
|
|
139
139
|
|
140
140
|
<h3 class="section-bar">Public Instance methods</h3>
|
141
141
|
|
142
|
-
<div id="method-
|
143
|
-
<a name="
|
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/
|
147
|
-
onclick="popupCode('Error404Handler.src/
|
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
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
14
|
-
|
15
|
-
|
16
|
-
|
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="#
|
90
|
-
<a href="#
|
104
|
+
<a href="#M000018">[]=</a>
|
105
|
+
<a href="#M000017">new</a>
|
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-
|
126
|
-
<a name="
|
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/
|
130
|
-
onclick="popupCode('HeaderOut.src/
|
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-
|
142
|
-
<a name="
|
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/
|
146
|
-
onclick="popupCode('HeaderOut.src/
|
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 "#{key}: #{value}" 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>
|
14
|
-
|
15
|
-
|
16
|
-
|
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">": "</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">"\r\n"</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="#
|
98
|
+
<a href="#M000023">process</a>
|
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"> [RW] </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-
|
134
|
-
<a name="
|
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/
|
138
|
-
onclick="popupCode('HttpHandler.src/
|
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
|
14
|
-
|
15
|
-
|
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
|
92
|
-
bodies right now since really huge ones have to be completely read
|
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="#
|
106
|
+
<a href="#M000030">new</a>
|
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-
|
147
|
-
<a name="
|
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/
|
151
|
-
onclick="popupCode('HttpRequest.src/
|
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">""</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"><</span> <span class="ruby-identifier">clen</span>
|
27
|
+
153: <span class="ruby-ivar">@body</span> <span class="ruby-operator"><<</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("hello\n")
|
90
|
+
end
|
91
|
+
</pre>
|
92
|
+
<p>
|
93
|
+
The parameter to start is the response code—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’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’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 "Connection:
|
115
|
+
close" 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’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="#
|
90
|
-
<a href="#
|
91
|
-
<a href="#
|
134
|
+
<a href="#M000027">finished</a>
|
135
|
+
<a href="#M000024">new</a>
|
136
|
+
<a href="#M000026">reset</a>
|
137
|
+
<a href="#M000025">start</a>
|
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-
|
147
|
-
<a name="
|
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/
|
151
|
-
onclick="popupCode('HttpResponse.src/
|
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-
|
163
|
-
<a name="
|
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/
|
167
|
-
onclick="popupCode('HttpResponse.src/
|
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-
|
177
|
-
<a name="
|
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/
|
181
|
-
onclick="popupCode('HttpResponse.src/
|
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’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
|
|