mongrel 0.2.2 → 0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +27 -25
- data/Rakefile +2 -3
- data/bin/mongrel_rails +114 -0
- data/doc/rdoc/classes/Mongrel.html +30 -0
- data/doc/rdoc/classes/Mongrel.src/M000001.html +18 -0
- data/doc/rdoc/classes/Mongrel/Const.html +2 -2
- data/doc/rdoc/classes/Mongrel/DirHandler.html +84 -21
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000009.html +7 -18
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000010.html +26 -9
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000011.html +27 -26
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000012.html +31 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000013.html +38 -0
- data/doc/rdoc/classes/Mongrel/Error404Handler.html +10 -10
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000028.html → M000033.html} +4 -4
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/{M000029.html → M000034.html} +4 -4
- data/doc/rdoc/classes/Mongrel/HeaderOut.html +10 -10
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000017.html → M000019.html} +4 -4
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/{M000018.html → M000020.html} +7 -7
- data/doc/rdoc/classes/Mongrel/HttpHandler.html +5 -5
- data/doc/rdoc/classes/Mongrel/HttpHandler.src/{M000023.html → M000025.html} +3 -3
- data/doc/rdoc/classes/Mongrel/HttpParser.html +35 -35
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000002.html +5 -6
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000003.html +7 -7
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000004.html +8 -20
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000005.html +20 -6
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000006.html +5 -5
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000007.html +5 -6
- data/doc/rdoc/classes/Mongrel/HttpParser.src/{M000001.html → M000008.html} +6 -6
- data/doc/rdoc/classes/Mongrel/HttpRequest.html +5 -5
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/{M000030.html → M000035.html} +17 -17
- data/doc/rdoc/classes/Mongrel/HttpResponse.html +66 -21
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000026.html +8 -6
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000027.html +7 -12
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000028.html +19 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000029.html +18 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000030.html +20 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000031.html +21 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000032.html +20 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.html +28 -28
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000014.html +18 -10
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000015.html +51 -5
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000016.html +9 -4
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000017.html +18 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000018.html +18 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.html +31 -21
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000021.html +18 -15
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000022.html +25 -42
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000023.html +36 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000024.html +84 -0
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README.html +32 -42
- data/doc/rdoc/files/ext/http11/http11_c.html +1 -1
- data/doc/rdoc/files/lib/mongrel_rb.html +1 -1
- data/doc/rdoc/fr_method_index.html +35 -30
- data/examples/simpletest.rb +16 -6
- data/ext/http11/http11.c +19 -3
- data/ext/http11/tst_search.c +2 -3
- data/lib/mongrel.rb +108 -20
- data/test/test_uriclassifier.rb +22 -1
- metadata +25 -19
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000008.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000024.html +0 -21
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000025.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000012.html +0 -31
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000013.html +0 -64
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000019.html +0 -39
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000020.html +0 -51
- data/lib/#mongrel.rb# +0 -493
|
@@ -86,10 +86,10 @@
|
|
|
86
86
|
<h3 class="section-bar">Methods</h3>
|
|
87
87
|
|
|
88
88
|
<div class="name-list">
|
|
89
|
-
<a href="#
|
|
90
|
-
<a href="#
|
|
91
|
-
<a href="#
|
|
92
|
-
<a href="#
|
|
89
|
+
<a href="#M000021">new</a>
|
|
90
|
+
<a href="#M000022">register</a>
|
|
91
|
+
<a href="#M000024">resolve</a>
|
|
92
|
+
<a href="#M000023">unregister</a>
|
|
93
93
|
</div>
|
|
94
94
|
</div>
|
|
95
95
|
|
|
@@ -111,12 +111,12 @@
|
|
|
111
111
|
<div id="methods">
|
|
112
112
|
<h3 class="section-bar">Public Class methods</h3>
|
|
113
113
|
|
|
114
|
-
<div id="method-
|
|
115
|
-
<a name="
|
|
114
|
+
<div id="method-M000021" class="method-detail">
|
|
115
|
+
<a name="M000021"></a>
|
|
116
116
|
|
|
117
117
|
<div class="method-heading">
|
|
118
|
-
<a href="URIClassifier.src/
|
|
119
|
-
onclick="popupCode('URIClassifier.src/
|
|
118
|
+
<a href="URIClassifier.src/M000021.html" target="Code" class="method-signature"
|
|
119
|
+
onclick="popupCode('URIClassifier.src/M000021.html');return false;">
|
|
120
120
|
<span class="method-name">URIClassifier.new → URIClassifier<br />
|
|
121
121
|
</span>
|
|
122
122
|
</a>
|
|
@@ -143,12 +143,12 @@ portion.
|
|
|
143
143
|
|
|
144
144
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
145
145
|
|
|
146
|
-
<div id="method-
|
|
147
|
-
<a name="
|
|
146
|
+
<div id="method-M000022" class="method-detail">
|
|
147
|
+
<a name="M000022"></a>
|
|
148
148
|
|
|
149
149
|
<div class="method-heading">
|
|
150
|
-
<a href="URIClassifier.src/
|
|
151
|
-
onclick="popupCode('URIClassifier.src/
|
|
150
|
+
<a href="URIClassifier.src/M000022.html" target="Code" class="method-signature"
|
|
151
|
+
onclick="popupCode('URIClassifier.src/M000022.html');return false;">
|
|
152
152
|
<span class="method-name">uc.register("/someuri", SampleHandler.new) → nil<br />
|
|
153
153
|
</span>
|
|
154
154
|
</a>
|
|
@@ -173,15 +173,17 @@ to get right with a Hash.
|
|
|
173
173
|
</div>
|
|
174
174
|
</div>
|
|
175
175
|
|
|
176
|
-
<div id="method-
|
|
177
|
-
<a name="
|
|
176
|
+
<div id="method-M000024" class="method-detail">
|
|
177
|
+
<a name="M000024"></a>
|
|
178
178
|
|
|
179
179
|
<div class="method-heading">
|
|
180
|
-
<a href="URIClassifier.src/
|
|
181
|
-
onclick="popupCode('URIClassifier.src/
|
|
180
|
+
<a href="URIClassifier.src/M000024.html" target="Code" class="method-signature"
|
|
181
|
+
onclick="popupCode('URIClassifier.src/M000024.html');return false;">
|
|
182
182
|
<span class="method-name">uc.resolve("/someuri") → "/someuri", "", handler<br />
|
|
183
183
|
uc.resolve("/someuri/pathinfo") → "/someuri", "/pathinfo", handler<br />
|
|
184
184
|
uc.resolve("/notfound/orhere") → nil, nil, nil<br />
|
|
185
|
+
uc.resolve("/") → "/", "/", handler # if uc.register("/", handler)<br />
|
|
186
|
+
uc.resolve("/path/from/root") → "/", "/path/from/root", handler # if uc.register("/", handler) <br />
|
|
185
187
|
</span>
|
|
186
188
|
</a>
|
|
187
189
|
</div>
|
|
@@ -209,18 +211,26 @@ chars, anything really. It also means that it’s very efficient to do
|
|
|
209
211
|
this only taking as long as the URI has characters.
|
|
210
212
|
</p>
|
|
211
213
|
<p>
|
|
214
|
+
A slight modification to the CGI 1.2 standard is given for handlers
|
|
215
|
+
registered to "/". CGI expects all CGI scripts to be at some
|
|
216
|
+
script path, so it doesn’t really say anything about a script that
|
|
217
|
+
handles the root. To make this work, the resolver will detect that the
|
|
218
|
+
requested handler is at "/", and return that for script_name, and
|
|
219
|
+
then simply return the full URI back as path_info.
|
|
220
|
+
</p>
|
|
221
|
+
<p>
|
|
212
222
|
It expects strings with no embedded ’\0’ characters.
|
|
213
|
-
Don‘t try other string-
|
|
223
|
+
Don‘t try other string-like stuff yet.
|
|
214
224
|
</p>
|
|
215
225
|
</div>
|
|
216
226
|
</div>
|
|
217
227
|
|
|
218
|
-
<div id="method-
|
|
219
|
-
<a name="
|
|
228
|
+
<div id="method-M000023" class="method-detail">
|
|
229
|
+
<a name="M000023"></a>
|
|
220
230
|
|
|
221
231
|
<div class="method-heading">
|
|
222
|
-
<a href="URIClassifier.src/
|
|
223
|
-
onclick="popupCode('URIClassifier.src/
|
|
232
|
+
<a href="URIClassifier.src/M000023.html" target="Code" class="method-signature"
|
|
233
|
+
onclick="popupCode('URIClassifier.src/M000023.html');return false;">
|
|
224
234
|
<span class="method-name">uc.unregister("/someuri")<br />
|
|
225
235
|
</span>
|
|
226
236
|
</a>
|
|
@@ -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,64 +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
|
|
15
|
+
* uc.register("/someuri", SampleHandler.new) -> nil
|
|
18
16
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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".
|
|
23
22
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* a
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* This is very powerful since it means you can also attach handlers to parts of the ;
|
|
31
|
-
* (semi-colon) separated path params, any part of the path, use off chars, anything really.
|
|
32
|
-
* It also means that it's very efficient to do this only taking as long as the URI has
|
|
33
|
-
* characters.
|
|
34
|
-
*
|
|
35
|
-
* It expects strings with no embedded '\0' characters. Don't try other string-line 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.
|
|
36
28
|
*/
|
|
37
|
-
VALUE
|
|
29
|
+
VALUE URIClassifier_register(VALUE self, VALUE uri, VALUE handler)
|
|
38
30
|
{
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
int rc = 0;
|
|
32
|
+
void *ptr = NULL;
|
|
41
33
|
struct tst *tst = NULL;
|
|
42
|
-
VALUE result;
|
|
43
|
-
unsigned char *uri_str = NULL;
|
|
44
|
-
unsigned char *script_name_str = NULL;
|
|
45
|
-
|
|
46
34
|
DATA_GET(self, struct tst, tst);
|
|
47
|
-
uri_str = (unsigned char *)StringValueCStr(uri);
|
|
48
|
-
|
|
49
|
-
handler = tst_search(uri_str, tst, &pref_len);
|
|
50
35
|
|
|
51
|
-
|
|
52
|
-
result = rb_ary_new();
|
|
36
|
+
rc = tst_insert((unsigned char *)StringValueCStr(uri), (void *)handler , tst, 0, &ptr);
|
|
53
37
|
|
|
54
|
-
if(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
} else {
|
|
59
|
-
|
|
60
|
-
rb_ary_push(result, Qnil);
|
|
61
|
-
rb_ary_push(result, Qnil);
|
|
62
|
-
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");
|
|
63
44
|
}
|
|
45
|
+
|
|
46
|
+
rb_hash_aset(rb_ivar_get(self, id_handler_map), uri, handler);
|
|
64
47
|
|
|
65
|
-
return
|
|
48
|
+
return Qnil;
|
|
66
49
|
}</pre>
|
|
67
50
|
</body>
|
|
68
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,84 @@
|
|
|
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
|
+
unsigned char *script_name_str = NULL;
|
|
53
|
+
|
|
54
|
+
DATA_GET(self, struct tst, tst);
|
|
55
|
+
uri_str = (unsigned char *)StringValueCStr(uri);
|
|
56
|
+
|
|
57
|
+
handler = tst_search(uri_str, tst, &pref_len);
|
|
58
|
+
|
|
59
|
+
// setup for multiple return values
|
|
60
|
+
result = rb_ary_new();
|
|
61
|
+
|
|
62
|
+
if(handler) {
|
|
63
|
+
rb_ary_push(result, rb_str_substr (uri, 0, pref_len));
|
|
64
|
+
// compensate for a script_name="/" where we need to add the "/" to path_info to keep it consistent
|
|
65
|
+
if(pref_len == 1 && uri_str[0] == '/') {
|
|
66
|
+
// matches the root URI so we have to use the whole URI as the path_info
|
|
67
|
+
rb_ary_push(result, uri);
|
|
68
|
+
} else {
|
|
69
|
+
// matches a script so process like normal
|
|
70
|
+
rb_ary_push(result, rb_str_substr(uri, pref_len, RSTRING(uri)->len));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
rb_ary_push(result, (VALUE)handler);
|
|
74
|
+
} else {
|
|
75
|
+
// not found so push back nothing
|
|
76
|
+
rb_ary_push(result, Qnil);
|
|
77
|
+
rb_ary_push(result, Qnil);
|
|
78
|
+
rb_ary_push(result, Qnil);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return result;
|
|
82
|
+
}</pre>
|
|
83
|
+
</body>
|
|
84
|
+
</html>
|
data/doc/rdoc/created.rid
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Fri Feb
|
|
1
|
+
Fri Feb 10 02:50:17 EST 2006
|
data/doc/rdoc/files/README.html
CHANGED
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
</tr>
|
|
57
57
|
<tr class="top-aligned-row">
|
|
58
58
|
<td><strong>Last Update:</strong></td>
|
|
59
|
-
<td>Fri Feb
|
|
59
|
+
<td>Fri Feb 10 02:18:14 EST 2006</td>
|
|
60
60
|
</tr>
|
|
61
61
|
</table>
|
|
62
62
|
</div>
|
|
@@ -84,38 +84,41 @@ portability issues.
|
|
|
84
84
|
</p>
|
|
85
85
|
<h2>Status</h2>
|
|
86
86
|
<p>
|
|
87
|
-
The 0.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
href="../classes/Mongrel/HttpResponse.html">Mongrel::HttpResponse</a> class
|
|
92
|
-
to make it more feature complete. The remaining development will be spent
|
|
93
|
-
getting <a href="../classes/Mongrel.html">Mongrel</a> to work with other
|
|
94
|
-
frameworks, adding additional needed features, and improving the
|
|
95
|
-
concurrency and speed.
|
|
87
|
+
The 0.3 release is the first official release to start supporting Ruby on
|
|
88
|
+
Rails and to have a more complete DirHandler for serving directories of
|
|
89
|
+
files. This release is actually closer to a full functioning web server
|
|
90
|
+
than the previous releases.
|
|
96
91
|
</p>
|
|
97
92
|
<p>
|
|
98
|
-
The
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
which should work with <a href="../classes/Mongrel.html">Mongrel</a> if you
|
|
103
|
-
use the subversion source for Camping.
|
|
93
|
+
The Rails support is pretty rough right now, but check out the
|
|
94
|
+
bin/mongrel_rails file, which should be installed into your PATH if you use
|
|
95
|
+
a gem. You should be able to do the following to run your Rails
|
|
96
|
+
applications:
|
|
104
97
|
</p>
|
|
98
|
+
<pre>
|
|
99
|
+
> cd myrailsapp
|
|
100
|
+
> mongrel_rails 0.0.0.0 3000
|
|
101
|
+
</pre>
|
|
105
102
|
<p>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
href="http://rubyforge.org/projects/mongrel">rubyforge.org/projects/mongrel</a>/
|
|
110
|
-
thanks to Tom Copland. I’ll be looking to automate management of
|
|
111
|
-
this, but feel free to use rubyforge to post feature requests, bugs, and
|
|
112
|
-
join the mailing list.
|
|
103
|
+
And then hit <a href="http://localhost:3000">localhost:3000</a>/ to see
|
|
104
|
+
your app. One thing is that if you have a public/index.html file then
|
|
105
|
+
you’ll get that served instead of your Rails application.
|
|
113
106
|
</p>
|
|
114
107
|
<p>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
People with the daemons gem installed will see that mongrel_rails will go
|
|
109
|
+
into the background. You can kill it with:
|
|
110
|
+
</p>
|
|
111
|
+
<pre>
|
|
112
|
+
> kill -TERM `cat log/mongrel-3000.pid`
|
|
113
|
+
</pre>
|
|
114
|
+
<p>
|
|
115
|
+
Where "3000" is whatever port you told it to listen on when you
|
|
116
|
+
ran it.
|
|
117
|
+
</p>
|
|
118
|
+
<p>
|
|
119
|
+
The file serving is still a little rough and the redirects might not work
|
|
120
|
+
well, but try it out and tell me about any weird errors. File uploads will
|
|
121
|
+
definitely have some problems.
|
|
119
122
|
</p>
|
|
120
123
|
<h2>Install</h2>
|
|
121
124
|
<p>
|
|
@@ -203,12 +206,6 @@ applications in a heavily utilized production environment. Right now
|
|
|
203
206
|
I’m looking at:
|
|
204
207
|
</p>
|
|
205
208
|
<ul>
|
|
206
|
-
<li>Fast static file handling with directory listings.
|
|
207
|
-
|
|
208
|
-
</li>
|
|
209
|
-
<li>More testing on more platforms.
|
|
210
|
-
|
|
211
|
-
</li>
|
|
212
209
|
<li>An idea I’ve had for an insane caching handler which could speed up
|
|
213
210
|
quite a
|
|
214
211
|
|
|
@@ -217,14 +214,6 @@ quite a
|
|
|
217
214
|
<p>
|
|
218
215
|
few deployments.
|
|
219
216
|
</p>
|
|
220
|
-
<ul>
|
|
221
|
-
<li>General little things most web servers need.
|
|
222
|
-
|
|
223
|
-
</li>
|
|
224
|
-
<li>A nice management system or interface for controlling mongrel servers.
|
|
225
|
-
|
|
226
|
-
</li>
|
|
227
|
-
</ul>
|
|
228
217
|
<p>
|
|
229
218
|
Overall though the goal of <a href="../classes/Mongrel.html">Mongrel</a> is
|
|
230
219
|
to be just enough HTTP to serve a Ruby web application that sits behind a
|
|
@@ -238,7 +227,8 @@ hosting the major web frameworks for Ruby:
|
|
|
238
227
|
<li>Ruby on Rails — that’s where my bread is buttered right now.
|
|
239
228
|
|
|
240
229
|
</li>
|
|
241
|
-
<li>Nitro —
|
|
230
|
+
<li>Nitro — Nitro folks have already hooked this up and started using it.
|
|
231
|
+
Nice.
|
|
242
232
|
|
|
243
233
|
</li>
|
|
244
234
|
<li>????? — Others people might be interested in.
|