mongrel 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +2 -0
- data/CHANGELOG +2 -0
- data/Manifest +68 -0
- data/bin/mongrel_rails +55 -22
- data/examples/camping/README +3 -0
- data/examples/httpd.conf +474 -0
- data/examples/mime.yaml +3 -0
- data/examples/mongrel.conf +9 -0
- data/examples/monitrc +57 -0
- data/ext/http11/http11.c +25 -12
- data/ext/http11/http11_parser.c +456 -331
- data/ext/http11/http11_parser.h +1 -0
- data/ext/http11/http11_parser.java.rl +170 -0
- data/ext/http11/http11_parser.rl +8 -48
- data/ext/http11/http11_parser_common.rl +54 -0
- data/ext/http11/tst.h +2 -2
- data/ext/http11/tst_cleanup.c +0 -1
- data/ext/http11/tst_insert.c +29 -3
- data/ext/http11/tst_search.c +60 -55
- data/lib/mongrel.rb +68 -53
- data/lib/mongrel/cgi.rb +3 -3
- data/lib/mongrel/command.rb +1 -1
- data/lib/mongrel/configurator.rb +41 -31
- data/lib/mongrel/debug.rb +2 -5
- data/lib/mongrel/handlers.rb +23 -9
- data/lib/mongrel/mime_types.yml +2 -1
- data/lib/mongrel/rails.rb +7 -15
- data/mongrel-public_cert.pem +20 -0
- data/mongrel.gemspec +211 -0
- data/test/jruby_socket.rb +39 -0
- data/test/test_cgi_wrapper.rb +26 -0
- data/test/test_command.rb +1 -4
- data/test/test_conditional.rb +6 -18
- data/test/test_configurator.rb +5 -8
- data/test/test_debug.rb +3 -11
- data/test/test_handlers.rb +8 -10
- data/test/test_http11.rb +24 -5
- data/test/test_redirect_handler.rb +2 -6
- data/test/test_request_progress.rb +5 -9
- data/test/test_response.rb +24 -3
- data/test/test_stats.rb +1 -3
- data/test/test_uriclassifier.rb +170 -81
- data/test/test_ws.rb +25 -24
- data/test/testhelp.rb +26 -3
- data/tools/trickletest.rb +2 -2
- metadata +138 -333
- metadata.gz.sig +0 -0
- data/Rakefile +0 -117
- data/doc/rdoc/classes/IO.html +0 -170
- data/doc/rdoc/classes/IO.src/M000003.html +0 -19
- data/doc/rdoc/classes/IO.src/M000004.html +0 -19
- data/doc/rdoc/classes/Kernel.html +0 -159
- data/doc/rdoc/classes/Kernel.src/M000012.html +0 -19
- data/doc/rdoc/classes/Kernel.src/M000013.html +0 -23
- data/doc/rdoc/classes/Mongrel.html +0 -204
- data/doc/rdoc/classes/Mongrel/CGIWrapper.html +0 -404
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000115.html +0 -25
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000116.html +0 -47
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000117.html +0 -34
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000118.html +0 -32
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000119.html +0 -25
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000120.html +0 -18
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000121.html +0 -18
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000122.html +0 -18
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000123.html +0 -19
- data/doc/rdoc/classes/Mongrel/Camping.html +0 -177
- data/doc/rdoc/classes/Mongrel/Camping.src/M000041.html +0 -22
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.html +0 -184
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000042.html +0 -20
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000043.html +0 -58
- data/doc/rdoc/classes/Mongrel/Command.html +0 -132
- data/doc/rdoc/classes/Mongrel/Command/Base.html +0 -384
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000018.html +0 -24
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000019.html +0 -42
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000020.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000021.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000022.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000023.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000024.html +0 -22
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000025.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000026.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000027.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000028.html +0 -24
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000029.html +0 -24
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000030.html +0 -18
- data/doc/rdoc/classes/Mongrel/Command/Registry.html +0 -192
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000031.html +0 -20
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000032.html +0 -29
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000033.html +0 -58
- data/doc/rdoc/classes/Mongrel/Configurator.html +0 -716
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000093.html +0 -27
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000094.html +0 -31
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000095.html +0 -18
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000096.html +0 -21
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000097.html +0 -20
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000098.html +0 -23
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000099.html +0 -18
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000100.html +0 -38
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000101.html +0 -19
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000102.html +0 -39
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000103.html +0 -33
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000104.html +0 -18
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000105.html +0 -24
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000106.html +0 -19
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000107.html +0 -18
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000108.html +0 -22
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000109.html +0 -22
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000110.html +0 -18
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000111.html +0 -34
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000112.html +0 -18
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000113.html +0 -36
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000114.html +0 -18
- data/doc/rdoc/classes/Mongrel/Const.html +0 -337
- data/doc/rdoc/classes/Mongrel/DeflateFilter.html +0 -188
- data/doc/rdoc/classes/Mongrel/DeflateFilter.src/M000124.html +0 -19
- data/doc/rdoc/classes/Mongrel/DeflateFilter.src/M000125.html +0 -23
- data/doc/rdoc/classes/Mongrel/DirHandler.html +0 -303
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000051.html +0 -21
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000052.html +0 -42
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000053.html +0 -38
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000054.html +0 -65
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000055.html +0 -39
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000056.html +0 -18
- data/doc/rdoc/classes/Mongrel/Error404Handler.html +0 -171
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000126.html +0 -18
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000127.html +0 -18
- data/doc/rdoc/classes/Mongrel/HeaderOut.html +0 -190
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000066.html +0 -21
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000067.html +0 -21
- data/doc/rdoc/classes/Mongrel/HttpHandler.html +0 -215
- data/doc/rdoc/classes/Mongrel/HttpHandler.src/M000072.html +0 -17
- data/doc/rdoc/classes/Mongrel/HttpHandler.src/M000073.html +0 -17
- data/doc/rdoc/classes/Mongrel/HttpHandler.src/M000074.html +0 -17
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.html +0 -210
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000014.html +0 -17
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000015.html +0 -17
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000016.html +0 -19
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000017.html +0 -17
- data/doc/rdoc/classes/Mongrel/HttpParams.html +0 -131
- data/doc/rdoc/classes/Mongrel/HttpParser.html +0 -278
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000044.html +0 -28
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000045.html +0 -29
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000046.html +0 -29
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000047.html +0 -59
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000048.html +0 -27
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000049.html +0 -27
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000050.html +0 -28
- data/doc/rdoc/classes/Mongrel/HttpParserError.html +0 -111
- data/doc/rdoc/classes/Mongrel/HttpRequest.html +0 -284
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000133.html +0 -50
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000134.html +0 -41
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000135.html +0 -29
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000136.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000137.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000138.html +0 -32
- data/doc/rdoc/classes/Mongrel/HttpResponse.html +0 -443
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000075.html +0 -25
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000076.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000077.html +0 -26
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000078.html +0 -22
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000079.html +0 -22
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000080.html +0 -22
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000081.html +0 -31
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000082.html +0 -21
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000083.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000084.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000085.html +0 -20
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000086.html +0 -18
- data/doc/rdoc/classes/Mongrel/HttpServer.html +0 -402
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000057.html +0 -25
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000058.html +0 -100
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000059.html +0 -32
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000060.html +0 -21
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000061.html +0 -29
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000062.html +0 -65
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000063.html +0 -34
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000064.html +0 -18
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000065.html +0 -22
- data/doc/rdoc/classes/Mongrel/Rails.html +0 -112
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.html +0 -225
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000034.html +0 -37
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000035.html +0 -25
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000036.html +0 -26
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.html +0 -263
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000037.html +0 -23
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000038.html +0 -56
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000039.html +0 -20
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000040.html +0 -25
- data/doc/rdoc/classes/Mongrel/RedirectHandler.html +0 -187
- data/doc/rdoc/classes/Mongrel/RedirectHandler.src/M000131.html +0 -22
- data/doc/rdoc/classes/Mongrel/RedirectHandler.src/M000132.html +0 -27
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.html +0 -211
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/M000128.html +0 -24
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/M000129.html +0 -24
- data/doc/rdoc/classes/Mongrel/StatisticsFilter.src/M000130.html +0 -18
- data/doc/rdoc/classes/Mongrel/Stats.html +0 -309
- data/doc/rdoc/classes/Mongrel/Stats.src/M000139.html +0 -19
- data/doc/rdoc/classes/Mongrel/Stats.src/M000140.html +0 -23
- data/doc/rdoc/classes/Mongrel/Stats.src/M000141.html +0 -26
- data/doc/rdoc/classes/Mongrel/Stats.src/M000142.html +0 -18
- data/doc/rdoc/classes/Mongrel/Stats.src/M000143.html +0 -18
- data/doc/rdoc/classes/Mongrel/Stats.src/M000144.html +0 -18
- data/doc/rdoc/classes/Mongrel/Stats.src/M000145.html +0 -23
- data/doc/rdoc/classes/Mongrel/Stats.src/M000146.html +0 -20
- data/doc/rdoc/classes/Mongrel/StatusHandler.html +0 -194
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000068.html +0 -18
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000069.html +0 -24
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000070.html +0 -42
- data/doc/rdoc/classes/Mongrel/StatusHandler.src/M000071.html +0 -20
- data/doc/rdoc/classes/Mongrel/StopServer.html +0 -117
- data/doc/rdoc/classes/Mongrel/TimeoutError.html +0 -117
- data/doc/rdoc/classes/Mongrel/URIClassifier.html +0 -317
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000087.html +0 -18
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000088.html +0 -18
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000089.html +0 -39
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000090.html +0 -51
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000091.html +0 -36
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000092.html +0 -83
- data/doc/rdoc/classes/MongrelDbg.html +0 -209
- data/doc/rdoc/classes/MongrelDbg.src/M000007.html +0 -24
- data/doc/rdoc/classes/MongrelDbg.src/M000008.html +0 -20
- data/doc/rdoc/classes/MongrelDbg.src/M000009.html +0 -22
- data/doc/rdoc/classes/MongrelDbg.src/M000010.html +0 -21
- data/doc/rdoc/classes/MongrelDbg.src/M000011.html +0 -18
- data/doc/rdoc/classes/Mutex.html +0 -158
- data/doc/rdoc/classes/Mutex.src/M000001.html +0 -24
- data/doc/rdoc/classes/Mutex.src/M000002.html +0 -32
- data/doc/rdoc/classes/RequestLog.html +0 -115
- data/doc/rdoc/classes/RequestLog/Access.html +0 -151
- data/doc/rdoc/classes/RequestLog/Access.src/M000147.html +0 -19
- data/doc/rdoc/classes/RequestLog/Files.html +0 -144
- data/doc/rdoc/classes/RequestLog/Files.src/M000148.html +0 -19
- data/doc/rdoc/classes/RequestLog/Objects.html +0 -150
- data/doc/rdoc/classes/RequestLog/Objects.src/M000150.html +0 -51
- data/doc/rdoc/classes/RequestLog/Params.html +0 -144
- data/doc/rdoc/classes/RequestLog/Params.src/M000151.html +0 -19
- data/doc/rdoc/classes/RequestLog/Threads.html +0 -144
- data/doc/rdoc/classes/RequestLog/Threads.src/M000149.html +0 -34
- data/doc/rdoc/classes/TCPServer.html +0 -173
- data/doc/rdoc/classes/TCPServer.src/M000005.html +0 -19
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/COPYING.html +0 -168
- data/doc/rdoc/files/LICENSE.html +0 -168
- data/doc/rdoc/files/README.html +0 -213
- data/doc/rdoc/files/ext/http11/http11_c.html +0 -101
- data/doc/rdoc/files/lib/mongrel/camping_rb.html +0 -120
- data/doc/rdoc/files/lib/mongrel/cgi_rb.html +0 -120
- data/doc/rdoc/files/lib/mongrel/command_rb.html +0 -123
- data/doc/rdoc/files/lib/mongrel/configurator_rb.html +0 -111
- data/doc/rdoc/files/lib/mongrel/debug_rb.html +0 -122
- data/doc/rdoc/files/lib/mongrel/handlers_rb.html +0 -122
- data/doc/rdoc/files/lib/mongrel/init_rb.html +0 -121
- data/doc/rdoc/files/lib/mongrel/rails_rb.html +0 -123
- data/doc/rdoc/files/lib/mongrel/stats_rb.html +0 -113
- data/doc/rdoc/files/lib/mongrel/tcphack_rb.html +0 -113
- data/doc/rdoc/files/lib/mongrel_rb.html +0 -135
- data/doc/rdoc/files/lib/mutex_fix_rb.html +0 -108
- data/doc/rdoc/fr_class_index.html +0 -68
- data/doc/rdoc/fr_file_index.html +0 -42
- data/doc/rdoc/fr_method_index.html +0 -177
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
- data/tools/rakehelp.rb +0 -117
data/ext/http11/http11_parser.h
CHANGED
@@ -0,0 +1,170 @@
|
|
1
|
+
package org.jruby.mongrel;
|
2
|
+
|
3
|
+
import org.jruby.util.ByteList;
|
4
|
+
|
5
|
+
public class Http11Parser {
|
6
|
+
|
7
|
+
/** Machine **/
|
8
|
+
|
9
|
+
%%{
|
10
|
+
|
11
|
+
machine http_parser;
|
12
|
+
|
13
|
+
action mark {parser.mark = fpc; }
|
14
|
+
|
15
|
+
action start_field { parser.field_start = fpc; }
|
16
|
+
action write_field {
|
17
|
+
parser.field_len = fpc-parser.field_start;
|
18
|
+
}
|
19
|
+
|
20
|
+
action start_value { parser.mark = fpc; }
|
21
|
+
action write_value {
|
22
|
+
if(parser.http_field != null) {
|
23
|
+
parser.http_field.call(parser.data, parser.field_start, parser.field_len, parser.mark, fpc-parser.mark);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
action request_method {
|
27
|
+
if(parser.request_method != null)
|
28
|
+
parser.request_method.call(parser.data, parser.mark, fpc-parser.mark);
|
29
|
+
}
|
30
|
+
action request_uri {
|
31
|
+
if(parser.request_uri != null)
|
32
|
+
parser.request_uri.call(parser.data, parser.mark, fpc-parser.mark);
|
33
|
+
}
|
34
|
+
action fragment {
|
35
|
+
if(parser.fragment != null)
|
36
|
+
parser.fragment.call(parser.data, parser.mark, fpc-parser.mark);
|
37
|
+
}
|
38
|
+
|
39
|
+
action start_query {parser.query_start = fpc; }
|
40
|
+
action query_string {
|
41
|
+
if(parser.query_string != null)
|
42
|
+
parser.query_string.call(parser.data, parser.query_start, fpc-parser.query_start);
|
43
|
+
}
|
44
|
+
|
45
|
+
action http_version {
|
46
|
+
if(parser.http_version != null)
|
47
|
+
parser.http_version.call(parser.data, parser.mark, fpc-parser.mark);
|
48
|
+
}
|
49
|
+
|
50
|
+
action request_path {
|
51
|
+
if(parser.request_path != null)
|
52
|
+
parser.request_path.call(parser.data, parser.mark, fpc-parser.mark);
|
53
|
+
}
|
54
|
+
|
55
|
+
action done {
|
56
|
+
parser.body_start = fpc + 1;
|
57
|
+
if(parser.header_done != null)
|
58
|
+
parser.header_done.call(parser.data, fpc + 1, pe - fpc - 1);
|
59
|
+
fbreak;
|
60
|
+
}
|
61
|
+
|
62
|
+
include http_parser_common "http11_parser_common.rl";
|
63
|
+
|
64
|
+
}%%
|
65
|
+
|
66
|
+
/** Data **/
|
67
|
+
%% write data;
|
68
|
+
|
69
|
+
public static interface ElementCB {
|
70
|
+
public void call(Object data, int at, int length);
|
71
|
+
}
|
72
|
+
|
73
|
+
public static interface FieldCB {
|
74
|
+
public void call(Object data, int field, int flen, int value, int vlen);
|
75
|
+
}
|
76
|
+
|
77
|
+
public static class HttpParser {
|
78
|
+
int cs;
|
79
|
+
int body_start;
|
80
|
+
int content_len;
|
81
|
+
int nread;
|
82
|
+
int mark;
|
83
|
+
int field_start;
|
84
|
+
int field_len;
|
85
|
+
int query_start;
|
86
|
+
|
87
|
+
Object data;
|
88
|
+
ByteList buffer;
|
89
|
+
|
90
|
+
public FieldCB http_field;
|
91
|
+
public ElementCB request_method;
|
92
|
+
public ElementCB request_uri;
|
93
|
+
public ElementCB fragment;
|
94
|
+
public ElementCB request_path;
|
95
|
+
public ElementCB query_string;
|
96
|
+
public ElementCB http_version;
|
97
|
+
public ElementCB header_done;
|
98
|
+
|
99
|
+
public void init() {
|
100
|
+
cs = 0;
|
101
|
+
|
102
|
+
%% write init;
|
103
|
+
|
104
|
+
body_start = 0;
|
105
|
+
content_len = 0;
|
106
|
+
mark = 0;
|
107
|
+
nread = 0;
|
108
|
+
field_len = 0;
|
109
|
+
field_start = 0;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
public final HttpParser parser = new HttpParser();
|
114
|
+
|
115
|
+
public int execute(ByteList buffer, int off) {
|
116
|
+
int p, pe;
|
117
|
+
int cs = parser.cs;
|
118
|
+
int len = buffer.realSize;
|
119
|
+
assert off<=len : "offset past end of buffer";
|
120
|
+
|
121
|
+
p = off;
|
122
|
+
pe = len;
|
123
|
+
byte[] data = buffer.bytes;
|
124
|
+
parser.buffer = buffer;
|
125
|
+
|
126
|
+
%% write exec;
|
127
|
+
|
128
|
+
parser.cs = cs;
|
129
|
+
parser.nread += (p - off);
|
130
|
+
|
131
|
+
assert p <= pe : "buffer overflow after parsing execute";
|
132
|
+
assert parser.nread <= len : "nread longer than length";
|
133
|
+
assert parser.body_start <= len : "body starts after buffer end";
|
134
|
+
assert parser.mark < len : "mark is after buffer end";
|
135
|
+
assert parser.field_len <= len : "field has length longer than whole buffer";
|
136
|
+
assert parser.field_start < len : "field starts after buffer end";
|
137
|
+
|
138
|
+
if(parser.body_start>0) {
|
139
|
+
/* final \r\n combo encountered so stop right here */
|
140
|
+
%%write eof;
|
141
|
+
parser.nread++;
|
142
|
+
}
|
143
|
+
|
144
|
+
return parser.nread;
|
145
|
+
}
|
146
|
+
|
147
|
+
public int finish() {
|
148
|
+
int cs = parser.cs;
|
149
|
+
|
150
|
+
%%write eof;
|
151
|
+
|
152
|
+
parser.cs = cs;
|
153
|
+
|
154
|
+
if(has_error()) {
|
155
|
+
return -1;
|
156
|
+
} else if(is_finished()) {
|
157
|
+
return 1;
|
158
|
+
} else {
|
159
|
+
return 0;
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
public boolean has_error() {
|
164
|
+
return parser.cs == http_parser_error;
|
165
|
+
}
|
166
|
+
|
167
|
+
public boolean is_finished() {
|
168
|
+
return parser.cs == http_parser_first_final;
|
169
|
+
}
|
170
|
+
}
|
data/ext/http11/http11_parser.rl
CHANGED
@@ -13,8 +13,10 @@
|
|
13
13
|
#define MARK(M,FPC) (parser->M = (FPC) - buffer)
|
14
14
|
#define PTR_TO(F) (buffer + parser->F)
|
15
15
|
|
16
|
-
/**
|
16
|
+
/** Machine **/
|
17
|
+
|
17
18
|
%%{
|
19
|
+
|
18
20
|
machine http_parser;
|
19
21
|
|
20
22
|
action mark {MARK(mark, fpc); }
|
@@ -39,6 +41,10 @@
|
|
39
41
|
if(parser->request_uri != NULL)
|
40
42
|
parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, fpc));
|
41
43
|
}
|
44
|
+
action fragment {
|
45
|
+
if(parser->fragment != NULL)
|
46
|
+
parser->fragment(parser->data, PTR_TO(mark), LEN(mark, fpc));
|
47
|
+
}
|
42
48
|
|
43
49
|
action start_query {MARK(query_start, fpc); }
|
44
50
|
action query_string {
|
@@ -63,54 +69,8 @@
|
|
63
69
|
fbreak;
|
64
70
|
}
|
65
71
|
|
72
|
+
include http_parser_common "http11_parser_common.rl";
|
66
73
|
|
67
|
-
#### HTTP PROTOCOL GRAMMAR
|
68
|
-
# line endings
|
69
|
-
CRLF = "\r\n";
|
70
|
-
|
71
|
-
# character types
|
72
|
-
CTL = (cntrl | 127);
|
73
|
-
safe = ("$" | "-" | "_" | ".");
|
74
|
-
extra = ("!" | "*" | "'" | "(" | ")" | ",");
|
75
|
-
reserved = (";" | "/" | "?" | ":" | "@" | "&" | "=" | "+");
|
76
|
-
unsafe = (CTL | " " | "\"" | "#" | "%" | "<" | ">");
|
77
|
-
national = any -- (alpha | digit | reserved | extra | safe | unsafe);
|
78
|
-
unreserved = (alpha | digit | safe | extra | national);
|
79
|
-
escape = ("%" xdigit xdigit);
|
80
|
-
uchar = (unreserved | escape);
|
81
|
-
pchar = (uchar | ":" | "@" | "&" | "=" | "+");
|
82
|
-
tspecials = ("(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\\" | "\"" | "/" | "[" | "]" | "?" | "=" | "{" | "}" | " " | "\t");
|
83
|
-
|
84
|
-
# elements
|
85
|
-
token = (ascii -- (CTL | tspecials));
|
86
|
-
|
87
|
-
# URI schemes and absolute paths
|
88
|
-
scheme = ( alpha | digit | "+" | "-" | "." )* ;
|
89
|
-
absolute_uri = (scheme ":" (uchar | reserved )*);
|
90
|
-
|
91
|
-
path = (pchar+ ( "/" pchar* )*) ;
|
92
|
-
query = ( uchar | reserved )* %query_string ;
|
93
|
-
param = ( pchar | "/" )* ;
|
94
|
-
params = (param ( ";" param )*) ;
|
95
|
-
rel_path = (path? %request_path (";" params)?) ("?" %start_query query)?;
|
96
|
-
absolute_path = ("/"+ rel_path);
|
97
|
-
|
98
|
-
Request_URI = ("*" | absolute_uri | absolute_path) >mark %request_uri;
|
99
|
-
Method = (upper | digit | safe){1,20} >mark %request_method;
|
100
|
-
|
101
|
-
http_number = (digit+ "." digit+) ;
|
102
|
-
HTTP_Version = ("HTTP/" http_number) >mark %http_version ;
|
103
|
-
Request_Line = (Method " " Request_URI " " HTTP_Version CRLF) ;
|
104
|
-
|
105
|
-
field_name = (token -- ":")+ >start_field %write_field;
|
106
|
-
|
107
|
-
field_value = any* >start_value %write_value;
|
108
|
-
|
109
|
-
message_header = field_name ":" " "* field_value :> CRLF;
|
110
|
-
|
111
|
-
Request = Request_Line (message_header)* ( CRLF @done);
|
112
|
-
|
113
|
-
main := Request;
|
114
74
|
}%%
|
115
75
|
|
116
76
|
/** Data **/
|
@@ -0,0 +1,54 @@
|
|
1
|
+
%%{
|
2
|
+
|
3
|
+
machine http_parser_common;
|
4
|
+
|
5
|
+
#### HTTP PROTOCOL GRAMMAR
|
6
|
+
# line endings
|
7
|
+
CRLF = "\r\n";
|
8
|
+
|
9
|
+
# character types
|
10
|
+
CTL = (cntrl | 127);
|
11
|
+
safe = ("$" | "-" | "_" | ".");
|
12
|
+
extra = ("!" | "*" | "'" | "(" | ")" | ",");
|
13
|
+
reserved = (";" | "/" | "?" | ":" | "@" | "&" | "=" | "+");
|
14
|
+
unsafe = (CTL | " " | "\"" | "#" | "%" | "<" | ">");
|
15
|
+
national = any -- (alpha | digit | reserved | extra | safe | unsafe);
|
16
|
+
unreserved = (alpha | digit | safe | extra | national);
|
17
|
+
escape = ("%" xdigit xdigit);
|
18
|
+
uchar = (unreserved | escape);
|
19
|
+
pchar = (uchar | ":" | "@" | "&" | "=" | "+");
|
20
|
+
tspecials = ("(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\\" | "\"" | "/" | "[" | "]" | "?" | "=" | "{" | "}" | " " | "\t");
|
21
|
+
|
22
|
+
# elements
|
23
|
+
token = (ascii -- (CTL | tspecials));
|
24
|
+
|
25
|
+
# URI schemes and absolute paths
|
26
|
+
scheme = ( alpha | digit | "+" | "-" | "." )* ;
|
27
|
+
absolute_uri = (scheme ":" (uchar | reserved )*);
|
28
|
+
|
29
|
+
path = ( pchar+ ( "/" pchar* )* ) ;
|
30
|
+
query = ( uchar | reserved )* %query_string ;
|
31
|
+
param = ( pchar | "/" )* ;
|
32
|
+
params = ( param ( ";" param )* ) ;
|
33
|
+
rel_path = ( path? %request_path (";" params)? ) ("?" %start_query query)?;
|
34
|
+
absolute_path = ( "/"+ rel_path );
|
35
|
+
|
36
|
+
Request_URI = ( "*" | absolute_uri | absolute_path ) >mark %request_uri;
|
37
|
+
Fragment = ( uchar | reserved )* >mark %fragment;
|
38
|
+
Method = ( upper | digit | safe ){1,20} >mark %request_method;
|
39
|
+
|
40
|
+
http_number = ( digit+ "." digit+ ) ;
|
41
|
+
HTTP_Version = ( "HTTP/" http_number ) >mark %http_version ;
|
42
|
+
Request_Line = ( Method " " Request_URI ("#" Fragment){0,1} " " HTTP_Version CRLF ) ;
|
43
|
+
|
44
|
+
field_name = ( token -- ":" )+ >start_field %write_field;
|
45
|
+
|
46
|
+
field_value = any* >start_value %write_value;
|
47
|
+
|
48
|
+
message_header = field_name ":" " "* field_value :> CRLF;
|
49
|
+
|
50
|
+
Request = Request_Line ( message_header )* ( CRLF @done );
|
51
|
+
|
52
|
+
main := Request;
|
53
|
+
|
54
|
+
}%%
|
data/ext/http11/tst.h
CHANGED
@@ -24,14 +24,14 @@ struct node_lines
|
|
24
24
|
|
25
25
|
enum tst_constants
|
26
26
|
{
|
27
|
-
TST_OK, TST_ERROR, TST_NULL_KEY, TST_DUPLICATE_KEY, TST_REPLACE
|
27
|
+
TST_OK, TST_ERROR, TST_NULL_KEY, TST_DUPLICATE_KEY, TST_REPLACE, TST_LONGEST_MATCH
|
28
28
|
};
|
29
29
|
|
30
30
|
struct tst *tst_init(int node_line_width);
|
31
31
|
|
32
32
|
int tst_insert(unsigned char *key, void *data, struct tst *tst, int option, void **exist_ptr);
|
33
33
|
|
34
|
-
void *tst_search(unsigned char *key, struct tst *tst, int *
|
34
|
+
void *tst_search(const unsigned char *key, struct tst *tst, int option, unsigned int *match_len);
|
35
35
|
|
36
36
|
void *tst_delete(unsigned char *key, struct tst *tst);
|
37
37
|
|
data/ext/http11/tst_cleanup.c
CHANGED
data/ext/http11/tst_insert.c
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
#include "tst.h"
|
3
3
|
#include <stdio.h>
|
4
4
|
#include <stdlib.h>
|
5
|
-
|
5
|
+
#include <string.h>
|
6
6
|
|
7
7
|
int tst_grow_node_free_list(struct tst *tst);
|
8
8
|
int tst_insert(unsigned char *key, void *data, struct tst *tst, int option, void **exist_ptr)
|
9
9
|
{
|
10
10
|
struct node *current_node;
|
11
11
|
struct node *new_node_tree_begin = NULL;
|
12
|
+
struct node *new_node;
|
12
13
|
int key_index;
|
13
14
|
int perform_loop = 1;
|
14
|
-
|
15
15
|
|
16
16
|
if (key == NULL)
|
17
17
|
return TST_NULL_KEY;
|
@@ -91,7 +91,33 @@ int tst_insert(unsigned char *key, void *data, struct tst *tst, int option, void
|
|
91
91
|
}
|
92
92
|
}
|
93
93
|
}
|
94
|
-
|
94
|
+
if(key[key_index] == 0)
|
95
|
+
{
|
96
|
+
if(tst->free_list == NULL)
|
97
|
+
{
|
98
|
+
if(tst_grow_node_free_list(tst) != 1)
|
99
|
+
return TST_ERROR;
|
100
|
+
}
|
101
|
+
new_node = tst->free_list;
|
102
|
+
tst->free_list = tst->free_list->middle;
|
103
|
+
|
104
|
+
memcpy((void*)new_node, (void*)current_node, sizeof(struct node));
|
105
|
+
current_node->value = 0;
|
106
|
+
if(new_node->value < 64)
|
107
|
+
{
|
108
|
+
current_node->left = new_node;
|
109
|
+
current_node->right = '\0';
|
110
|
+
}
|
111
|
+
else
|
112
|
+
{
|
113
|
+
current_node->left = '\0';
|
114
|
+
current_node->right = new_node;
|
115
|
+
}
|
116
|
+
|
117
|
+
current_node->middle = data;
|
118
|
+
return TST_OK;
|
119
|
+
}
|
120
|
+
|
95
121
|
if( ((current_node->value == 0) && (key[key_index] < 64)) ||
|
96
122
|
((current_node->value != 0) && (key[key_index] <
|
97
123
|
current_node->value)) )
|
data/ext/http11/tst_search.c
CHANGED
@@ -4,65 +4,70 @@
|
|
4
4
|
#include <stdlib.h>
|
5
5
|
#include <assert.h>
|
6
6
|
|
7
|
-
|
7
|
+
|
8
|
+
void *tst_search(const unsigned char *key, struct tst *tst, int option,
|
9
|
+
unsigned int *match_len)
|
8
10
|
{
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
struct node *current_node;
|
12
|
+
struct node *longest_match = NULL;
|
13
|
+
unsigned int longest_match_len = 0;
|
14
|
+
int key_index;
|
15
|
+
|
16
|
+
assert(key != NULL && "key can't be NULL");
|
17
|
+
assert(tst != NULL && "tst can't be NULL");
|
18
|
+
|
19
|
+
if (key[0] == 0)
|
20
|
+
return NULL;
|
21
|
+
|
22
|
+
if (tst->head[(int) key[0]] == NULL)
|
23
|
+
return NULL;
|
24
|
+
|
25
|
+
if (match_len)
|
26
|
+
*match_len = 0;
|
27
|
+
|
28
|
+
current_node = tst->head[(int) key[0]];
|
29
|
+
key_index = 1;
|
21
30
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
if(prefix_len) *prefix_len = key_index;
|
33
|
-
return current_node->middle;
|
34
|
-
} else {
|
35
|
-
current_node = current_node->middle;
|
36
|
-
if(current_node && current_node->value == 0) {
|
37
|
-
if(prefix_len) *prefix_len = key_index+1;
|
38
|
-
longest_match = current_node->middle;
|
31
|
+
while (current_node != NULL) {
|
32
|
+
if (key[key_index] == current_node->value) {
|
33
|
+
if (current_node->value == 0) {
|
34
|
+
if (match_len)
|
35
|
+
*match_len = key_index;
|
36
|
+
return current_node->middle;
|
37
|
+
} else {
|
38
|
+
current_node = current_node->middle;
|
39
|
+
key_index++;
|
40
|
+
continue;
|
39
41
|
}
|
42
|
+
} else {
|
43
|
+
if (current_node->value == 0) {
|
44
|
+
if (option & TST_LONGEST_MATCH) {
|
45
|
+
longest_match = current_node->middle;
|
46
|
+
longest_match_len = key_index;
|
47
|
+
}
|
40
48
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
{
|
58
|
-
if(current_node->value == 0) {
|
59
|
-
if(prefix_len) *prefix_len = key_index;
|
60
|
-
longest_match = current_node->middle;
|
61
|
-
}
|
62
|
-
current_node = current_node->right;
|
63
|
-
continue;
|
49
|
+
if (key[key_index] < 64) {
|
50
|
+
current_node = current_node->left;
|
51
|
+
continue;
|
52
|
+
} else {
|
53
|
+
current_node = current_node->right;
|
54
|
+
continue;
|
55
|
+
}
|
56
|
+
} else {
|
57
|
+
if (key[key_index] < current_node->value) {
|
58
|
+
current_node = current_node->left;
|
59
|
+
continue;
|
60
|
+
} else {
|
61
|
+
current_node = current_node->right;
|
62
|
+
continue;
|
63
|
+
}
|
64
|
+
}
|
64
65
|
}
|
65
66
|
}
|
66
|
-
|
67
|
-
|
67
|
+
|
68
|
+
if (match_len)
|
69
|
+
*match_len = longest_match_len;
|
70
|
+
|
71
|
+
return longest_match;
|
72
|
+
|
68
73
|
}
|