diff options
author | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-01-28 19:03:53 +0000 |
---|---|---|
committer | zedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9> | 2006-01-28 19:03:53 +0000 |
commit | 004dec2c2f44a0db510dfd65e5ffd8c9fc4ff83e (patch) | |
tree | a8b7de6debeb447af5479bf156706d09fe748ab4 /doc/rdoc/classes/Mongrel | |
parent | b6d34b2a4191a3118c7c70ea49349e89e581ed91 (diff) | |
download | unicorn-004dec2c2f44a0db510dfd65e5ffd8c9fc4ff83e.tar.gz |
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@4 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'doc/rdoc/classes/Mongrel')
28 files changed, 2139 insertions, 0 deletions
diff --git a/doc/rdoc/classes/Mongrel/Error404Handler.html b/doc/rdoc/classes/Mongrel/Error404Handler.html new file mode 100644 index 0000000..a227f40 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/Error404Handler.html @@ -0,0 +1,171 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Class: Mongrel::Error404Handler</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <meta http-equiv="Content-Script-Type" content="text/javascript" /> + <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" /> + <script type="text/javascript"> + // <![CDATA[ + + function popupCode( url ) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode( id ) { + if ( document.getElementById ) + elem = document.getElementById( id ); + else if ( document.all ) + elem = eval( "document.all." + id ); + else + return false; + + elemStyle = elem.style; + + if ( elemStyle.display != "block" ) { + elemStyle.display = "block" + } else { + elemStyle.display = "none" + } + + return true; + } + + // Make codeblocks hidden by default + document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) + + // ]]> + </script> + +</head> +<body> + + + + <div id="classHeader"> + <table class="header-table"> + <tr class="top-aligned-row"> + <td><strong>Class</strong></td> + <td class="class-name-in-header">Mongrel::Error404Handler</td> + </tr> + <tr class="top-aligned-row"> + <td><strong>In:</strong></td> + <td> + <a href="../../files/lib/mongrel_rb.html"> + lib/mongrel.rb + </a> + <br /> + </td> + </tr> + + <tr class="top-aligned-row"> + <td><strong>Parent:</strong></td> + <td> + <a href="HttpHandler.html"> + HttpHandler + </a> + </td> + </tr> + </table> + </div> + <!-- banner header --> + + <div id="bodyContent"> + + + + <div id="contextContent"> + + <div id="description"> + <p> +The server normally returns a 404 response if a URI is requested, but it +also returns a lame empty message. This lets you do a 404 response with a +custom message for special URIs. +</p> + + </div> + + + </div> + + <div id="method-list"> + <h3 class="section-bar">Methods</h3> + + <div class="name-list"> + <a href="#M000019">new</a> + <a href="#M000020">process</a> + </div> + </div> + + </div> + + + <!-- if includes --> + + <div id="section"> + + + + + + + + + <!-- if method_list --> + <div id="methods"> + <h3 class="section-bar">Public Class methods</h3> + + <div id="method-M000019" class="method-detail"> + <a name="M000019"></a> + + <div class="method-heading"> + <a href="Error404Handler.src/M000019.html" target="Code" class="method-signature" + onclick="popupCode('Error404Handler.src/M000019.html');return false;"> + <span class="method-name">new</span><span class="method-args">(msg)</span> + </a> + </div> + + <div class="method-description"> + <p> +Sets the message to return. This is constructed once for the handler so +it’s pretty efficient. +</p> + </div> + </div> + + <h3 class="section-bar">Public Instance methods</h3> + + <div id="method-M000020" class="method-detail"> + <a name="M000020"></a> + + <div class="method-heading"> + <a href="Error404Handler.src/M000020.html" target="Code" class="method-signature" + onclick="popupCode('Error404Handler.src/M000020.html');return false;"> + <span class="method-name">process</span><span class="method-args">(request, response)</span> + </a> + </div> + + <div class="method-description"> + <p> +Just kicks back the standard 404 response with your special message. +</p> + </div> + </div> + + + </div> + + + </div> + + +<div id="validator-badges"> + <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> +</div> + +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/Error404Handler.src/M000019.html b/doc/rdoc/classes/Mongrel/Error404Handler.src/M000019.html new file mode 100644 index 0000000..6cb8774 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/Error404Handler.src/M000019.html @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>new (Mongrel::Error404Handler)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 75</span> +75: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">msg</span>) +76: <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> +77: <span class="ruby-keyword kw">end</span></pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/Error404Handler.src/M000020.html b/doc/rdoc/classes/Mongrel/Error404Handler.src/M000020.html new file mode 100644 index 0000000..76d5a15 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/Error404Handler.src/M000020.html @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>process (Mongrel::Error404Handler)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 80</span> +80: <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>) +81: <span class="ruby-identifier">response</span>.<span class="ruby-identifier">socket</span>.<span class="ruby-identifier">write</span>(<span class="ruby-ivar">@response</span>) +82: <span class="ruby-keyword kw">end</span></pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpHandler.html b/doc/rdoc/classes/Mongrel/HttpHandler.html new file mode 100644 index 0000000..55f6f3a --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpHandler.html @@ -0,0 +1,159 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Class: Mongrel::HttpHandler</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <meta http-equiv="Content-Script-Type" content="text/javascript" /> + <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" /> + <script type="text/javascript"> + // <![CDATA[ + + function popupCode( url ) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode( id ) { + if ( document.getElementById ) + elem = document.getElementById( id ); + else if ( document.all ) + elem = eval( "document.all." + id ); + else + return false; + + elemStyle = elem.style; + + if ( elemStyle.display != "block" ) { + elemStyle.display = "block" + } else { + elemStyle.display = "none" + } + + return true; + } + + // Make codeblocks hidden by default + document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) + + // ]]> + </script> + +</head> +<body> + + + + <div id="classHeader"> + <table class="header-table"> + <tr class="top-aligned-row"> + <td><strong>Class</strong></td> + <td class="class-name-in-header">Mongrel::HttpHandler</td> + </tr> + <tr class="top-aligned-row"> + <td><strong>In:</strong></td> + <td> + <a href="../../files/lib/mongrel_rb.html"> + lib/mongrel.rb + </a> + <br /> + </td> + </tr> + + <tr class="top-aligned-row"> + <td><strong>Parent:</strong></td> + <td> + Object + </td> + </tr> + </table> + </div> + <!-- banner header --> + + <div id="bodyContent"> + + + + <div id="contextContent"> + + <div id="description"> + <p> +You implement your application handler with this. It’s very light +giving just the minimum necessary for you to handle a request and shoot +back a response. Look at the <a href="HttpRequest.html">HttpRequest</a> and +<a href="HttpResponse.html">HttpResponse</a> objects for how to use them. +</p> + + </div> + + + </div> + + <div id="method-list"> + <h3 class="section-bar">Methods</h3> + + <div class="name-list"> + <a href="#M000017">process</a> + </div> + </div> + + </div> + + + <!-- if includes --> + + <div id="section"> + + + + + + <div id="attribute-list"> + <h3 class="section-bar">Attributes</h3> + + <div class="name-list"> + <table> + <tr class="top-aligned-row context-row"> + <td class="context-item-name">script_name</td> + <td class="context-item-value"> [RW] </td> + <td class="context-item-desc"></td> + </tr> + </table> + </div> + </div> + + + + <!-- if method_list --> + <div id="methods"> + <h3 class="section-bar">Public Instance methods</h3> + + <div id="method-M000017" class="method-detail"> + <a name="M000017"></a> + + <div class="method-heading"> + <a href="HttpHandler.src/M000017.html" target="Code" class="method-signature" + onclick="popupCode('HttpHandler.src/M000017.html');return false;"> + <span class="method-name">process</span><span class="method-args">(request, response)</span> + </a> + </div> + + <div class="method-description"> + </div> + </div> + + + </div> + + + </div> + + +<div id="validator-badges"> + <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> +</div> + +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpHandler.src/M000017.html b/doc/rdoc/classes/Mongrel/HttpHandler.src/M000017.html new file mode 100644 index 0000000..9b5f53c --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpHandler.src/M000017.html @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>process (Mongrel::HttpHandler)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 64</span> +64: <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>) +65: <span class="ruby-keyword kw">end</span></pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpParser.html b/doc/rdoc/classes/Mongrel/HttpParser.html new file mode 100644 index 0000000..13cc01c --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpParser.html @@ -0,0 +1,265 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Class: Mongrel::HttpParser</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <meta http-equiv="Content-Script-Type" content="text/javascript" /> + <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" /> + <script type="text/javascript"> + // <![CDATA[ + + function popupCode( url ) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode( id ) { + if ( document.getElementById ) + elem = document.getElementById( id ); + else if ( document.all ) + elem = eval( "document.all." + id ); + else + return false; + + elemStyle = elem.style; + + if ( elemStyle.display != "block" ) { + elemStyle.display = "block" + } else { + elemStyle.display = "none" + } + + return true; + } + + // Make codeblocks hidden by default + document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) + + // ]]> + </script> + +</head> +<body> + + + + <div id="classHeader"> + <table class="header-table"> + <tr class="top-aligned-row"> + <td><strong>Class</strong></td> + <td class="class-name-in-header">Mongrel::HttpParser</td> + </tr> + <tr class="top-aligned-row"> + <td><strong>In:</strong></td> + <td> + <a href="../../files/ext/http11/http11_c.html"> + ext/http11/http11.c + </a> + <br /> + </td> + </tr> + + <tr class="top-aligned-row"> + <td><strong>Parent:</strong></td> + <td> + Object + </td> + </tr> + </table> + </div> + <!-- banner header --> + + <div id="bodyContent"> + + + + <div id="contextContent"> + + + + </div> + + <div id="method-list"> + <h3 class="section-bar">Methods</h3> + + <div class="name-list"> + <a href="#M000005">error?</a> + <a href="#M000004">execute</a> + <a href="#M000003">finish</a> + <a href="#M000006">finished?</a> + <a href="#M000001">new</a> + <a href="#M000007">nread</a> + <a href="#M000002">reset</a> + </div> + </div> + + </div> + + + <!-- if includes --> + + <div id="section"> + + + + + + + + + <!-- if method_list --> + <div id="methods"> + <h3 class="section-bar">Public Class methods</h3> + + <div id="method-M000001" class="method-detail"> + <a name="M000001"></a> + + <div class="method-heading"> + <a href="HttpParser.src/M000001.html" target="Code" class="method-signature" + onclick="popupCode('HttpParser.src/M000001.html');return false;"> + <span class="method-name">parser.new → parser<br /> +</span> + </a> + </div> + + <div class="method-description"> + <p> +Creates a new parser. +</p> + </div> + </div> + + <h3 class="section-bar">Public Instance methods</h3> + + <div id="method-M000005" class="method-detail"> + <a name="M000005"></a> + + <div class="method-heading"> + <a href="HttpParser.src/M000005.html" target="Code" class="method-signature" + onclick="popupCode('HttpParser.src/M000005.html');return false;"> + <span class="method-name">parser.error? → true/false<br /> +</span> + </a> + </div> + + <div class="method-description"> + <p> +Tells you whether the parser is in an error state. +</p> + </div> + </div> + + <div id="method-M000004" class="method-detail"> + <a name="M000004"></a> + + <div class="method-heading"> + <a href="HttpParser.src/M000004.html" target="Code" class="method-signature" + onclick="popupCode('HttpParser.src/M000004.html');return false;"> + <span class="method-name">parser.execute(req_hash, data) → Integer<br /> +</span> + </a> + </div> + + <div class="method-description"> + <p> +Takes a Hash and a String of data, parses the String of data filling in the +Hash returning an Integer to indicate how much of the data has been read. +No matter what the return value, you should call HttpParser#finished? and +HttpParser#error? to figure out if it’s done parsing or there was an +error. +</p> + </div> + </div> + + <div id="method-M000003" class="method-detail"> + <a name="M000003"></a> + + <div class="method-heading"> + <a href="HttpParser.src/M000003.html" target="Code" class="method-signature" + onclick="popupCode('HttpParser.src/M000003.html');return false;"> + <span class="method-name">parser.finish → true/false<br /> +</span> + </a> + </div> + + <div class="method-description"> + <p> +Finishes a parser early which could put in a "good" or bad state. +You should call reset after finish it or bad things will happen. +</p> + </div> + </div> + + <div id="method-M000006" class="method-detail"> + <a name="M000006"></a> + + <div class="method-heading"> + <a href="HttpParser.src/M000006.html" target="Code" class="method-signature" + onclick="popupCode('HttpParser.src/M000006.html');return false;"> + <span class="method-name">parser.finished? → true/false<br /> +</span> + </a> + </div> + + <div class="method-description"> + <p> +Tells you whether the parser is finished or not and in a good state. +</p> + </div> + </div> + + <div id="method-M000007" class="method-detail"> + <a name="M000007"></a> + + <div class="method-heading"> + <a href="HttpParser.src/M000007.html" target="Code" class="method-signature" + onclick="popupCode('HttpParser.src/M000007.html');return false;"> + <span class="method-name">parser.nread → Integer<br /> +</span> + </a> + </div> + + <div class="method-description"> + <p> +Returns the amount of data processed so far during this processing cycle. +It is set to 0 on initialize or reset calls and is incremented each time +execute is called. +</p> + </div> + </div> + + <div id="method-M000002" class="method-detail"> + <a name="M000002"></a> + + <div class="method-heading"> + <a href="HttpParser.src/M000002.html" target="Code" class="method-signature" + onclick="popupCode('HttpParser.src/M000002.html');return false;"> + <span class="method-name">parser.reset → nil<br /> +</span> + </a> + </div> + + <div class="method-description"> + <p> +Resets the parser to it’s initial state so that you can reuse it +rather than making new ones. +</p> + </div> + </div> + + + </div> + + + </div> + + +<div id="validator-badges"> + <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> +</div> + +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpParser.src/M000001.html b/doc/rdoc/classes/Mongrel/HttpParser.src/M000001.html new file mode 100644 index 0000000..47326b1 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpParser.src/M000001.html @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>new (Mongrel::HttpParser)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre>/** + * call-seq: + * parser.new -> parser + * + * Creates a new parser. + */ +VALUE HttpParser_init(VALUE self) +{ + http_parser *http = NULL; + DATA_GET(self, http_parser, http); + http_parser_init(http); + + return self; +}</pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpParser.src/M000002.html b/doc/rdoc/classes/Mongrel/HttpParser.src/M000002.html new file mode 100644 index 0000000..5ff567b --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpParser.src/M000002.html @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>reset (Mongrel::HttpParser)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre>/** + * call-seq: + * parser.reset -> nil + * + * Resets the parser to it's initial state so that you can reuse it + * rather than making new ones. + */ +VALUE HttpParser_reset(VALUE self) +{ + http_parser *http = NULL; + DATA_GET(self, http_parser, http); + http_parser_init(http); + + return Qnil; +}</pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpParser.src/M000003.html b/doc/rdoc/classes/Mongrel/HttpParser.src/M000003.html new file mode 100644 index 0000000..7dfc546 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpParser.src/M000003.html @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>finish (Mongrel::HttpParser)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre>/** + * call-seq: + * parser.finish -> true/false + * + * Finishes a parser early which could put in a "good" or bad state. + * You should call reset after finish it or bad things will happen. + */ +VALUE HttpParser_finish(VALUE self) +{ + http_parser *http = NULL; + DATA_GET(self, http_parser, http); + http_parser_finish(http); + + return http_parser_is_finished(http) ? Qtrue : Qfalse; +}</pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpParser.src/M000004.html b/doc/rdoc/classes/Mongrel/HttpParser.src/M000004.html new file mode 100644 index 0000000..9ee1f57 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpParser.src/M000004.html @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>execute (Mongrel::HttpParser)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre>/** + * call-seq: + * parser.execute(req_hash, data) -> Integer + * + * Takes a Hash and a String of data, parses the String of data filling in the Hash + * returning an Integer to indicate how much of the data has been read. No matter + * what the return value, you should call HttpParser#finished? and HttpParser#error? + * to figure out if it's done parsing or there was an error. + */ +VALUE HttpParser_execute(VALUE self, VALUE req_hash, VALUE data) +{ + http_parser *http = NULL; + DATA_GET(self, http_parser, http); + + http->data = (void *)req_hash; + http_parser_execute(http, RSTRING(data)->ptr, RSTRING(data)->len); + + return INT2FIX(http_parser_nread(http)); +}</pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpParser.src/M000005.html b/doc/rdoc/classes/Mongrel/HttpParser.src/M000005.html new file mode 100644 index 0000000..e8ebe0e --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpParser.src/M000005.html @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>error? (Mongrel::HttpParser)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre>/** + * call-seq: + * parser.error? -> true/false + * + * Tells you whether the parser is in an error state. + */ +VALUE HttpParser_has_error(VALUE self) +{ + http_parser *http = NULL; + DATA_GET(self, http_parser, http); + + return http_parser_has_error(http) ? Qtrue : Qfalse; +}</pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpParser.src/M000006.html b/doc/rdoc/classes/Mongrel/HttpParser.src/M000006.html new file mode 100644 index 0000000..a279344 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpParser.src/M000006.html @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>finished? (Mongrel::HttpParser)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre>/** + * call-seq: + * parser.finished? -> true/false + * + * Tells you whether the parser is finished or not and in a good state. + */ +VALUE HttpParser_is_finished(VALUE self) +{ + http_parser *http = NULL; + DATA_GET(self, http_parser, http); + + return http_parser_is_finished(http) ? Qtrue : Qfalse; +}</pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpParser.src/M000007.html b/doc/rdoc/classes/Mongrel/HttpParser.src/M000007.html new file mode 100644 index 0000000..2cfaca7 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpParser.src/M000007.html @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>nread (Mongrel::HttpParser)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre>/** + * call-seq: + * parser.nread -> Integer + * + * Returns the amount of data processed so far during this processing cycle. It is + * set to 0 on initialize or reset calls and is incremented each time execute is called. + */ +VALUE HttpParser_nread(VALUE self) +{ + http_parser *http = NULL; + DATA_GET(self, http_parser, http); + + return INT2FIX(http->nread); +}</pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpRequest.html b/doc/rdoc/classes/Mongrel/HttpRequest.html new file mode 100644 index 0000000..525ed90 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpRequest.html @@ -0,0 +1,177 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Class: Mongrel::HttpRequest</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <meta http-equiv="Content-Script-Type" content="text/javascript" /> + <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" /> + <script type="text/javascript"> + // <![CDATA[ + + function popupCode( url ) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode( id ) { + if ( document.getElementById ) + elem = document.getElementById( id ); + else if ( document.all ) + elem = eval( "document.all." + id ); + else + return false; + + elemStyle = elem.style; + + if ( elemStyle.display != "block" ) { + elemStyle.display = "block" + } else { + elemStyle.display = "none" + } + + return true; + } + + // Make codeblocks hidden by default + document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) + + // ]]> + </script> + +</head> +<body> + + + + <div id="classHeader"> + <table class="header-table"> + <tr class="top-aligned-row"> + <td><strong>Class</strong></td> + <td class="class-name-in-header">Mongrel::HttpRequest</td> + </tr> + <tr class="top-aligned-row"> + <td><strong>In:</strong></td> + <td> + <a href="../../files/lib/mongrel_rb.html"> + lib/mongrel.rb + </a> + <br /> + </td> + </tr> + + <tr class="top-aligned-row"> + <td><strong>Parent:</strong></td> + <td> + Object + </td> + </tr> + </table> + </div> + <!-- banner header --> + + <div id="bodyContent"> + + + + <div id="contextContent"> + + <div id="description"> + <p> +When a handler is found for a registered URI then this class is constructed +and passed to your HttpHandler::process method. You should assume that +<b>one</b> handler processes all requests. Included in the HttpReqeust is a +HttpRequest.params Hash that matches common CGI params, and a +HttpRequest.body which is a string containing the request body (raw for +now). +</p> +<p> +<a href="../Mongrel.html">Mongrel</a> really only support small-ish request +bodies right now since really huge ones have to be completely read off the +wire and put into a string. Later there will be several options for +efficiently handling large file uploads. +</p> + + </div> + + + </div> + + <div id="method-list"> + <h3 class="section-bar">Methods</h3> + + <div class="name-list"> + <a href="#M000021">new</a> + </div> + </div> + + </div> + + + <!-- if includes --> + + <div id="section"> + + + + + + <div id="attribute-list"> + <h3 class="section-bar">Attributes</h3> + + <div class="name-list"> + <table> + <tr class="top-aligned-row context-row"> + <td class="context-item-name">body</td> + <td class="context-item-value"> [R] </td> + <td class="context-item-desc"></td> + </tr> + <tr class="top-aligned-row context-row"> + <td class="context-item-name">params</td> + <td class="context-item-value"> [R] </td> + <td class="context-item-desc"></td> + </tr> + </table> + </div> + </div> + + + + <!-- if method_list --> + <div id="methods"> + <h3 class="section-bar">Public Class methods</h3> + + <div id="method-M000021" class="method-detail"> + <a name="M000021"></a> + + <div class="method-heading"> + <a href="HttpRequest.src/M000021.html" target="Code" class="method-signature" + onclick="popupCode('HttpRequest.src/M000021.html');return false;"> + <span class="method-name">new</span><span class="method-args">(params, initial_body, socket)</span> + </a> + </div> + + <div class="method-description"> + <p> +You don’t really call this. It’s made for you. Main thing it +does is hook up the params, and store any remaining body data into the +HttpRequest.body attribute. +</p> + </div> + </div> + + + </div> + + + </div> + + +<div id="validator-badges"> + <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> +</div> + +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpRequest.src/M000021.html b/doc/rdoc/classes/Mongrel/HttpRequest.src/M000021.html new file mode 100644 index 0000000..39c1d18 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpRequest.src/M000021.html @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>new (Mongrel::HttpRequest)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 27</span> +27: <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>) +28: <span class="ruby-ivar">@body</span> = <span class="ruby-identifier">initial_body</span> <span class="ruby-operator">||</span> <span class="ruby-value str">""</span> +29: <span class="ruby-ivar">@params</span> = <span class="ruby-identifier">params</span> +30: <span class="ruby-ivar">@socket</span> = <span class="ruby-identifier">socket</span> +31: +32: <span class="ruby-comment cmt"># fix up the CGI requirements</span> +33: <span class="ruby-identifier">params</span>[<span class="ruby-value str">'CONTENT_LENGTH'</span>] = <span class="ruby-identifier">params</span>[<span class="ruby-value str">'HTTP_CONTENT_LENGTH'</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span> +34: +35: <span class="ruby-comment cmt"># now, if the initial_body isn't long enough for the content length we have to fill it</span> +36: <span class="ruby-comment cmt"># TODO: adapt for big ass stuff by writing to a temp file</span> +37: <span class="ruby-identifier">clen</span> = <span class="ruby-identifier">params</span>[<span class="ruby-value str">'HTTP_CONTENT_LENGTH'</span>].<span class="ruby-identifier">to_i</span> +38: <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> +39: <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>) +40: <span class="ruby-keyword kw">end</span> +41: <span class="ruby-keyword kw">end</span></pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpResponse.html b/doc/rdoc/classes/Mongrel/HttpResponse.html new file mode 100644 index 0000000..89832b0 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpResponse.html @@ -0,0 +1,159 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Class: Mongrel::HttpResponse</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <meta http-equiv="Content-Script-Type" content="text/javascript" /> + <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" /> + <script type="text/javascript"> + // <![CDATA[ + + function popupCode( url ) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode( id ) { + if ( document.getElementById ) + elem = document.getElementById( id ); + else if ( document.all ) + elem = eval( "document.all." + id ); + else + return false; + + elemStyle = elem.style; + + if ( elemStyle.display != "block" ) { + elemStyle.display = "block" + } else { + elemStyle.display = "none" + } + + return true; + } + + // Make codeblocks hidden by default + document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) + + // ]]> + </script> + +</head> +<body> + + + + <div id="classHeader"> + <table class="header-table"> + <tr class="top-aligned-row"> + <td><strong>Class</strong></td> + <td class="class-name-in-header">Mongrel::HttpResponse</td> + </tr> + <tr class="top-aligned-row"> + <td><strong>In:</strong></td> + <td> + <a href="../../files/lib/mongrel_rb.html"> + lib/mongrel.rb + </a> + <br /> + </td> + </tr> + + <tr class="top-aligned-row"> + <td><strong>Parent:</strong></td> + <td> + Object + </td> + </tr> + </table> + </div> + <!-- banner header --> + + <div id="bodyContent"> + + + + <div id="contextContent"> + + <div id="description"> + <p> +Very very simple response object. You basically write your stuff raw to the +HttpResponse.socket variable. This will be made <b>much</b> easier in +future releases allowing you to set status and request headers prior to +sending the response. +</p> + + </div> + + + </div> + + <div id="method-list"> + <h3 class="section-bar">Methods</h3> + + <div class="name-list"> + <a href="#M000018">new</a> + </div> + </div> + + </div> + + + <!-- if includes --> + + <div id="section"> + + + + + + <div id="attribute-list"> + <h3 class="section-bar">Attributes</h3> + + <div class="name-list"> + <table> + <tr class="top-aligned-row context-row"> + <td class="context-item-name">socket</td> + <td class="context-item-value"> [R] </td> + <td class="context-item-desc"></td> + </tr> + </table> + </div> + </div> + + + + <!-- if method_list --> + <div id="methods"> + <h3 class="section-bar">Public Class methods</h3> + + <div id="method-M000018" class="method-detail"> + <a name="M000018"></a> + + <div class="method-heading"> + <a href="HttpResponse.src/M000018.html" target="Code" class="method-signature" + onclick="popupCode('HttpResponse.src/M000018.html');return false;"> + <span class="method-name">new</span><span class="method-args">(socket)</span> + </a> + </div> + + <div class="method-description"> + </div> + </div> + + + </div> + + + </div> + + +<div id="validator-badges"> + <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> +</div> + +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpResponse.src/M000018.html b/doc/rdoc/classes/Mongrel/HttpResponse.src/M000018.html new file mode 100644 index 0000000..9086679 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpResponse.src/M000018.html @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>new (Mongrel::HttpResponse)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 51</span> +51: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">socket</span>) +52: <span class="ruby-ivar">@socket</span> = <span class="ruby-identifier">socket</span> +53: <span class="ruby-keyword kw">end</span></pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpServer.html b/doc/rdoc/classes/Mongrel/HttpServer.html new file mode 100644 index 0000000..f3632cc --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpServer.html @@ -0,0 +1,300 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Class: Mongrel::HttpServer</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <meta http-equiv="Content-Script-Type" content="text/javascript" /> + <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" /> + <script type="text/javascript"> + // <![CDATA[ + + function popupCode( url ) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode( id ) { + if ( document.getElementById ) + elem = document.getElementById( id ); + else if ( document.all ) + elem = eval( "document.all." + id ); + else + return false; + + elemStyle = elem.style; + + if ( elemStyle.display != "block" ) { + elemStyle.display = "block" + } else { + elemStyle.display = "none" + } + + return true; + } + + // Make codeblocks hidden by default + document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) + + // ]]> + </script> + +</head> +<body> + + + + <div id="classHeader"> + <table class="header-table"> + <tr class="top-aligned-row"> + <td><strong>Class</strong></td> + <td class="class-name-in-header">Mongrel::HttpServer</td> + </tr> + <tr class="top-aligned-row"> + <td><strong>In:</strong></td> + <td> + <a href="../../files/lib/mongrel_rb.html"> + lib/mongrel.rb + </a> + <br /> + </td> + </tr> + + <tr class="top-aligned-row"> + <td><strong>Parent:</strong></td> + <td> + Object + </td> + </tr> + </table> + </div> + <!-- banner header --> + + <div id="bodyContent"> + + + + <div id="contextContent"> + + <div id="description"> + <p> +This is the main driver of <a href="../Mongrel.html">Mongrel</a>, while the +Mognrel::HttpParser and <a +href="URIClassifier.html">Mongrel::URIClassifier</a> make up the majority +of how the server functions. It’s a very simple class that just has a +thread accepting connections and a simple <a +href="HttpServer.html#M000009">HttpServer.process_client</a> function to do +the heavy lifting with the IO and Ruby. +</p> +<p> +*NOTE:* The <a href="HttpServer.html#M000009">process_client</a> function +used threads at one time but that proved to have stability issues on Mac +OSX. Actually, Ruby in general has stability issues on Mac OSX. +</p> +<p> +You use it by doing the following: +</p> +<pre> + server = HttpServer.new("0.0.0.0", 3000) + server.register("/stuff", MyNifterHandler.new) + server.run.join +</pre> +<p> +The last line can be just server.run if you don’t want to join the +thread used. If you don’t though Ruby will mysteriously just exit on +you. +</p> + + </div> + + + </div> + + <div id="method-list"> + <h3 class="section-bar">Methods</h3> + + <div class="name-list"> + <a href="#M000008">new</a> + <a href="#M000009">process_client</a> + <a href="#M000011">register</a> + <a href="#M000010">run</a> + <a href="#M000012">unregister</a> + </div> + </div> + + </div> + + + <!-- if includes --> + + <div id="section"> + + + <div id="constants-list"> + <h3 class="section-bar">Constants</h3> + + <div class="name-list"> + <table summary="Constants"> + <tr class="top-aligned-row context-row"> + <td class="context-item-name">ERROR_404_RESPONSE</td> + <td>=</td> + <td class="context-item-value">"HTTP/1.1 404 Not Found\r\nConnection: close\r\nContent-Type: text/plain\r\nServer: Mongrel/0.1\r\n\r\n"</td> + <td width="3em"> </td> + <td class="context-item-desc"> +The standard empty 404 response for bad requests. Use Error4040Handler for +custom stuff. + +</td> + </tr> + <tr class="top-aligned-row context-row"> + <td class="context-item-name">CHUNK_SIZE</td> + <td>=</td> + <td class="context-item-value">2048</td> + <td width="3em"> </td> + <td class="context-item-desc"> +For now we just read 2k chunks. Not optimal at all. + +</td> + </tr> + </table> + </div> + </div> + + + + <div id="attribute-list"> + <h3 class="section-bar">Attributes</h3> + + <div class="name-list"> + <table> + <tr class="top-aligned-row context-row"> + <td class="context-item-name">acceptor</td> + <td class="context-item-value"> [R] </td> + <td class="context-item-desc"></td> + </tr> + </table> + </div> + </div> + + + + <!-- if method_list --> + <div id="methods"> + <h3 class="section-bar">Public Class methods</h3> + + <div id="method-M000008" class="method-detail"> + <a name="M000008"></a> + + <div class="method-heading"> + <a href="HttpServer.src/M000008.html" target="Code" class="method-signature" + onclick="popupCode('HttpServer.src/M000008.html');return false;"> + <span class="method-name">new</span><span class="method-args">(host, port)</span> + </a> + </div> + + <div class="method-description"> + <p> +Creates a working server on host:port (strange things happen if port +isn’t a Number). Use HttpServer::run to start the server. +</p> + </div> + </div> + + <h3 class="section-bar">Public Instance methods</h3> + + <div id="method-M000009" class="method-detail"> + <a name="M000009"></a> + + <div class="method-heading"> + <a href="HttpServer.src/M000009.html" target="Code" class="method-signature" + onclick="popupCode('HttpServer.src/M000009.html');return false;"> + <span class="method-name">process_client</span><span class="method-args">(client)</span> + </a> + </div> + + <div class="method-description"> + <p> +Used internally to process an accepted client. It uses <a +href="HttpParser.html">HttpParser</a> and <a +href="URIClassifier.html">URIClassifier</a> (in ext/http11/http11.c) to do +the heavy work, and mostly just does a hack job at some simple IO. Future +releases will target this area mostly. +</p> + </div> + </div> + + <div id="method-M000011" class="method-detail"> + <a name="M000011"></a> + + <div class="method-heading"> + <a href="HttpServer.src/M000011.html" target="Code" class="method-signature" + onclick="popupCode('HttpServer.src/M000011.html');return false;"> + <span class="method-name">register</span><span class="method-args">(uri, handler)</span> + </a> + </div> + + <div class="method-description"> + <p> +Simply registers a handler with the internal <a +href="URIClassifier.html">URIClassifier</a>. When the URI is found in the +prefix of a request then your handler’s HttpHandler::process method +is called. See <a +href="URIClassifier.html#M000014">Mongrel::URIClassifier#register</a> for +more information. +</p> + </div> + </div> + + <div id="method-M000010" class="method-detail"> + <a name="M000010"></a> + + <div class="method-heading"> + <a href="HttpServer.src/M000010.html" target="Code" class="method-signature" + onclick="popupCode('HttpServer.src/M000010.html');return false;"> + <span class="method-name">run</span><span class="method-args">()</span> + </a> + </div> + + <div class="method-description"> + <p> +Runs the thing. It returns the thread used so you can "join" it. +You can also access the HttpServer::acceptor attribute to get the thread +later. +</p> + </div> + </div> + + <div id="method-M000012" class="method-detail"> + <a name="M000012"></a> + + <div class="method-heading"> + <a href="HttpServer.src/M000012.html" target="Code" class="method-signature" + onclick="popupCode('HttpServer.src/M000012.html');return false;"> + <span class="method-name">unregister</span><span class="method-args">(uri)</span> + </a> + </div> + + <div class="method-description"> + <p> +Removes any handler registered at the given URI. See <a +href="URIClassifier.html#M000015">Mongrel::URIClassifier#unregister</a> for +more information. +</p> + </div> + </div> + + + </div> + + + </div> + + +<div id="validator-badges"> + <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> +</div> + +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpServer.src/M000008.html b/doc/rdoc/classes/Mongrel/HttpServer.src/M000008.html new file mode 100644 index 0000000..d5b5591 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpServer.src/M000008.html @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>new (Mongrel::HttpServer)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 114</span> +114: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>) +115: <span class="ruby-ivar">@socket</span> = <span class="ruby-constant">TCPServer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">host</span>, <span class="ruby-identifier">port</span>) +116: <span class="ruby-ivar">@classifier</span> = <span class="ruby-constant">URIClassifier</span>.<span class="ruby-identifier">new</span> +117: <span class="ruby-keyword kw">end</span></pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpServer.src/M000009.html b/doc/rdoc/classes/Mongrel/HttpServer.src/M000009.html new file mode 100644 index 0000000..5181e70 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpServer.src/M000009.html @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>process_client (Mongrel::HttpServer)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 122</span> +122: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_client</span>(<span class="ruby-identifier">client</span>) +123: <span class="ruby-keyword kw">begin</span> +124: <span class="ruby-identifier">parser</span> = <span class="ruby-constant">HttpParser</span>.<span class="ruby-identifier">new</span> +125: <span class="ruby-identifier">params</span> = {} +126: <span class="ruby-identifier">data</span> = <span class="ruby-value str">""</span> +127: +128: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span> +129: <span class="ruby-identifier">data</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">client</span>.<span class="ruby-identifier">readpartial</span>(<span class="ruby-constant">CHUNK_SIZE</span>) +130: +131: <span class="ruby-identifier">nread</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">execute</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">data</span>) +132: +133: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">error?</span> +134: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">"parser error:"</span> +135: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">data</span> +136: <span class="ruby-keyword kw">break</span> +137: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">finished?</span> +138: <span class="ruby-identifier">script_name</span>, <span class="ruby-identifier">path_info</span>, <span class="ruby-identifier">handler</span> = <span class="ruby-ivar">@classifier</span>.<span class="ruby-identifier">resolve</span>(<span class="ruby-identifier">params</span>[<span class="ruby-value str">"PATH_INFO"</span>]) +139: +140: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">handler</span> +141: <span class="ruby-identifier">params</span>[<span class="ruby-value str">'PATH_INFO'</span>] = <span class="ruby-identifier">path_info</span> +142: <span class="ruby-identifier">params</span>[<span class="ruby-value str">'SCRIPT_NAME'</span>] = <span class="ruby-identifier">script_name</span> +143: +144: <span class="ruby-identifier">request</span> = <span class="ruby-constant">HttpRequest</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">params</span>, <span class="ruby-identifier">data</span>[<span class="ruby-identifier">nread</span> <span class="ruby-operator">...</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">length</span>], <span class="ruby-identifier">client</span>) +145: <span class="ruby-identifier">response</span> = <span class="ruby-constant">HttpResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">client</span>) +146: +147: <span class="ruby-identifier">handler</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">request</span>, <span class="ruby-identifier">response</span>) +148: <span class="ruby-keyword kw">else</span> +149: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">write</span>(<span class="ruby-constant">ERROR_404_RESPONSE</span>) +150: <span class="ruby-keyword kw">end</span> +151: +152: <span class="ruby-keyword kw">break</span> +153: <span class="ruby-keyword kw">else</span> +154: <span class="ruby-comment cmt"># gotta stream and read again until we can get the parser to be character safe</span> +155: <span class="ruby-comment cmt"># TODO: make this more efficient since this means we're parsing a lot repeatedly</span> +156: <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">reset</span> +157: <span class="ruby-keyword kw">end</span> +158: <span class="ruby-keyword kw">end</span> +159: <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">details</span> +160: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"ERROR: #{details}"</span> +161: <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">details</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">"\n"</span>) +162: <span class="ruby-keyword kw">ensure</span> +163: <span class="ruby-identifier">client</span>.<span class="ruby-identifier">close</span> +164: <span class="ruby-keyword kw">end</span> +165: <span class="ruby-keyword kw">end</span></pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpServer.src/M000010.html b/doc/rdoc/classes/Mongrel/HttpServer.src/M000010.html new file mode 100644 index 0000000..c79c3e3 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpServer.src/M000010.html @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>run (Mongrel::HttpServer)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 169</span> +169: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span> +170: <span class="ruby-ivar">@acceptor</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">do</span> +171: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span> +172: <span class="ruby-identifier">process_client</span>(<span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">accept</span>) +173: <span class="ruby-keyword kw">end</span> +174: <span class="ruby-keyword kw">end</span> +175: <span class="ruby-keyword kw">end</span></pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpServer.src/M000011.html b/doc/rdoc/classes/Mongrel/HttpServer.src/M000011.html new file mode 100644 index 0000000..7273b5d --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpServer.src/M000011.html @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>register (Mongrel::HttpServer)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 181</span> +181: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">register</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">handler</span>) +182: <span class="ruby-ivar">@classifier</span>.<span class="ruby-identifier">register</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">handler</span>) +183: <span class="ruby-keyword kw">end</span></pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/HttpServer.src/M000012.html b/doc/rdoc/classes/Mongrel/HttpServer.src/M000012.html new file mode 100644 index 0000000..1b8587c --- /dev/null +++ b/doc/rdoc/classes/Mongrel/HttpServer.src/M000012.html @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>unregister (Mongrel::HttpServer)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 187</span> +187: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unregister</span>(<span class="ruby-identifier">uri</span>) +188: <span class="ruby-ivar">@classifier</span>.<span class="ruby-identifier">unregister</span>(<span class="ruby-identifier">uri</span>) +189: <span class="ruby-keyword kw">end</span></pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/URIClassifier.html b/doc/rdoc/classes/Mongrel/URIClassifier.html new file mode 100644 index 0000000..4708416 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/URIClassifier.html @@ -0,0 +1,257 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Class: Mongrel::URIClassifier</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <meta http-equiv="Content-Script-Type" content="text/javascript" /> + <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" /> + <script type="text/javascript"> + // <![CDATA[ + + function popupCode( url ) { + window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") + } + + function toggleCode( id ) { + if ( document.getElementById ) + elem = document.getElementById( id ); + else if ( document.all ) + elem = eval( "document.all." + id ); + else + return false; + + elemStyle = elem.style; + + if ( elemStyle.display != "block" ) { + elemStyle.display = "block" + } else { + elemStyle.display = "none" + } + + return true; + } + + // Make codeblocks hidden by default + document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) + + // ]]> + </script> + +</head> +<body> + + + + <div id="classHeader"> + <table class="header-table"> + <tr class="top-aligned-row"> + <td><strong>Class</strong></td> + <td class="class-name-in-header">Mongrel::URIClassifier</td> + </tr> + <tr class="top-aligned-row"> + <td><strong>In:</strong></td> + <td> + <a href="../../files/ext/http11/http11_c.html"> + ext/http11/http11.c + </a> + <br /> + </td> + </tr> + + <tr class="top-aligned-row"> + <td><strong>Parent:</strong></td> + <td> + Object + </td> + </tr> + </table> + </div> + <!-- banner header --> + + <div id="bodyContent"> + + + + <div id="contextContent"> + + + + </div> + + <div id="method-list"> + <h3 class="section-bar">Methods</h3> + + <div class="name-list"> + <a href="#M000013">new</a> + <a href="#M000014">register</a> + <a href="#M000016">resolve</a> + <a href="#M000015">unregister</a> + </div> + </div> + + </div> + + + <!-- if includes --> + + <div id="section"> + + + + + + + + + <!-- if method_list --> + <div id="methods"> + <h3 class="section-bar">Public Class methods</h3> + + <div id="method-M000013" class="method-detail"> + <a name="M000013"></a> + + <div class="method-heading"> + <a href="URIClassifier.src/M000013.html" target="Code" class="method-signature" + onclick="popupCode('URIClassifier.src/M000013.html');return false;"> + <span class="method-name">URIClassifier.new → URIClassifier<br /> +</span> + </a> + </div> + + <div class="method-description"> + <p> +Initializes a new <a href="URIClassifier.html">URIClassifier</a> object +that you can use to associate URI sequences with objects. You can actually +use it with any string sequence and any objects, but it’s mostly used +with URIs. +</p> +<p> +It uses TST from <a +href="http://www.octavian.org/cs/software.html">www.octavian.org/cs/software.html</a> +to build an ternary search trie to hold all of the URIs. It uses this to do +an initial search for the a URI prefix, and then to break the URI into +SCRIPT_NAME and PATH_INFO portions. It actually will do two searches most +of the time in order to find the right handler for the registered prefix +portion. +</p> +<p> +Here’s how it all works. Let’s say you register +"/blog" with a BlogHandler. Great. Now, someone goes to +"/blog/zedsucks/ass". You want SCRIPT_NAME to be +"/blog" and PATH_INFO to be "/zedsucks/ass". <a +href="URIClassifier.html">URIClassifier</a> first does a TST search and +comes up with a failure, but knows that the failure ended at the +"/blog" part. So, that’s the SCRIPT_NAME. It then tries a +second search for just "/blog". If that comes back good then it +sets the rest ("/zedsucks/ass") to the PATH_INFO and returns the +BlogHandler. +</p> +<p> +The optimal approach would be to not do the search twice, but the TST lib +doesn’t really support returning prefixes. Might not be hard to add +later. +</p> +<p> +The key though is that it will try to match the <b>longest</b> match it +can. If you also register "/blog/zed" then the above URI will +give SCRIPT_NAME="/blog/zed", PATH_INFO="sucks/ass". +Probably not what you want, so your handler will need to do the 404 thing. +</p> +<p> +Take a look at the postamble of example/tepee.rb to see how this is handled +for Camping. +</p> + </div> + </div> + + <h3 class="section-bar">Public Instance methods</h3> + + <div id="method-M000014" class="method-detail"> + <a name="M000014"></a> + + <div class="method-heading"> + <a href="URIClassifier.src/M000014.html" target="Code" class="method-signature" + onclick="popupCode('URIClassifier.src/M000014.html');return false;"> + <span class="method-name">uc.register("/someuri", SampleHandler.new) → nil<br /> +</span> + </a> + </div> + + <div class="method-description"> + <p> +Registers the SampleHandler (one for all requests) with the +"/someuri". When URIClassifier::resolve is called with +"/someuri" it’ll return SampleHandler immediately. When +"/someuri/pathhere" is called it’ll find SomeHandler after +a second search, and setup PATH_INFO="/pathhere". +</p> +<p> +You actually can reuse this class to register nearly anything and quickly +resolve it. This could be used for caching, fast mapping, etc. The downside +is it uses much more memory than a Hash, but it can be a lot faster. +It’s main advantage is that it works on prefixes, which is damn hard +to get right with a Hash. +</p> + </div> + </div> + + <div id="method-M000016" class="method-detail"> + <a name="M000016"></a> + + <div class="method-heading"> + <a href="URIClassifier.src/M000016.html" target="Code" class="method-signature" + onclick="popupCode('URIClassifier.src/M000016.html');return false;"> + <span class="method-name">uc.resolve("/someuri") → "/someuri", "", handler<br /> +uc.resolve("/someuri/pathinfo") → "/someuri", "/pathinfo", handler<br /> +uc.resolve("/notfound/orhere") → nil, nil, nil<br /> +</span> + </a> + </div> + + <div class="method-description"> + <p> +Attempts to resolve either the whole URI or at the longest prefix, +returning the prefix (as script_info), path (as path_info), and registered +handler (usually an <a href="HttpHandler.html">HttpHandler</a>). +</p> +<p> +It expects strings. Don‘t try other string-line stuff yet. +</p> + </div> + </div> + + <div id="method-M000015" class="method-detail"> + <a name="M000015"></a> + + <div class="method-heading"> + <a href="URIClassifier.src/M000015.html" target="Code" class="method-signature" + onclick="popupCode('URIClassifier.src/M000015.html');return false;"> + <span class="method-name">uc.unregister("/someuri")<br /> +</span> + </a> + </div> + + <div class="method-description"> + <p> +Yep, just removes this uri and it’s handler from the trie. +</p> + </div> + </div> + + + </div> + + + </div> + + +<div id="validator-badges"> + <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> +</div> + +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/URIClassifier.src/M000013.html b/doc/rdoc/classes/Mongrel/URIClassifier.src/M000013.html new file mode 100644 index 0000000..a843bc8 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/URIClassifier.src/M000013.html @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>new (Mongrel::URIClassifier)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre>/** + * call-seq: + * URIClassifier.new -> URIClassifier + * + * Initializes a new URIClassifier object that you can use to associate URI sequences + * with objects. You can actually use it with any string sequence and any objects, + * but it's mostly used with URIs. + * + * It uses TST from http://www.octavian.org/cs/software.html to build an ternary search + * trie to hold all of the URIs. It uses this to do an initial search for the a URI + * prefix, and then to break the URI into SCRIPT_NAME and PATH_INFO portions. It actually + * will do two searches most of the time in order to find the right handler for the + * registered prefix portion. + * + * Here's how it all works. Let's say you register "/blog" with a BlogHandler. Great. + * Now, someone goes to "/blog/zedsucks/ass". You want SCRIPT_NAME to be "/blog" and + * PATH_INFO to be "/zedsucks/ass". URIClassifier first does a TST search and comes + * up with a failure, but knows that the failure ended at the "/blog" part. So, that's + * the SCRIPT_NAME. It then tries a second search for just "/blog". If that comes back + * good then it sets the rest ("/zedsucks/ass") to the PATH_INFO and returns the BlogHandler. + * + * The optimal approach would be to not do the search twice, but the TST lib doesn't + * really support returning prefixes. Might not be hard to add later. + * + * The key though is that it will try to match the *longest* match it can. If you + * also register "/blog/zed" then the above URI will give SCRIPT_NAME="/blog/zed", + * PATH_INFO="sucks/ass". Probably not what you want, so your handler will need to + * do the 404 thing. + * + * Take a look at the postamble of example/tepee.rb to see how this is handled for + * Camping. + */ +VALUE URIClassifier_init(VALUE self) +{ + VALUE hash; + + // we create an internal hash to protect stuff from the GC + hash = rb_hash_new(); + rb_iv_set(self, "handler_map", hash); +}</pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/URIClassifier.src/M000014.html b/doc/rdoc/classes/Mongrel/URIClassifier.src/M000014.html new file mode 100644 index 0000000..5055109 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/URIClassifier.src/M000014.html @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>register (Mongrel::URIClassifier)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre>/** + * call-seq: + * uc.register("/someuri", SampleHandler.new) -> nil + * + * Registers the SampleHandler (one for all requests) with the "/someuri". + * When URIClassifier::resolve is called with "/someuri" it'll return + * SampleHandler immediately. When "/someuri/pathhere" is called it'll + * find SomeHandler after a second search, and setup PATH_INFO="/pathhere". + * + * You actually can reuse this class to register nearly anything and + * quickly resolve it. This could be used for caching, fast mapping, etc. + * The downside is it uses much more memory than a Hash, but it can be + * a lot faster. It's main advantage is that it works on prefixes, which + * is damn hard to get right with a Hash. + */ +VALUE URIClassifier_register(VALUE self, VALUE uri, VALUE handler) +{ + int rc = 0; + void *ptr = NULL; + struct tst *tst = NULL; + DATA_GET(self, struct tst, tst); + + rc = tst_insert((unsigned char *)StringValueCStr(uri), (void *)handler , tst, 0, &ptr); + + if(rc == TST_DUPLICATE_KEY) { + rb_raise(rb_eStandardError, "Handler already registered with that name"); + } else if(rc == TST_ERROR) { + rb_raise(rb_eStandardError, "Memory error registering handler"); + } else if(rc == TST_NULL_KEY) { + rb_raise(rb_eStandardError, "URI was empty"); + } + + rb_hash_aset(rb_iv_get(self, "handler_map"), uri, handler); + + return Qnil; +}</pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/URIClassifier.src/M000015.html b/doc/rdoc/classes/Mongrel/URIClassifier.src/M000015.html new file mode 100644 index 0000000..4fafe2b --- /dev/null +++ b/doc/rdoc/classes/Mongrel/URIClassifier.src/M000015.html @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>unregister (Mongrel::URIClassifier)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre>/** + * call-seq: + * uc.unregister("/someuri") + * + * Yep, just removes this uri and it's handler from the trie. + */ +VALUE URIClassifier_unregister(VALUE self, VALUE uri) +{ + void *handler = NULL; + struct tst *tst = NULL; + DATA_GET(self, struct tst, tst); + + handler = tst_delete((unsigned char *)StringValueCStr(uri), tst); + + if(handler) { + rb_hash_delete(rb_iv_get(self, "handler_map"), uri); + + return (VALUE)handler; + } else { + return Qnil; + } +}</pre> +</body> +</html>
\ No newline at end of file diff --git a/doc/rdoc/classes/Mongrel/URIClassifier.src/M000016.html b/doc/rdoc/classes/Mongrel/URIClassifier.src/M000016.html new file mode 100644 index 0000000..f545ea2 --- /dev/null +++ b/doc/rdoc/classes/Mongrel/URIClassifier.src/M000016.html @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <title>resolve (Mongrel::URIClassifier)</title> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> + <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" /> +</head> +<body class="standalone-code"> + <pre>/** + * call-seq: + * uc.resolve("/someuri") -> "/someuri", "", handler + * uc.resolve("/someuri/pathinfo") -> "/someuri", "/pathinfo", handler + * uc.resolve("/notfound/orhere") -> nil, nil, nil + * + * Attempts to resolve either the whole URI or at the longest prefix, returning + * the prefix (as script_info), path (as path_info), and registered handler + * (usually an HttpHandler). + * + * It expects strings. Don't try other string-line stuff yet. + */ +VALUE URIClassifier_resolve(VALUE self, VALUE uri) +{ + void *handler = NULL; + int pref_len = 0; + struct tst *tst = NULL; + VALUE result; + VALUE script_name; + VALUE path_info; + unsigned char *uri_str = NULL; + unsigned char *script_name_str = NULL; + + DATA_GET(self, struct tst, tst); + uri_str = (unsigned char *)StringValueCStr(uri); + + handler = tst_search(uri_str, tst, &pref_len); + + // setup for multiple return values + result = rb_ary_new(); + + + if(handler == NULL) { + script_name = rb_str_substr (uri, 0, pref_len); + script_name_str = (unsigned char *)StringValueCStr(script_name); + + handler = tst_search(script_name_str, tst, NULL); + + if(handler == NULL) { + // didn't find the script name at all + rb_ary_push(result, Qnil); + rb_ary_push(result, Qnil); + rb_ary_push(result, Qnil); + return result; + } else { + // found a handler, setup the path info and we're good + path_info = rb_str_substr(uri, pref_len, RSTRING(uri)->len); + } + } else { + // whole thing was found, so uri is the script name, path info empty + script_name = uri; + path_info = rb_str_new2(""); + } + + rb_ary_push(result, script_name); + rb_ary_push(result, path_info); + rb_ary_push(result, (VALUE)handler); + return result; +}</pre> +</body> +</html>
\ No newline at end of file |