mongrel 0.3.13 → 0.3.13.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/bin/mongrel_rails +1 -1
- data/doc/rdoc/classes/Mongrel.html +1 -0
- data/doc/rdoc/classes/Mongrel/CGIWrapper.html +49 -49
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000098.html +11 -21
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000099.html +34 -14
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000100.html +21 -12
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000101.html +14 -5
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000102.html +12 -5
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000103.html +5 -5
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000104.html +5 -6
- data/doc/rdoc/classes/Mongrel/{URIClassifier.src/M000088.html → CGIWrapper.src/M000105.html} +5 -5
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000106.html +19 -0
- data/doc/rdoc/classes/Mongrel/Camping.html +5 -5
- data/doc/rdoc/classes/Mongrel/Camping.src/{M000046.html → M000047.html} +0 -0
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.html +10 -10
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000048.html +5 -38
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000049.html +51 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.html +65 -65
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000025.html +11 -29
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000026.html +29 -5
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000027.html +5 -5
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000028.html +5 -5
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000029.html +5 -5
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000030.html +5 -9
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000031.html +9 -5
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000032.html +5 -5
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000033.html +5 -5
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000034.html +5 -11
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000035.html +11 -11
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000036.html +11 -5
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000037.html +18 -0
- data/doc/rdoc/classes/Mongrel/Command/Registry.html +15 -15
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000038.html +7 -12
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000039.html +12 -37
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000040.html +50 -0
- data/doc/rdoc/classes/Mongrel/Configurator.html +143 -107
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000107.html +16 -7
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000108.html +18 -7
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000109.html +7 -10
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000110.html +7 -5
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000111.html +10 -21
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000112.html +5 -6
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000113.html +21 -17
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000114.html +6 -20
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000115.html +17 -5
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000116.html +20 -11
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000117.html +5 -6
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000118.html +11 -9
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000119.html +6 -12
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000120.html +5 -5
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000121.html +9 -22
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000122.html +12 -5
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000123.html +5 -20
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000124.html +22 -5
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000125.html +18 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000126.html +33 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000127.html +18 -0
- data/doc/rdoc/classes/Mongrel/Const.html +6 -1
- data/doc/rdoc/classes/Mongrel/DeflateFilter.html +10 -10
- data/doc/rdoc/classes/Mongrel/DeflateFilter.src/{M000094.html → M000096.html} +5 -5
- data/doc/rdoc/classes/Mongrel/DeflateFilter.src/{M000095.html → M000097.html} +14 -14
- data/doc/rdoc/classes/Mongrel/DirHandler.html +31 -31
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000057.html +8 -30
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000058.html +30 -29
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000059.html +29 -50
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000060.html +50 -26
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000061.html +26 -5
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000062.html +18 -0
- data/doc/rdoc/classes/Mongrel/Error404Handler.html +10 -10
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000125.html → M000128.html} +4 -4
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000126.html → M000129.html} +4 -4
- data/doc/rdoc/classes/Mongrel/HeaderOut.html +10 -10
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000070.html +5 -5
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000071.html +18 -0
- data/doc/rdoc/classes/Mongrel/HttpHandler.html +31 -9
- data/doc/rdoc/classes/Mongrel/{URIClassifier.src/M000089.html → HttpHandler.src/M000076.html} +4 -5
- data/doc/rdoc/classes/Mongrel/HttpHandler.src/{M000075.html → M000077.html} +3 -3
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.html +30 -15
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000022.html +4 -6
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000023.html +6 -4
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000024.html +17 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.html +35 -35
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000050.html +5 -6
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000051.html +7 -7
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000052.html +7 -37
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000053.html +37 -5
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000054.html +5 -5
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000055.html +5 -6
- data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000049.html → M000056.html} +6 -6
- data/doc/rdoc/classes/Mongrel/HttpRequest.html +20 -20
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000130.html → M000135.html} +38 -38
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000131.html → M000136.html} +6 -6
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000132.html → M000137.html} +6 -6
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000133.html → M000138.html} +18 -18
- data/doc/rdoc/classes/Mongrel/HttpResponse.html +61 -61
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000078.html +12 -12
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000079.html +7 -9
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000080.html +12 -9
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000081.html +9 -9
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000082.html +9 -18
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000083.html +9 -8
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000084.html +18 -7
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000085.html +8 -7
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000086.html +7 -7
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000087.html +7 -5
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000088.html +20 -0
- data/doc/rdoc/classes/Mongrel/{HeaderOut.src/M000069.html → HttpResponse.src/M000089.html} +5 -5
- data/doc/rdoc/classes/Mongrel/HttpServer.html +38 -38
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000063.html +12 -70
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000064.html +76 -13
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000065.html +13 -50
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000066.html +50 -21
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000067.html +20 -4
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000068.html +5 -9
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000069.html +22 -0
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.html +15 -15
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000041.html +26 -12
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000042.html +12 -13
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000043.html +26 -0
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.html +15 -15
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000044.html +9 -38
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000045.html +38 -10
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000046.html +23 -0
- data/doc/rdoc/classes/Mongrel/RedirectHandler.html +187 -0
- data/doc/rdoc/classes/Mongrel/RedirectHandler.src/M000133.html +22 -0
- data/doc/rdoc/classes/Mongrel/RedirectHandler.src/M000134.html +27 -0
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.html +16 -16
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/{M000127.html → M000130.html} +10 -10
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/{M000128.html → M000131.html} +10 -10
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/{M000129.html → M000132.html} +4 -4
- data/doc/rdoc/classes/Mongrel/StatusHandler.html +20 -20
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000072.html +5 -11
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000073.html +11 -29
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000074.html +29 -7
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000075.html +20 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.html +30 -30
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000090.html +5 -26
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000091.html +5 -38
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000092.html +18 -15
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000093.html +25 -57
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000094.html +36 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000095.html +83 -0
- data/doc/rdoc/classes/RequestLog/Access.html +5 -5
- data/doc/rdoc/classes/RequestLog/Access.src/{M000134.html → M000139.html} +0 -0
- data/doc/rdoc/classes/RequestLog/Files.html +5 -5
- data/doc/rdoc/classes/RequestLog/Files.src/{M000135.html → M000140.html} +0 -0
- data/doc/rdoc/classes/RequestLog/Objects.html +5 -5
- data/doc/rdoc/classes/RequestLog/Objects.src/{M000137.html → M000142.html} +0 -0
- data/doc/rdoc/classes/RequestLog/Params.html +5 -5
- data/doc/rdoc/classes/RequestLog/Params.src/{M000138.html → M000143.html} +0 -0
- data/doc/rdoc/classes/RequestLog/Threads.html +5 -5
- data/doc/rdoc/classes/RequestLog/Threads.src/{M000136.html → M000141.html} +0 -0
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/ext/http11/http11_c.html +1 -1
- data/doc/rdoc/files/lib/mongrel/handlers_rb.html +1 -1
- data/doc/rdoc/files/lib/mongrel_rb.html +1 -1
- data/doc/rdoc/fr_class_index.html +1 -0
- data/doc/rdoc/fr_method_index.html +124 -119
- data/examples/simpletest.rb +2 -0
- data/ext/http11/http11.c +1 -1
- data/lib/mongrel.rb +30 -5
- data/lib/mongrel/handlers.rb +57 -2
- data/test/test_redirect_handler.rb +40 -0
- metadata +47 -38
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000096.html +0 -24
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000097.html +0 -47
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000047.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000024.html +0 -24
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000037.html +0 -20
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000105.html +0 -29
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000106.html +0 -31
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000056.html +0 -21
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000076.html +0 -25
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000077.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000062.html +0 -25
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000040.html +0 -39
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000043.html +0 -22
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000071.html +0 -18
@@ -5,47 +5,14 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>inspect (Mongrel::URIClassifier)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
|
-
<pre
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
* Registers the SampleHandler (one for all requests) with the "/someuri".
|
18
|
-
* When URIClassifier::resolve is called with "/someuri" it'll return
|
19
|
-
* SampleHandler immediately. When called with "/someuri/iwant" it'll also
|
20
|
-
* return SomeHandler immediatly, with no additional searches, but it will
|
21
|
-
* return path info with "/iwant".
|
22
|
-
*
|
23
|
-
* You actually can reuse this class to register nearly anything and
|
24
|
-
* quickly resolve it. This could be used for caching, fast mapping, etc.
|
25
|
-
* The downside is it uses much more memory than a Hash, but it can be
|
26
|
-
* a lot faster. It's main advantage is that it works on prefixes, which
|
27
|
-
* is damn hard to get right with a Hash.
|
28
|
-
*/
|
29
|
-
VALUE URIClassifier_register(VALUE self, VALUE uri, VALUE handler)
|
30
|
-
{
|
31
|
-
int rc = 0;
|
32
|
-
void *ptr = NULL;
|
33
|
-
struct tst *tst = NULL;
|
34
|
-
DATA_GET(self, struct tst, tst);
|
35
|
-
|
36
|
-
rc = tst_insert((unsigned char *)StringValueCStr(uri), (void *)handler , tst, 0, &ptr);
|
37
|
-
|
38
|
-
if(rc == TST_DUPLICATE_KEY) {
|
39
|
-
rb_raise(rb_eStandardError, "Handler already registered with that name");
|
40
|
-
} else if(rc == TST_ERROR) {
|
41
|
-
rb_raise(rb_eStandardError, "Memory error registering handler");
|
42
|
-
} else if(rc == TST_NULL_KEY) {
|
43
|
-
rb_raise(rb_eStandardError, "URI was empty");
|
44
|
-
}
|
45
|
-
|
46
|
-
rb_hash_aset(rb_ivar_get(self, id_handler_map), uri, handler);
|
47
|
-
|
48
|
-
return Qnil;
|
49
|
-
}</pre>
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/mongrel.rb, line 58</span>
|
14
|
+
58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">inspect</span>
|
15
|
+
59: <span class="ruby-ivar">@handler_map</span>.<span class="ruby-identifier">inspect</span>
|
16
|
+
60: <span class="ruby-keyword kw">end</span></pre>
|
50
17
|
</body>
|
51
18
|
</html>
|
@@ -5,32 +5,35 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>new (Mongrel::URIClassifier)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
13
|
<pre>/**
|
14
14
|
* call-seq:
|
15
|
-
*
|
15
|
+
* URIClassifier.new -> 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.
|
16
26
|
*
|
17
|
-
* Yep, just removes this uri and it's handler from the trie.
|
18
27
|
*/
|
19
|
-
VALUE
|
28
|
+
VALUE URIClassifier_init(VALUE self)
|
20
29
|
{
|
21
|
-
|
22
|
-
struct tst *tst = NULL;
|
23
|
-
DATA_GET(self, struct tst, tst);
|
24
|
-
|
25
|
-
handler = tst_delete((unsigned char *)StringValueCStr(uri), tst);
|
30
|
+
VALUE hash;
|
26
31
|
|
27
|
-
|
28
|
-
|
32
|
+
// we create an internal hash to protect stuff from the GC
|
33
|
+
hash = rb_hash_new();
|
34
|
+
rb_ivar_set(self, id_handler_map, hash);
|
29
35
|
|
30
|
-
|
31
|
-
} else {
|
32
|
-
return Qnil;
|
33
|
-
}
|
36
|
+
return self;
|
34
37
|
}</pre>
|
35
38
|
</body>
|
36
39
|
</html>
|
@@ -5,79 +5,47 @@
|
|
5
5
|
|
6
6
|
<html>
|
7
7
|
<head>
|
8
|
-
<title>
|
8
|
+
<title>register (Mongrel::URIClassifier)</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
11
11
|
</head>
|
12
12
|
<body class="standalone-code">
|
13
13
|
<pre>/**
|
14
14
|
* call-seq:
|
15
|
-
* uc.
|
16
|
-
* uc.resolve("/someuri/pathinfo") -> "/someuri", "/pathinfo", handler
|
17
|
-
* uc.resolve("/notfound/orhere") -> nil, nil, nil
|
18
|
-
* uc.resolve("/") -> "/", "/", handler # if uc.register("/", handler)
|
19
|
-
* uc.resolve("/path/from/root") -> "/", "/path/from/root", handler # if uc.register("/", handler)
|
20
|
-
*
|
21
|
-
* Attempts to resolve either the whole URI or at the longest prefix, returning
|
22
|
-
* the prefix (as script_info), path (as path_info), and registered handler
|
23
|
-
* (usually an HttpHandler). If it doesn't find a handler registered at the longest
|
24
|
-
* match then it returns nil,nil,nil.
|
15
|
+
* uc.register("/someuri", SampleHandler.new) -> nil
|
25
16
|
*
|
26
|
-
*
|
27
|
-
*
|
28
|
-
*
|
29
|
-
*
|
30
|
-
*
|
31
|
-
*
|
32
|
-
* This is very powerful since it means you can also attach handlers to parts of the ;
|
33
|
-
* (semi-colon) separated path params, any part of the path, use off chars, anything really.
|
34
|
-
* It also means that it's very efficient to do this only taking as long as the URI has
|
35
|
-
* characters.
|
17
|
+
* Registers the SampleHandler (one for all requests) with the "/someuri".
|
18
|
+
* When URIClassifier::resolve is called with "/someuri" it'll return
|
19
|
+
* SampleHandler immediately. When called with "/someuri/iwant" it'll also
|
20
|
+
* return SomeHandler immediatly, with no additional searches, but it will
|
21
|
+
* return path info with "/iwant".
|
36
22
|
*
|
37
|
-
*
|
38
|
-
*
|
39
|
-
*
|
40
|
-
*
|
41
|
-
*
|
42
|
-
*
|
43
|
-
* It expects strings with no embedded '\0' characters. Don't try other string-like stuff yet.
|
23
|
+
* You actually can reuse this class to register nearly anything and
|
24
|
+
* quickly resolve it. This could be used for caching, fast mapping, etc.
|
25
|
+
* The downside is it uses much more memory than a Hash, but it can be
|
26
|
+
* a lot faster. It's main advantage is that it works on prefixes, which
|
27
|
+
* is damn hard to get right with a Hash.
|
44
28
|
*/
|
45
|
-
VALUE
|
29
|
+
VALUE URIClassifier_register(VALUE self, VALUE uri, VALUE handler)
|
46
30
|
{
|
47
|
-
|
48
|
-
|
31
|
+
int rc = 0;
|
32
|
+
void *ptr = NULL;
|
49
33
|
struct tst *tst = NULL;
|
50
|
-
VALUE result;
|
51
|
-
unsigned char *uri_str = NULL;
|
52
|
-
|
53
34
|
DATA_GET(self, struct tst, tst);
|
54
|
-
uri_str = (unsigned char *)StringValueCStr(uri);
|
55
|
-
|
56
|
-
handler = tst_search(uri_str, tst, &pref_len);
|
57
35
|
|
58
|
-
|
59
|
-
result = rb_ary_new();
|
36
|
+
rc = tst_insert((unsigned char *)StringValueCStr(uri), (void *)handler , tst, 0, &ptr);
|
60
37
|
|
61
|
-
if(
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
} else {
|
68
|
-
// matches a script so process like normal
|
69
|
-
rb_ary_push(result, rb_str_substr(uri, pref_len, RSTRING(uri)->len));
|
70
|
-
}
|
71
|
-
|
72
|
-
rb_ary_push(result, (VALUE)handler);
|
73
|
-
} else {
|
74
|
-
// not found so push back nothing
|
75
|
-
rb_ary_push(result, Qnil);
|
76
|
-
rb_ary_push(result, Qnil);
|
77
|
-
rb_ary_push(result, Qnil);
|
38
|
+
if(rc == TST_DUPLICATE_KEY) {
|
39
|
+
rb_raise(rb_eStandardError, "Handler already registered with that name");
|
40
|
+
} else if(rc == TST_ERROR) {
|
41
|
+
rb_raise(rb_eStandardError, "Memory error registering handler");
|
42
|
+
} else if(rc == TST_NULL_KEY) {
|
43
|
+
rb_raise(rb_eStandardError, "URI was empty");
|
78
44
|
}
|
45
|
+
|
46
|
+
rb_hash_aset(rb_ivar_get(self, id_handler_map), uri, handler);
|
79
47
|
|
80
|
-
return
|
48
|
+
return Qnil;
|
81
49
|
}</pre>
|
82
50
|
</body>
|
83
51
|
</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("/someuri")
|
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>
|
@@ -0,0 +1,83 @@
|
|
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>resolve (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.resolve("/someuri") -> "/someuri", "", handler
|
16
|
+
* uc.resolve("/someuri/pathinfo") -> "/someuri", "/pathinfo", handler
|
17
|
+
* uc.resolve("/notfound/orhere") -> nil, nil, nil
|
18
|
+
* uc.resolve("/") -> "/", "/", handler # if uc.register("/", handler)
|
19
|
+
* uc.resolve("/path/from/root") -> "/", "/path/from/root", handler # if uc.register("/", handler)
|
20
|
+
*
|
21
|
+
* Attempts to resolve either the whole URI or at the longest prefix, returning
|
22
|
+
* the prefix (as script_info), path (as path_info), and registered handler
|
23
|
+
* (usually an HttpHandler). If it doesn't find a handler registered at the longest
|
24
|
+
* match then it returns nil,nil,nil.
|
25
|
+
*
|
26
|
+
* Because the resolver uses a trie you are able to register a handler at *any* character
|
27
|
+
* in the URI and it will be handled as long as it's the longest prefix. So, if you
|
28
|
+
* registered handler #1 at "/something/lik", and #2 at "/something/like/that", then a
|
29
|
+
* a search for "/something/like" would give you #1. A search for "/something/like/that/too"
|
30
|
+
* would give you #2.
|
31
|
+
*
|
32
|
+
* This is very powerful since it means you can also attach handlers to parts of the ;
|
33
|
+
* (semi-colon) separated path params, any part of the path, use off chars, anything really.
|
34
|
+
* It also means that it's very efficient to do this only taking as long as the URI has
|
35
|
+
* characters.
|
36
|
+
*
|
37
|
+
* A slight modification to the CGI 1.2 standard is given for handlers registered to "/".
|
38
|
+
* CGI expects all CGI scripts to be at some script path, so it doesn't really say anything
|
39
|
+
* about a script that handles the root. To make this work, the resolver will detect that
|
40
|
+
* the requested handler is at "/", and return that for script_name, and then simply return
|
41
|
+
* the full URI back as path_info.
|
42
|
+
*
|
43
|
+
* It expects strings with no embedded '\0' characters. Don't try other string-like stuff yet.
|
44
|
+
*/
|
45
|
+
VALUE URIClassifier_resolve(VALUE self, VALUE uri)
|
46
|
+
{
|
47
|
+
void *handler = NULL;
|
48
|
+
int pref_len = 0;
|
49
|
+
struct tst *tst = NULL;
|
50
|
+
VALUE result;
|
51
|
+
unsigned char *uri_str = NULL;
|
52
|
+
|
53
|
+
DATA_GET(self, struct tst, tst);
|
54
|
+
uri_str = (unsigned char *)StringValueCStr(uri);
|
55
|
+
|
56
|
+
handler = tst_search(uri_str, tst, &pref_len);
|
57
|
+
|
58
|
+
// setup for multiple return values
|
59
|
+
result = rb_ary_new();
|
60
|
+
|
61
|
+
if(handler) {
|
62
|
+
rb_ary_push(result, rb_str_substr (uri, 0, pref_len));
|
63
|
+
// compensate for a script_name="/" where we need to add the "/" to path_info to keep it consistent
|
64
|
+
if(pref_len == 1 && uri_str[0] == '/') {
|
65
|
+
// matches the root URI so we have to use the whole URI as the path_info
|
66
|
+
rb_ary_push(result, uri);
|
67
|
+
} else {
|
68
|
+
// matches a script so process like normal
|
69
|
+
rb_ary_push(result, rb_str_substr(uri, pref_len, RSTRING(uri)->len));
|
70
|
+
}
|
71
|
+
|
72
|
+
rb_ary_push(result, (VALUE)handler);
|
73
|
+
} else {
|
74
|
+
// not found so push back nothing
|
75
|
+
rb_ary_push(result, Qnil);
|
76
|
+
rb_ary_push(result, Qnil);
|
77
|
+
rb_ary_push(result, Qnil);
|
78
|
+
}
|
79
|
+
|
80
|
+
return result;
|
81
|
+
}</pre>
|
82
|
+
</body>
|
83
|
+
</html>
|
@@ -93,7 +93,7 @@ log when daemonized).
|
|
93
93
|
<h3 class="section-bar">Methods</h3>
|
94
94
|
|
95
95
|
<div class="name-list">
|
96
|
-
<a href="#
|
96
|
+
<a href="#M000139">process</a>
|
97
97
|
</div>
|
98
98
|
</div>
|
99
99
|
|
@@ -122,12 +122,12 @@ log when daemonized).
|
|
122
122
|
<div id="methods">
|
123
123
|
<h3 class="section-bar">Public Instance methods</h3>
|
124
124
|
|
125
|
-
<div id="method-
|
126
|
-
<a name="
|
125
|
+
<div id="method-M000139" class="method-detail">
|
126
|
+
<a name="M000139"></a>
|
127
127
|
|
128
128
|
<div class="method-heading">
|
129
|
-
<a href="Access.src/
|
130
|
-
onclick="popupCode('Access.src/
|
129
|
+
<a href="Access.src/M000139.html" target="Code" class="method-signature"
|
130
|
+
onclick="popupCode('Access.src/M000139.html');return false;">
|
131
131
|
<span class="method-name">process</span><span class="method-args">(request,response)</span>
|
132
132
|
</a>
|
133
133
|
</div>
|
File without changes
|
@@ -86,7 +86,7 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
89
|
+
<a href="#M000140">process</a>
|
90
90
|
</div>
|
91
91
|
</div>
|
92
92
|
|
@@ -115,12 +115,12 @@
|
|
115
115
|
<div id="methods">
|
116
116
|
<h3 class="section-bar">Public Instance methods</h3>
|
117
117
|
|
118
|
-
<div id="method-
|
119
|
-
<a name="
|
118
|
+
<div id="method-M000140" class="method-detail">
|
119
|
+
<a name="M000140"></a>
|
120
120
|
|
121
121
|
<div class="method-heading">
|
122
|
-
<a href="Files.src/
|
123
|
-
onclick="popupCode('Files.src/
|
122
|
+
<a href="Files.src/M000140.html" target="Code" class="method-signature"
|
123
|
+
onclick="popupCode('Files.src/M000140.html');return false;">
|
124
124
|
<span class="method-name">process</span><span class="method-args">(request, response)</span>
|
125
125
|
</a>
|
126
126
|
</div>
|
File without changes
|
@@ -86,7 +86,7 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
89
|
+
<a href="#M000142">process</a>
|
90
90
|
</div>
|
91
91
|
</div>
|
92
92
|
|
@@ -115,12 +115,12 @@
|
|
115
115
|
<div id="methods">
|
116
116
|
<h3 class="section-bar">Public Instance methods</h3>
|
117
117
|
|
118
|
-
<div id="method-
|
119
|
-
<a name="
|
118
|
+
<div id="method-M000142" class="method-detail">
|
119
|
+
<a name="M000142"></a>
|
120
120
|
|
121
121
|
<div class="method-heading">
|
122
|
-
<a href="Objects.src/
|
123
|
-
onclick="popupCode('Objects.src/
|
122
|
+
<a href="Objects.src/M000142.html" target="Code" class="method-signature"
|
123
|
+
onclick="popupCode('Objects.src/M000142.html');return false;">
|
124
124
|
<span class="method-name">process</span><span class="method-args">(request, response)</span>
|
125
125
|
</a>
|
126
126
|
</div>
|
File without changes
|
@@ -86,7 +86,7 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
89
|
+
<a href="#M000143">process</a>
|
90
90
|
</div>
|
91
91
|
</div>
|
92
92
|
|
@@ -115,12 +115,12 @@
|
|
115
115
|
<div id="methods">
|
116
116
|
<h3 class="section-bar">Public Instance methods</h3>
|
117
117
|
|
118
|
-
<div id="method-
|
119
|
-
<a name="
|
118
|
+
<div id="method-M000143" class="method-detail">
|
119
|
+
<a name="M000143"></a>
|
120
120
|
|
121
121
|
<div class="method-heading">
|
122
|
-
<a href="Params.src/
|
123
|
-
onclick="popupCode('Params.src/
|
122
|
+
<a href="Params.src/M000143.html" target="Code" class="method-signature"
|
123
|
+
onclick="popupCode('Params.src/M000143.html');return false;">
|
124
124
|
<span class="method-name">process</span><span class="method-args">(request, response)</span>
|
125
125
|
</a>
|
126
126
|
</div>
|
File without changes
|
@@ -86,7 +86,7 @@
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
87
87
|
|
88
88
|
<div class="name-list">
|
89
|
-
<a href="#
|
89
|
+
<a href="#M000141">process</a>
|
90
90
|
</div>
|
91
91
|
</div>
|
92
92
|
|
@@ -115,12 +115,12 @@
|
|
115
115
|
<div id="methods">
|
116
116
|
<h3 class="section-bar">Public Instance methods</h3>
|
117
117
|
|
118
|
-
<div id="method-
|
119
|
-
<a name="
|
118
|
+
<div id="method-M000141" class="method-detail">
|
119
|
+
<a name="M000141"></a>
|
120
120
|
|
121
121
|
<div class="method-heading">
|
122
|
-
<a href="Threads.src/
|
123
|
-
onclick="popupCode('Threads.src/
|
122
|
+
<a href="Threads.src/M000141.html" target="Code" class="method-signature"
|
123
|
+
onclick="popupCode('Threads.src/M000141.html');return false;">
|
124
124
|
<span class="method-name">process</span><span class="method-args">(request, response)</span>
|
125
125
|
</a>
|
126
126
|
</div>
|