about summary refs log tree commit homepage
path: root/doc/rdoc/classes/Mongrel/URIClassifier.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/rdoc/classes/Mongrel/URIClassifier.html')
-rw-r--r--doc/rdoc/classes/Mongrel/URIClassifier.html257
1 files changed, 257 insertions, 0 deletions
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>&nbsp;&nbsp;
+      <a href="#M000014">register</a>&nbsp;&nbsp;
+      <a href="#M000016">resolve</a>&nbsp;&nbsp;
+      <a href="#M000015">unregister</a>&nbsp;&nbsp;
+      </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 &rarr; 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&#8217;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&#8217;s how it all works. Let&#8217;s say you register
+&quot;/blog&quot; with a BlogHandler. Great. Now, someone goes to
+&quot;/blog/zedsucks/ass&quot;. You want SCRIPT_NAME to be
+&quot;/blog&quot; and PATH_INFO to be &quot;/zedsucks/ass&quot;. <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
+&quot;/blog&quot; part. So, that&#8217;s the SCRIPT_NAME. It then tries a
+second search for just &quot;/blog&quot;. If that comes back good then it
+sets the rest (&quot;/zedsucks/ass&quot;) 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&#8217;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 &quot;/blog/zed&quot; then the above URI will
+give SCRIPT_NAME=&quot;/blog/zed&quot;, PATH_INFO=&quot;sucks/ass&quot;.
+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) &rarr; nil<br />
+</span>
+          </a>
+        </div>
+      
+        <div class="method-description">
+          <p>
+Registers the SampleHandler (one for all requests) with the
+&quot;/someuri&quot;. When URIClassifier::resolve is called with
+&quot;/someuri&quot; it&#8217;ll return SampleHandler immediately. When
+&quot;/someuri/pathhere&quot; is called it&#8217;ll find SomeHandler after
+a second search, and setup PATH_INFO=&quot;/pathhere&quot;.
+</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&#8217;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") &rarr; "/someuri", "", handler<br />
+uc.resolve("/someuri/pathinfo") &rarr; "/someuri", "/pathinfo", handler<br />
+uc.resolve("/notfound/orhere") &rarr; 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&#8216;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&#8217;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