mongrel 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/README +4 -1
  2. data/Rakefile +1 -1
  3. data/bin/mongrel_rails +77 -24
  4. data/doc/rdoc/classes/Mongrel.html +0 -30
  5. data/doc/rdoc/classes/Mongrel/DirHandler.html +45 -26
  6. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000022.html +20 -0
  7. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000023.html +29 -7
  8. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000024.html +27 -29
  9. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000025.html +18 -27
  10. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000026.html +25 -18
  11. data/doc/rdoc/classes/Mongrel/DirHandler.src/M000027.html +5 -25
  12. data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000047.html +4 -4
  13. data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000048.html +4 -4
  14. data/doc/rdoc/classes/Mongrel/HttpParser.html +35 -35
  15. data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000022.html → M000015.html} +6 -6
  16. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000016.html +6 -5
  17. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000017.html +7 -7
  18. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000018.html +20 -8
  19. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000019.html +6 -20
  20. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000020.html +5 -5
  21. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000021.html +6 -5
  22. data/doc/rdoc/classes/Mongrel/HttpServer.html +1 -1
  23. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000028.html +16 -9
  24. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000029.html +49 -49
  25. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000030.html +9 -9
  26. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000031.html +4 -4
  27. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000032.html +4 -4
  28. data/doc/rdoc/created.rid +1 -1
  29. data/doc/rdoc/files/README.html +7 -2
  30. data/doc/rdoc/files/lib/mongrel_rb.html +1 -1
  31. data/doc/rdoc/fr_method_index.html +15 -15
  32. data/lib/mongrel.rb +17 -8
  33. metadata +4 -5
  34. data/doc/rdoc/classes/Mongrel.src/M000015.html +0 -18
@@ -5,36 +5,27 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>send_dir_listing (Mongrel::DirHandler)</title>
8
+ <title>send_file (Mongrel::DirHandler)</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
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 503</span>
14
- 503: <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
- 504: <span class="ruby-comment cmt"># take off any trailing / so the links come out right</span>
16
- 505: <span class="ruby-identifier">base</span>.<span class="ruby-identifier">chop!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">base</span>[<span class="ruby-value">-1</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;/&quot;</span>[<span class="ruby-value">-1</span>]
17
- 506:
18
- 507: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@listing_allowed</span>
19
- 508: <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>
20
- 509: <span class="ruby-identifier">head</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-value str">&quot;text/html&quot;</span>
21
- 510: <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>
22
- 511: <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>
23
- 512: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">child</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;.&quot;</span>
24
- 513:
25
- 514: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">child</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;..&quot;</span>
26
- 515: <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;Up to parent..&lt;/a&gt;&lt;br/&gt;&quot;</span>
27
- 516: <span class="ruby-keyword kw">else</span>
28
- 517: <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>
29
- 518: <span class="ruby-keyword kw">end</span>
30
- 519: <span class="ruby-keyword kw">end</span>
31
- 520: <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>
32
- 521: <span class="ruby-keyword kw">end</span>
33
- 522: <span class="ruby-keyword kw">else</span>
34
- 523: <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>
35
- 524: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">&quot;Directory listings not allowed&quot;</span>)
36
- 525: <span class="ruby-keyword kw">end</span>
37
- 526: <span class="ruby-keyword kw">end</span>
38
- 527: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 539</span>
14
+ 539: <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
+ 540: <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
+ 541: <span class="ruby-comment cmt"># set the mime type from our map based on the ending</span>
17
+ 542: <span class="ruby-identifier">dot_at</span> = <span class="ruby-identifier">req</span>.<span class="ruby-identifier">rindex</span>(<span class="ruby-value str">&quot;.&quot;</span>)
18
+ 543: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dot_at</span>
19
+ 544: <span class="ruby-identifier">ext</span> = <span class="ruby-identifier">req</span>[<span class="ruby-identifier">dot_at</span> <span class="ruby-operator">..</span> <span class="ruby-value">-1</span>]
20
+ 545: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-identifier">ext</span>]
21
+ 546: <span class="ruby-identifier">head</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-identifier">ext</span>]
22
+ 547: <span class="ruby-keyword kw">end</span>
23
+ 548: <span class="ruby-keyword kw">end</span>
24
+ 549:
25
+ 550: <span class="ruby-identifier">open</span>(<span class="ruby-identifier">req</span>, <span class="ruby-value str">&quot;rb&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>
26
+ 551: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>)
27
+ 552: <span class="ruby-keyword kw">end</span>
28
+ 553: <span class="ruby-keyword kw">end</span>
29
+ 554: <span class="ruby-keyword kw">end</span></pre>
39
30
  </body>
40
31
  </html>
@@ -5,27 +5,34 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>send_file (Mongrel::DirHandler)</title>
8
+ <title>process (Mongrel::DirHandler)</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
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 532</span>
14
- 532: <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
- 533: <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
- 534: <span class="ruby-comment cmt"># set the mime type from our map based on the ending</span>
17
- 535: <span class="ruby-identifier">dot_at</span> = <span class="ruby-identifier">req</span>.<span class="ruby-identifier">rindex</span>(<span class="ruby-value str">&quot;.&quot;</span>)
18
- 536: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dot_at</span>
19
- 537: <span class="ruby-identifier">ext</span> = <span class="ruby-identifier">req</span>[<span class="ruby-identifier">dot_at</span> <span class="ruby-operator">..</span> <span class="ruby-value">-1</span>]
20
- 538: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-identifier">ext</span>]
21
- 539: <span class="ruby-identifier">head</span>[<span class="ruby-value str">'Content-Type'</span>] = <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-identifier">ext</span>]
22
- 540: <span class="ruby-keyword kw">end</span>
23
- 541: <span class="ruby-keyword kw">end</span>
24
- 542:
25
- 543: <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>
26
- 544: <span class="ruby-identifier">out</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>)
27
- 545: <span class="ruby-keyword kw">end</span>
28
- 546: <span class="ruby-keyword kw">end</span>
29
- 547: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 559</span>
14
+ 559: <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
+ 560: <span class="ruby-identifier">req</span> = <span class="ruby-identifier">can_serve</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-value str">'PATH_INFO'</span>]
16
+ 561: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">req</span>
17
+ 562: <span class="ruby-comment cmt"># not found, return a 404</span>
18
+ 563: <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>
19
+ 564: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;File not found&quot;</span>
20
+ 565: <span class="ruby-keyword kw">end</span>
21
+ 566: <span class="ruby-keyword kw">else</span>
22
+ 567: <span class="ruby-keyword kw">begin</span>
23
+ 568: <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>
24
+ 569: <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>)
25
+ 570: <span class="ruby-keyword kw">else</span>
26
+ 571: <span class="ruby-identifier">send_file</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">response</span>)
27
+ 572: <span class="ruby-keyword kw">end</span>
28
+ 573: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">details</span>
29
+ 574: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">reset</span>
30
+ 575: <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>
31
+ 576: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;Error accessing file: #{details}&quot;</span>
32
+ 577: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">details</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
33
+ 578: <span class="ruby-keyword kw">end</span>
34
+ 579: <span class="ruby-keyword kw">end</span>
35
+ 580: <span class="ruby-keyword kw">end</span>
36
+ 581: <span class="ruby-keyword kw">end</span></pre>
30
37
  </body>
31
38
  </html>
@@ -5,34 +5,14 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>process (Mongrel::DirHandler)</title>
8
+ <title>add_mime_type (Mongrel::DirHandler)</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
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 552</span>
14
- 552: <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
- 553: <span class="ruby-identifier">req</span> = <span class="ruby-identifier">can_serve</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">params</span>[<span class="ruby-value str">'PATH_INFO'</span>]
16
- 554: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">req</span>
17
- 555: <span class="ruby-comment cmt"># not found, return a 404</span>
18
- 556: <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>
19
- 557: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;File not found&quot;</span>
20
- 558: <span class="ruby-keyword kw">end</span>
21
- 559: <span class="ruby-keyword kw">else</span>
22
- 560: <span class="ruby-keyword kw">begin</span>
23
- 561: <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>
24
- 562: <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>)
25
- 563: <span class="ruby-keyword kw">else</span>
26
- 564: <span class="ruby-identifier">send_file</span>(<span class="ruby-identifier">req</span>, <span class="ruby-identifier">response</span>)
27
- 565: <span class="ruby-keyword kw">end</span>
28
- 566: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">details</span>
29
- 567: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">reset</span>
30
- 568: <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>
31
- 569: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;Error accessing file: #{details}&quot;</span>
32
- 570: <span class="ruby-identifier">out</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">details</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;\n&quot;</span>)
33
- 571: <span class="ruby-keyword kw">end</span>
34
- 572: <span class="ruby-keyword kw">end</span>
35
- 573: <span class="ruby-keyword kw">end</span>
36
- 574: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 585</span>
14
+ 585: <span class="ruby-keyword kw">def</span> <span class="ruby-constant">DirHandler</span><span class="ruby-operator">::</span><span class="ruby-identifier">add_mime_type</span>(<span class="ruby-identifier">extension</span>, <span class="ruby-identifier">type</span>)
15
+ 586: <span class="ruby-constant">MIME_TYPES</span>[<span class="ruby-identifier">extension</span>] = <span class="ruby-identifier">type</span>
16
+ 587: <span class="ruby-keyword kw">end</span></pre>
37
17
  </body>
38
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 424</span>
14
- 424: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">msg</span>)
15
- 425: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Const</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
- 426: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 431</span>
14
+ 431: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">msg</span>)
15
+ 432: <span class="ruby-ivar">@response</span> = <span class="ruby-constant">Const</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
+ 433: <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 429</span>
14
- 429: <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
- 430: <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
- 431: <span class="ruby-keyword kw">end</span></pre>
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 436</span>
14
+ 436: <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
+ 437: <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
+ 438: <span class="ruby-keyword kw">end</span></pre>
17
17
  </body>
18
18
  </html>
@@ -86,13 +86,13 @@
86
86
  <h3 class="section-bar">Methods</h3>
87
87
 
88
88
  <div class="name-list">
89
- <a href="#M000020">error?</a>&nbsp;&nbsp;
90
- <a href="#M000019">execute</a>&nbsp;&nbsp;
91
- <a href="#M000018">finish</a>&nbsp;&nbsp;
92
- <a href="#M000021">finished?</a>&nbsp;&nbsp;
93
- <a href="#M000016">new</a>&nbsp;&nbsp;
94
- <a href="#M000022">nread</a>&nbsp;&nbsp;
95
- <a href="#M000017">reset</a>&nbsp;&nbsp;
89
+ <a href="#M000019">error?</a>&nbsp;&nbsp;
90
+ <a href="#M000018">execute</a>&nbsp;&nbsp;
91
+ <a href="#M000017">finish</a>&nbsp;&nbsp;
92
+ <a href="#M000020">finished?</a>&nbsp;&nbsp;
93
+ <a href="#M000015">new</a>&nbsp;&nbsp;
94
+ <a href="#M000021">nread</a>&nbsp;&nbsp;
95
+ <a href="#M000016">reset</a>&nbsp;&nbsp;
96
96
  </div>
97
97
  </div>
98
98
 
@@ -114,12 +114,12 @@
114
114
  <div id="methods">
115
115
  <h3 class="section-bar">Public Class methods</h3>
116
116
 
117
- <div id="method-M000016" class="method-detail">
118
- <a name="M000016"></a>
117
+ <div id="method-M000015" class="method-detail">
118
+ <a name="M000015"></a>
119
119
 
120
120
  <div class="method-heading">
121
- <a href="HttpParser.src/M000016.html" target="Code" class="method-signature"
122
- onclick="popupCode('HttpParser.src/M000016.html');return false;">
121
+ <a href="HttpParser.src/M000015.html" target="Code" class="method-signature"
122
+ onclick="popupCode('HttpParser.src/M000015.html');return false;">
123
123
  <span class="method-name">parser.new &rarr; parser<br />
124
124
  </span>
125
125
  </a>
@@ -134,12 +134,12 @@ Creates a new parser.
134
134
 
135
135
  <h3 class="section-bar">Public Instance methods</h3>
136
136
 
137
- <div id="method-M000020" class="method-detail">
138
- <a name="M000020"></a>
137
+ <div id="method-M000019" class="method-detail">
138
+ <a name="M000019"></a>
139
139
 
140
140
  <div class="method-heading">
141
- <a href="HttpParser.src/M000020.html" target="Code" class="method-signature"
142
- onclick="popupCode('HttpParser.src/M000020.html');return false;">
141
+ <a href="HttpParser.src/M000019.html" target="Code" class="method-signature"
142
+ onclick="popupCode('HttpParser.src/M000019.html');return false;">
143
143
  <span class="method-name">parser.error? &rarr; true/false<br />
144
144
  </span>
145
145
  </a>
@@ -152,12 +152,12 @@ Tells you whether the parser is in an error state.
152
152
  </div>
153
153
  </div>
154
154
 
155
- <div id="method-M000019" class="method-detail">
156
- <a name="M000019"></a>
155
+ <div id="method-M000018" class="method-detail">
156
+ <a name="M000018"></a>
157
157
 
158
158
  <div class="method-heading">
159
- <a href="HttpParser.src/M000019.html" target="Code" class="method-signature"
160
- onclick="popupCode('HttpParser.src/M000019.html');return false;">
159
+ <a href="HttpParser.src/M000018.html" target="Code" class="method-signature"
160
+ onclick="popupCode('HttpParser.src/M000018.html');return false;">
161
161
  <span class="method-name">parser.execute(req_hash, data) &rarr; Integer<br />
162
162
  </span>
163
163
  </a>
@@ -180,12 +180,12 @@ handling block.
180
180
  </div>
181
181
  </div>
182
182
 
183
- <div id="method-M000018" class="method-detail">
184
- <a name="M000018"></a>
183
+ <div id="method-M000017" class="method-detail">
184
+ <a name="M000017"></a>
185
185
 
186
186
  <div class="method-heading">
187
- <a href="HttpParser.src/M000018.html" target="Code" class="method-signature"
188
- onclick="popupCode('HttpParser.src/M000018.html');return false;">
187
+ <a href="HttpParser.src/M000017.html" target="Code" class="method-signature"
188
+ onclick="popupCode('HttpParser.src/M000017.html');return false;">
189
189
  <span class="method-name">parser.finish &rarr; true/false<br />
190
190
  </span>
191
191
  </a>
@@ -199,12 +199,12 @@ You should call reset after finish it or bad things will happen.
199
199
  </div>
200
200
  </div>
201
201
 
202
- <div id="method-M000021" class="method-detail">
203
- <a name="M000021"></a>
202
+ <div id="method-M000020" class="method-detail">
203
+ <a name="M000020"></a>
204
204
 
205
205
  <div class="method-heading">
206
- <a href="HttpParser.src/M000021.html" target="Code" class="method-signature"
207
- onclick="popupCode('HttpParser.src/M000021.html');return false;">
206
+ <a href="HttpParser.src/M000020.html" target="Code" class="method-signature"
207
+ onclick="popupCode('HttpParser.src/M000020.html');return false;">
208
208
  <span class="method-name">parser.finished? &rarr; true/false<br />
209
209
  </span>
210
210
  </a>
@@ -217,12 +217,12 @@ Tells you whether the parser is finished or not and in a good state.
217
217
  </div>
218
218
  </div>
219
219
 
220
- <div id="method-M000022" class="method-detail">
221
- <a name="M000022"></a>
220
+ <div id="method-M000021" class="method-detail">
221
+ <a name="M000021"></a>
222
222
 
223
223
  <div class="method-heading">
224
- <a href="HttpParser.src/M000022.html" target="Code" class="method-signature"
225
- onclick="popupCode('HttpParser.src/M000022.html');return false;">
224
+ <a href="HttpParser.src/M000021.html" target="Code" class="method-signature"
225
+ onclick="popupCode('HttpParser.src/M000021.html');return false;">
226
226
  <span class="method-name">parser.nread &rarr; Integer<br />
227
227
  </span>
228
228
  </a>
@@ -237,12 +237,12 @@ execute is called.
237
237
  </div>
238
238
  </div>
239
239
 
240
- <div id="method-M000017" class="method-detail">
241
- <a name="M000017"></a>
240
+ <div id="method-M000016" class="method-detail">
241
+ <a name="M000016"></a>
242
242
 
243
243
  <div class="method-heading">
244
- <a href="HttpParser.src/M000017.html" target="Code" class="method-signature"
245
- onclick="popupCode('HttpParser.src/M000017.html');return false;">
244
+ <a href="HttpParser.src/M000016.html" target="Code" class="method-signature"
245
+ onclick="popupCode('HttpParser.src/M000016.html');return false;">
246
246
  <span class="method-name">parser.reset &rarr; nil<br />
247
247
  </span>
248
248
  </a>
@@ -5,24 +5,24 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>nread (Mongrel::HttpParser)</title>
8
+ <title>new (Mongrel::HttpParser)</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
13
  <pre>/**
14
14
  * call-seq:
15
- * parser.nread -&gt; Integer
15
+ * parser.new -&gt; parser
16
16
  *
17
- * Returns the amount of data processed so far during this processing cycle. It is
18
- * set to 0 on initialize or reset calls and is incremented each time execute is called.
17
+ * Creates a new parser.
19
18
  */
20
- VALUE HttpParser_nread(VALUE self)
19
+ VALUE HttpParser_init(VALUE self)
21
20
  {
22
21
  http_parser *http = NULL;
23
22
  DATA_GET(self, http_parser, http);
23
+ http_parser_init(http);
24
24
 
25
- return INT2FIX(http-&gt;nread);
25
+ return self;
26
26
  }</pre>
27
27
  </body>
28
28
  </html>
@@ -5,24 +5,25 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>new (Mongrel::HttpParser)</title>
8
+ <title>reset (Mongrel::HttpParser)</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
13
  <pre>/**
14
14
  * call-seq:
15
- * parser.new -&gt; parser
15
+ * parser.reset -&gt; nil
16
16
  *
17
- * Creates a new parser.
17
+ * Resets the parser to it's initial state so that you can reuse it
18
+ * rather than making new ones.
18
19
  */
19
- VALUE HttpParser_init(VALUE self)
20
+ VALUE HttpParser_reset(VALUE self)
20
21
  {
21
22
  http_parser *http = NULL;
22
23
  DATA_GET(self, http_parser, http);
23
24
  http_parser_init(http);
24
25
 
25
- return self;
26
+ return Qnil;
26
27
  }</pre>
27
28
  </body>
28
29
  </html>
@@ -5,25 +5,25 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>reset (Mongrel::HttpParser)</title>
8
+ <title>finish (Mongrel::HttpParser)</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
13
  <pre>/**
14
14
  * call-seq:
15
- * parser.reset -&gt; nil
15
+ * parser.finish -&gt; true/false
16
16
  *
17
- * Resets the parser to it's initial state so that you can reuse it
18
- * rather than making new ones.
17
+ * Finishes a parser early which could put in a &quot;good&quot; or bad state.
18
+ * You should call reset after finish it or bad things will happen.
19
19
  */
20
- VALUE HttpParser_reset(VALUE self)
20
+ VALUE HttpParser_finish(VALUE self)
21
21
  {
22
22
  http_parser *http = NULL;
23
23
  DATA_GET(self, http_parser, http);
24
- http_parser_init(http);
24
+ http_parser_finish(http);
25
25
 
26
- return Qnil;
26
+ return http_parser_is_finished(http) ? Qtrue : Qfalse;
27
27
  }</pre>
28
28
  </body>
29
29
  </html>
@@ -5,25 +5,37 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>finish (Mongrel::HttpParser)</title>
8
+ <title>execute (Mongrel::HttpParser)</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
13
  <pre>/**
14
14
  * call-seq:
15
- * parser.finish -&gt; true/false
15
+ * parser.execute(req_hash, data) -&gt; Integer
16
16
  *
17
- * Finishes a parser early which could put in a &quot;good&quot; or bad state.
18
- * You should call reset after finish it or bad things will happen.
17
+ * Takes a Hash and a String of data, parses the String of data filling in the Hash
18
+ * returning an Integer to indicate how much of the data has been read. No matter
19
+ * what the return value, you should call HttpParser#finished? and HttpParser#error?
20
+ * to figure out if it's done parsing or there was an error.
21
+ *
22
+ * This function now throws an exception when there is a parsing error. This makes
23
+ * the logic for working with the parser much easier. You can still test for an
24
+ * error, but now you need to wrap the parser with an exception handling block.
19
25
  */
20
- VALUE HttpParser_finish(VALUE self)
26
+ VALUE HttpParser_execute(VALUE self, VALUE req_hash, VALUE data)
21
27
  {
22
28
  http_parser *http = NULL;
23
29
  DATA_GET(self, http_parser, http);
24
- http_parser_finish(http);
25
-
26
- return http_parser_is_finished(http) ? Qtrue : Qfalse;
30
+
31
+ http-&gt;data = (void *)req_hash;
32
+ http_parser_execute(http, RSTRING(data)-&gt;ptr, RSTRING(data)-&gt;len);
33
+
34
+ if(http_parser_has_error(http)) {
35
+ rb_raise(rb_eStandardError, &quot;HTTP Parsing failure&quot;);
36
+ } else {
37
+ return INT2FIX(http_parser_nread(http));
38
+ }
27
39
  }</pre>
28
40
  </body>
29
41
  </html>