mongrel 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/COPYING +504 -0
  2. data/LICENSE +504 -0
  3. data/README +117 -0
  4. data/Rakefile +30 -0
  5. data/doc/rdoc/classes/Mongrel.html +144 -0
  6. data/doc/rdoc/classes/Mongrel/Error404Handler.html +171 -0
  7. data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000023.html +18 -0
  8. data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000024.html +18 -0
  9. data/doc/rdoc/classes/Mongrel/HeaderOut.html +167 -0
  10. data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000013.html +18 -0
  11. data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000014.html +21 -0
  12. data/doc/rdoc/classes/Mongrel/HttpHandler.html +159 -0
  13. data/doc/rdoc/classes/Mongrel/HttpHandler.src/M000019.html +17 -0
  14. data/doc/rdoc/classes/Mongrel/HttpParser.html +271 -0
  15. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000001.html +28 -0
  16. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000002.html +29 -0
  17. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000003.html +29 -0
  18. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000004.html +41 -0
  19. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000005.html +27 -0
  20. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000006.html +27 -0
  21. data/doc/rdoc/classes/Mongrel/HttpParser.src/M000007.html +28 -0
  22. data/doc/rdoc/classes/Mongrel/HttpRequest.html +177 -0
  23. data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000025.html +30 -0
  24. data/doc/rdoc/classes/Mongrel/HttpResponse.html +202 -0
  25. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000020.html +21 -0
  26. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000021.html +20 -0
  27. data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000022.html +25 -0
  28. data/doc/rdoc/classes/Mongrel/HttpServer.html +336 -0
  29. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000008.html +26 -0
  30. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000009.html +58 -0
  31. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000010.html +22 -0
  32. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000011.html +18 -0
  33. data/doc/rdoc/classes/Mongrel/HttpServer.src/M000012.html +18 -0
  34. data/doc/rdoc/classes/Mongrel/URIClassifier.html +257 -0
  35. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000015.html +54 -0
  36. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000016.html +50 -0
  37. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000017.html +36 -0
  38. data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000018.html +73 -0
  39. data/doc/rdoc/created.rid +1 -0
  40. data/doc/rdoc/files/COPYING.html +756 -0
  41. data/doc/rdoc/files/LICENSE.html +756 -0
  42. data/doc/rdoc/files/README.html +273 -0
  43. data/doc/rdoc/files/ext/http11/http11_c.html +101 -0
  44. data/doc/rdoc/files/lib/mongrel_rb.html +111 -0
  45. data/doc/rdoc/fr_class_index.html +35 -0
  46. data/doc/rdoc/fr_file_index.html +31 -0
  47. data/doc/rdoc/fr_method_index.html +51 -0
  48. data/doc/rdoc/index.html +24 -0
  49. data/doc/rdoc/rdoc-style.css +208 -0
  50. data/examples/camping/blog.rb +300 -0
  51. data/examples/camping/tepee.rb +168 -0
  52. data/examples/simpletest.rb +16 -0
  53. data/examples/webrick_compare.rb +20 -0
  54. data/ext/http11/MANIFEST +0 -0
  55. data/ext/http11/ext_help.h +14 -0
  56. data/ext/http11/extconf.rb +6 -0
  57. data/ext/http11/http11.c +436 -0
  58. data/ext/http11/http11_parser.c +918 -0
  59. data/ext/http11/http11_parser.h +37 -0
  60. data/ext/http11/tst.h +40 -0
  61. data/ext/http11/tst_cleanup.c +24 -0
  62. data/ext/http11/tst_delete.c +146 -0
  63. data/ext/http11/tst_grow_node_free_list.c +38 -0
  64. data/ext/http11/tst_init.c +41 -0
  65. data/ext/http11/tst_insert.c +192 -0
  66. data/ext/http11/tst_search.c +54 -0
  67. data/lib/mongrel.rb +298 -0
  68. data/setup.rb +1360 -0
  69. data/test/test_http11.rb +38 -0
  70. data/test/test_response.rb +44 -0
  71. data/test/test_uriclassifier.rb +104 -0
  72. data/test/test_ws.rb +33 -0
  73. data/tools/rakehelp.rb +99 -0
  74. metadata +132 -0
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>run (Mongrel::HttpServer)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 276</span>
14
+ 276: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>
15
+ 277: <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>
16
+ 278: <span class="ruby-keyword kw">while</span> <span class="ruby-keyword kw">true</span>
17
+ 279: <span class="ruby-ivar">@req_queue</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@socket</span>.<span class="ruby-identifier">accept</span>
18
+ 280: <span class="ruby-keyword kw">end</span>
19
+ 281: <span class="ruby-keyword kw">end</span>
20
+ 282: <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>register (Mongrel::HttpServer)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 288</span>
14
+ 288: <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>)
15
+ 289: <span class="ruby-ivar">@classifier</span>.<span class="ruby-identifier">register</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">handler</span>)
16
+ 290: <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>unregister (Mongrel::HttpServer)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 294</span>
14
+ 294: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unregister</span>(<span class="ruby-identifier">uri</span>)
15
+ 295: <span class="ruby-ivar">@classifier</span>.<span class="ruby-identifier">unregister</span>(<span class="ruby-identifier">uri</span>)
16
+ 296: <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,257 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Mongrel::URIClassifier</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Mongrel::URIClassifier</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/ext/http11/http11_c.html">
59
+ ext/http11/http11.c
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000015">new</a>&nbsp;&nbsp;
90
+ <a href="#M000016">register</a>&nbsp;&nbsp;
91
+ <a href="#M000018">resolve</a>&nbsp;&nbsp;
92
+ <a href="#M000017">unregister</a>&nbsp;&nbsp;
93
+ </div>
94
+ </div>
95
+
96
+ </div>
97
+
98
+
99
+ <!-- if includes -->
100
+
101
+ <div id="section">
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+ <!-- if method_list -->
111
+ <div id="methods">
112
+ <h3 class="section-bar">Public Class methods</h3>
113
+
114
+ <div id="method-M000015" class="method-detail">
115
+ <a name="M000015"></a>
116
+
117
+ <div class="method-heading">
118
+ <a href="URIClassifier.src/M000015.html" target="Code" class="method-signature"
119
+ onclick="popupCode('URIClassifier.src/M000015.html');return false;">
120
+ <span class="method-name">URIClassifier.new &rarr; URIClassifier<br />
121
+ </span>
122
+ </a>
123
+ </div>
124
+
125
+ <div class="method-description">
126
+ <p>
127
+ Initializes a new <a href="URIClassifier.html">URIClassifier</a> object
128
+ that you can use to associate URI sequences with objects. You can actually
129
+ use it with any string sequence and any objects, but it&#8217;s mostly used
130
+ with URIs.
131
+ </p>
132
+ <p>
133
+ It uses TST from <a
134
+ href="http://www.octavian.org/cs/software.html">www.octavian.org/cs/software.html</a>
135
+ to build an ternary search trie to hold all of the URIs. It uses this to do
136
+ an initial search for the a URI prefix, and then to break the URI into
137
+ SCRIPT_NAME and PATH_INFO portions. It actually will do two searches most
138
+ of the time in order to find the right handler for the registered prefix
139
+ portion.
140
+ </p>
141
+ <p>
142
+ Here&#8217;s how it all works. Let&#8217;s say you register
143
+ &quot;/blog&quot; with a BlogHandler. Great. Now, someone goes to
144
+ &quot;/blog/zedsucks/ass&quot;. You want SCRIPT_NAME to be
145
+ &quot;/blog&quot; and PATH_INFO to be &quot;/zedsucks/ass&quot;. <a
146
+ href="URIClassifier.html">URIClassifier</a> first does a TST search and
147
+ comes up with a failure, but knows that the failure ended at the
148
+ &quot;/blog&quot; part. So, that&#8217;s the SCRIPT_NAME. It then tries a
149
+ second search for just &quot;/blog&quot;. If that comes back good then it
150
+ sets the rest (&quot;/zedsucks/ass&quot;) to the PATH_INFO and returns the
151
+ BlogHandler.
152
+ </p>
153
+ <p>
154
+ The optimal approach would be to not do the search twice, but the TST lib
155
+ doesn&#8217;t really support returning prefixes. Might not be hard to add
156
+ later.
157
+ </p>
158
+ <p>
159
+ The key though is that it will try to match the <b>longest</b> match it
160
+ can. If you also register &quot;/blog/zed&quot; then the above URI will
161
+ give SCRIPT_NAME=&quot;/blog/zed&quot;, PATH_INFO=&quot;sucks/ass&quot;.
162
+ Probably not what you want, so your handler will need to do the 404 thing.
163
+ </p>
164
+ <p>
165
+ Take a look at the postamble of example/tepee.rb to see how this is handled
166
+ for Camping.
167
+ </p>
168
+ </div>
169
+ </div>
170
+
171
+ <h3 class="section-bar">Public Instance methods</h3>
172
+
173
+ <div id="method-M000016" class="method-detail">
174
+ <a name="M000016"></a>
175
+
176
+ <div class="method-heading">
177
+ <a href="URIClassifier.src/M000016.html" target="Code" class="method-signature"
178
+ onclick="popupCode('URIClassifier.src/M000016.html');return false;">
179
+ <span class="method-name">uc.register("/someuri", SampleHandler.new) &rarr; nil<br />
180
+ </span>
181
+ </a>
182
+ </div>
183
+
184
+ <div class="method-description">
185
+ <p>
186
+ Registers the SampleHandler (one for all requests) with the
187
+ &quot;/someuri&quot;. When URIClassifier::resolve is called with
188
+ &quot;/someuri&quot; it&#8217;ll return SampleHandler immediately. When
189
+ &quot;/someuri/pathhere&quot; is called it&#8217;ll find SomeHandler after
190
+ a second search, and setup PATH_INFO=&quot;/pathhere&quot;.
191
+ </p>
192
+ <p>
193
+ You actually can reuse this class to register nearly anything and quickly
194
+ resolve it. This could be used for caching, fast mapping, etc. The downside
195
+ is it uses much more memory than a Hash, but it can be a lot faster.
196
+ It&#8217;s main advantage is that it works on prefixes, which is damn hard
197
+ to get right with a Hash.
198
+ </p>
199
+ </div>
200
+ </div>
201
+
202
+ <div id="method-M000018" class="method-detail">
203
+ <a name="M000018"></a>
204
+
205
+ <div class="method-heading">
206
+ <a href="URIClassifier.src/M000018.html" target="Code" class="method-signature"
207
+ onclick="popupCode('URIClassifier.src/M000018.html');return false;">
208
+ <span class="method-name">uc.resolve("/someuri") &rarr; "/someuri", "", handler<br />
209
+ uc.resolve("/someuri/pathinfo") &rarr; "/someuri", "/pathinfo", handler<br />
210
+ uc.resolve("/notfound/orhere") &rarr; nil, nil, nil<br />
211
+ </span>
212
+ </a>
213
+ </div>
214
+
215
+ <div class="method-description">
216
+ <p>
217
+ Attempts to resolve either the whole URI or at the longest prefix,
218
+ returning the prefix (as script_info), path (as path_info), and registered
219
+ handler (usually an <a href="HttpHandler.html">HttpHandler</a>).
220
+ </p>
221
+ <p>
222
+ It expects strings. Don&#8216;t try other string-line stuff yet.
223
+ </p>
224
+ </div>
225
+ </div>
226
+
227
+ <div id="method-M000017" class="method-detail">
228
+ <a name="M000017"></a>
229
+
230
+ <div class="method-heading">
231
+ <a href="URIClassifier.src/M000017.html" target="Code" class="method-signature"
232
+ onclick="popupCode('URIClassifier.src/M000017.html');return false;">
233
+ <span class="method-name">uc.unregister("/someuri")<br />
234
+ </span>
235
+ </a>
236
+ </div>
237
+
238
+ <div class="method-description">
239
+ <p>
240
+ Yep, just removes this uri and it&#8217;s handler from the trie.
241
+ </p>
242
+ </div>
243
+ </div>
244
+
245
+
246
+ </div>
247
+
248
+
249
+ </div>
250
+
251
+
252
+ <div id="validator-badges">
253
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
254
+ </div>
255
+
256
+ </body>
257
+ </html>
@@ -0,0 +1,54 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>new (Mongrel::URIClassifier)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre>/**
14
+ * call-seq:
15
+ * URIClassifier.new -&gt; URIClassifier
16
+ *
17
+ * Initializes a new URIClassifier object that you can use to associate URI sequences
18
+ * with objects. You can actually use it with any string sequence and any objects,
19
+ * but it's mostly used with URIs.
20
+ *
21
+ * It uses TST from http://www.octavian.org/cs/software.html to build an ternary search
22
+ * trie to hold all of the URIs. It uses this to do an initial search for the a URI
23
+ * prefix, and then to break the URI into SCRIPT_NAME and PATH_INFO portions. It actually
24
+ * will do two searches most of the time in order to find the right handler for the
25
+ * registered prefix portion.
26
+ *
27
+ * Here's how it all works. Let's say you register &quot;/blog&quot; with a BlogHandler. Great.
28
+ * Now, someone goes to &quot;/blog/zedsucks/ass&quot;. You want SCRIPT_NAME to be &quot;/blog&quot; and
29
+ * PATH_INFO to be &quot;/zedsucks/ass&quot;. URIClassifier first does a TST search and comes
30
+ * up with a failure, but knows that the failure ended at the &quot;/blog&quot; part. So, that's
31
+ * the SCRIPT_NAME. It then tries a second search for just &quot;/blog&quot;. If that comes back
32
+ * good then it sets the rest (&quot;/zedsucks/ass&quot;) to the PATH_INFO and returns the BlogHandler.
33
+ *
34
+ * The optimal approach would be to not do the search twice, but the TST lib doesn't
35
+ * really support returning prefixes. Might not be hard to add later.
36
+ *
37
+ * The key though is that it will try to match the *longest* match it can. If you
38
+ * also register &quot;/blog/zed&quot; then the above URI will give SCRIPT_NAME=&quot;/blog/zed&quot;,
39
+ * PATH_INFO=&quot;sucks/ass&quot;. Probably not what you want, so your handler will need to
40
+ * do the 404 thing.
41
+ *
42
+ * Take a look at the postamble of example/tepee.rb to see how this is handled for
43
+ * Camping.
44
+ */
45
+ VALUE URIClassifier_init(VALUE self)
46
+ {
47
+ VALUE hash;
48
+
49
+ // we create an internal hash to protect stuff from the GC
50
+ hash = rb_hash_new();
51
+ rb_ivar_set(self, id_handler_map, hash);
52
+ }</pre>
53
+ </body>
54
+ </html>
@@ -0,0 +1,50 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>register (Mongrel::URIClassifier)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre>/**
14
+ * call-seq:
15
+ * uc.register(&quot;/someuri&quot;, SampleHandler.new) -&gt; nil
16
+ *
17
+ * Registers the SampleHandler (one for all requests) with the &quot;/someuri&quot;.
18
+ * When URIClassifier::resolve is called with &quot;/someuri&quot; it'll return
19
+ * SampleHandler immediately. When &quot;/someuri/pathhere&quot; is called it'll
20
+ * find SomeHandler after a second search, and setup PATH_INFO=&quot;/pathhere&quot;.
21
+ *
22
+ * You actually can reuse this class to register nearly anything and
23
+ * quickly resolve it. This could be used for caching, fast mapping, etc.
24
+ * The downside is it uses much more memory than a Hash, but it can be
25
+ * a lot faster. It's main advantage is that it works on prefixes, which
26
+ * is damn hard to get right with a Hash.
27
+ */
28
+ VALUE URIClassifier_register(VALUE self, VALUE uri, VALUE handler)
29
+ {
30
+ int rc = 0;
31
+ void *ptr = NULL;
32
+ struct tst *tst = NULL;
33
+ DATA_GET(self, struct tst, tst);
34
+
35
+ rc = tst_insert((unsigned char *)StringValueCStr(uri), (void *)handler , tst, 0, &amp;ptr);
36
+
37
+ if(rc == TST_DUPLICATE_KEY) {
38
+ rb_raise(rb_eStandardError, &quot;Handler already registered with that name&quot;);
39
+ } else if(rc == TST_ERROR) {
40
+ rb_raise(rb_eStandardError, &quot;Memory error registering handler&quot;);
41
+ } else if(rc == TST_NULL_KEY) {
42
+ rb_raise(rb_eStandardError, &quot;URI was empty&quot;);
43
+ }
44
+
45
+ rb_hash_aset(rb_ivar_get(self, id_handler_map), uri, handler);
46
+
47
+ return Qnil;
48
+ }</pre>
49
+ </body>
50
+ </html>
@@ -0,0 +1,36 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>unregister (Mongrel::URIClassifier)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre>/**
14
+ * call-seq:
15
+ * uc.unregister(&quot;/someuri&quot;)
16
+ *
17
+ * Yep, just removes this uri and it's handler from the trie.
18
+ */
19
+ VALUE URIClassifier_unregister(VALUE self, VALUE uri)
20
+ {
21
+ void *handler = NULL;
22
+ struct tst *tst = NULL;
23
+ DATA_GET(self, struct tst, tst);
24
+
25
+ handler = tst_delete((unsigned char *)StringValueCStr(uri), tst);
26
+
27
+ if(handler) {
28
+ rb_hash_delete(rb_ivar_get(self, id_handler_map), uri);
29
+
30
+ return (VALUE)handler;
31
+ } else {
32
+ return Qnil;
33
+ }
34
+ }</pre>
35
+ </body>
36
+ </html>