waitress-core 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/LICENSE +21 -21
- data/Rakefile +13 -13
- data/bin/waitress +22 -22
- data/ext/Thanks.md +1 -1
- data/ext/waitress_http11/ext_help.h +15 -15
- data/ext/waitress_http11/extconf.rb +6 -6
- data/ext/waitress_http11/http11.c +532 -532
- data/ext/waitress_http11/http11_parser.c +1216 -1216
- data/ext/waitress_http11/http11_parser.h +49 -49
- data/ext/waitress_http11/http11_parser.java.rl +171 -171
- data/ext/waitress_http11/http11_parser.rl +165 -165
- data/ext/waitress_http11/http11_parser_common.rl +55 -55
- data/ext/waitress_http11/http11_wrb_parser.h +91 -91
- data/lib/waitress/chef.rb +113 -113
- data/lib/waitress/configure.rb +121 -121
- data/lib/waitress/evalbind.rb +9 -9
- data/lib/waitress/handlers/dirhandler.rb +39 -39
- data/lib/waitress/handlers/handler.rb +57 -57
- data/lib/waitress/handlers/handler404.rb +25 -25
- data/lib/waitress/handlers/libhandler.rb +58 -58
- data/lib/waitress/kernel.rb +182 -182
- data/lib/waitress/parse/query.rb +60 -60
- data/lib/waitress/request.rb +45 -45
- data/lib/waitress/resources/default_config.rb +52 -52
- data/lib/waitress/resources/http/404.html +18 -18
- data/lib/waitress/resources/http/css/hack.css +37 -37
- data/lib/waitress/resources/http/css/waitress.css +57 -57
- data/lib/waitress/resources/http/fonts/svg/latin/hack-bold-latin-webfont.svg +240 -240
- data/lib/waitress/resources/http/fonts/svg/latin/hack-bolditalic-latin-webfont.svg +240 -240
- data/lib/waitress/resources/http/fonts/svg/latin/hack-italic-latin-webfont.svg +240 -240
- data/lib/waitress/resources/http/fonts/svg/latin/hack-regular-latin-webfont.svg +240 -240
- data/lib/waitress/resources/http/index.html +15 -15
- data/lib/waitress/response.rb +105 -105
- data/lib/waitress/server.rb +161 -158
- data/lib/waitress/util.rb +707 -707
- data/lib/waitress/version.rb +3 -3
- data/lib/waitress/vhost.rb +217 -217
- data/lib/waitress.rb +106 -106
- data/lib/waitress_http11.so +0 -0
- data/waitress-core.gemspec +29 -29
- metadata +3 -3
- data/lib/waitress_http11.bundle +0 -0
@@ -1,49 +1,49 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2005 Zed A. Shaw
|
3
|
-
* You can redistribute it and/or modify it under the same terms as Ruby.
|
4
|
-
*/
|
5
|
-
|
6
|
-
#ifndef http11_parser_h
|
7
|
-
#define http11_parser_h
|
8
|
-
|
9
|
-
#include <sys/types.h>
|
10
|
-
|
11
|
-
#if defined(_WIN32)
|
12
|
-
#include <stddef.h>
|
13
|
-
#endif
|
14
|
-
|
15
|
-
typedef void (*element_cb)(void *data, const char *at, size_t length);
|
16
|
-
typedef void (*field_cb)(void *data, const char *field, size_t flen, const char *value, size_t vlen);
|
17
|
-
|
18
|
-
typedef struct http_parser {
|
19
|
-
int cs;
|
20
|
-
size_t body_start;
|
21
|
-
int content_len;
|
22
|
-
size_t nread;
|
23
|
-
size_t mark;
|
24
|
-
size_t field_start;
|
25
|
-
size_t field_len;
|
26
|
-
size_t query_start;
|
27
|
-
|
28
|
-
void *data;
|
29
|
-
|
30
|
-
field_cb http_field;
|
31
|
-
element_cb request_method;
|
32
|
-
element_cb request_uri;
|
33
|
-
element_cb fragment;
|
34
|
-
element_cb request_path;
|
35
|
-
element_cb query_string;
|
36
|
-
element_cb http_version;
|
37
|
-
element_cb header_done;
|
38
|
-
|
39
|
-
} http_parser;
|
40
|
-
|
41
|
-
int http_parser_init(http_parser *parser);
|
42
|
-
int http_parser_finish(http_parser *parser);
|
43
|
-
size_t http_parser_execute(http_parser *parser, const char *data, size_t len, size_t off);
|
44
|
-
int http_parser_has_error(http_parser *parser);
|
45
|
-
int http_parser_is_finished(http_parser *parser);
|
46
|
-
|
47
|
-
#define http_parser_nread(parser) (parser)->nread
|
48
|
-
|
49
|
-
#endif
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2005 Zed A. Shaw
|
3
|
+
* You can redistribute it and/or modify it under the same terms as Ruby.
|
4
|
+
*/
|
5
|
+
|
6
|
+
#ifndef http11_parser_h
|
7
|
+
#define http11_parser_h
|
8
|
+
|
9
|
+
#include <sys/types.h>
|
10
|
+
|
11
|
+
#if defined(_WIN32)
|
12
|
+
#include <stddef.h>
|
13
|
+
#endif
|
14
|
+
|
15
|
+
typedef void (*element_cb)(void *data, const char *at, size_t length);
|
16
|
+
typedef void (*field_cb)(void *data, const char *field, size_t flen, const char *value, size_t vlen);
|
17
|
+
|
18
|
+
typedef struct http_parser {
|
19
|
+
int cs;
|
20
|
+
size_t body_start;
|
21
|
+
int content_len;
|
22
|
+
size_t nread;
|
23
|
+
size_t mark;
|
24
|
+
size_t field_start;
|
25
|
+
size_t field_len;
|
26
|
+
size_t query_start;
|
27
|
+
|
28
|
+
void *data;
|
29
|
+
|
30
|
+
field_cb http_field;
|
31
|
+
element_cb request_method;
|
32
|
+
element_cb request_uri;
|
33
|
+
element_cb fragment;
|
34
|
+
element_cb request_path;
|
35
|
+
element_cb query_string;
|
36
|
+
element_cb http_version;
|
37
|
+
element_cb header_done;
|
38
|
+
|
39
|
+
} http_parser;
|
40
|
+
|
41
|
+
int http_parser_init(http_parser *parser);
|
42
|
+
int http_parser_finish(http_parser *parser);
|
43
|
+
size_t http_parser_execute(http_parser *parser, const char *data, size_t len, size_t off);
|
44
|
+
int http_parser_has_error(http_parser *parser);
|
45
|
+
int http_parser_is_finished(http_parser *parser);
|
46
|
+
|
47
|
+
#define http_parser_nread(parser) (parser)->nread
|
48
|
+
|
49
|
+
#endif
|
@@ -1,171 +1,171 @@
|
|
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 snake_upcase_field { /* FIXME stub */ }
|
17
|
-
action write_field {
|
18
|
-
parser.field_len = fpc-parser.field_start;
|
19
|
-
}
|
20
|
-
|
21
|
-
action start_value { parser.mark = fpc; }
|
22
|
-
action write_value {
|
23
|
-
if(parser.http_field != null) {
|
24
|
-
parser.http_field.call(parser.data, parser.field_start, parser.field_len, parser.mark, fpc-parser.mark);
|
25
|
-
}
|
26
|
-
}
|
27
|
-
action request_method {
|
28
|
-
if(parser.request_method != null)
|
29
|
-
parser.request_method.call(parser.data, parser.mark, fpc-parser.mark);
|
30
|
-
}
|
31
|
-
action request_uri {
|
32
|
-
if(parser.request_uri != null)
|
33
|
-
parser.request_uri.call(parser.data, parser.mark, fpc-parser.mark);
|
34
|
-
}
|
35
|
-
action fragment {
|
36
|
-
if(parser.fragment != null)
|
37
|
-
parser.fragment.call(parser.data, parser.mark, fpc-parser.mark);
|
38
|
-
}
|
39
|
-
|
40
|
-
action start_query {parser.query_start = fpc; }
|
41
|
-
action query_string {
|
42
|
-
if(parser.query_string != null)
|
43
|
-
parser.query_string.call(parser.data, parser.query_start, fpc-parser.query_start);
|
44
|
-
}
|
45
|
-
|
46
|
-
action http_version {
|
47
|
-
if(parser.http_version != null)
|
48
|
-
parser.http_version.call(parser.data, parser.mark, fpc-parser.mark);
|
49
|
-
}
|
50
|
-
|
51
|
-
action request_path {
|
52
|
-
if(parser.request_path != null)
|
53
|
-
parser.request_path.call(parser.data, parser.mark, fpc-parser.mark);
|
54
|
-
}
|
55
|
-
|
56
|
-
action done {
|
57
|
-
parser.body_start = fpc + 1;
|
58
|
-
if(parser.header_done != null)
|
59
|
-
parser.header_done.call(parser.data, fpc + 1, pe - fpc - 1);
|
60
|
-
fbreak;
|
61
|
-
}
|
62
|
-
|
63
|
-
include http_parser_common "http11_parser_common.rl";
|
64
|
-
|
65
|
-
}%%
|
66
|
-
|
67
|
-
/** Data **/
|
68
|
-
%% write data;
|
69
|
-
|
70
|
-
public static interface ElementCB {
|
71
|
-
public void call(Object data, int at, int length);
|
72
|
-
}
|
73
|
-
|
74
|
-
public static interface FieldCB {
|
75
|
-
public void call(Object data, int field, int flen, int value, int vlen);
|
76
|
-
}
|
77
|
-
|
78
|
-
public static class HttpParser {
|
79
|
-
int cs;
|
80
|
-
int body_start;
|
81
|
-
int content_len;
|
82
|
-
int nread;
|
83
|
-
int mark;
|
84
|
-
int field_start;
|
85
|
-
int field_len;
|
86
|
-
int query_start;
|
87
|
-
|
88
|
-
Object data;
|
89
|
-
ByteList buffer;
|
90
|
-
|
91
|
-
public FieldCB http_field;
|
92
|
-
public ElementCB request_method;
|
93
|
-
public ElementCB request_uri;
|
94
|
-
public ElementCB fragment;
|
95
|
-
public ElementCB request_path;
|
96
|
-
public ElementCB query_string;
|
97
|
-
public ElementCB http_version;
|
98
|
-
public ElementCB header_done;
|
99
|
-
|
100
|
-
public void init() {
|
101
|
-
cs = 0;
|
102
|
-
|
103
|
-
%% write init;
|
104
|
-
|
105
|
-
body_start = 0;
|
106
|
-
content_len = 0;
|
107
|
-
mark = 0;
|
108
|
-
nread = 0;
|
109
|
-
field_len = 0;
|
110
|
-
field_start = 0;
|
111
|
-
}
|
112
|
-
}
|
113
|
-
|
114
|
-
public final HttpParser parser = new HttpParser();
|
115
|
-
|
116
|
-
public int execute(ByteList buffer, int off) {
|
117
|
-
int p, pe;
|
118
|
-
int cs = parser.cs;
|
119
|
-
int len = buffer.realSize;
|
120
|
-
assert off<=len : "offset past end of buffer";
|
121
|
-
|
122
|
-
p = off;
|
123
|
-
pe = len;
|
124
|
-
byte[] data = buffer.bytes;
|
125
|
-
parser.buffer = buffer;
|
126
|
-
|
127
|
-
%% write exec;
|
128
|
-
|
129
|
-
parser.cs = cs;
|
130
|
-
parser.nread += (p - off);
|
131
|
-
|
132
|
-
assert p <= pe : "buffer overflow after parsing execute";
|
133
|
-
assert parser.nread <= len : "nread longer than length";
|
134
|
-
assert parser.body_start <= len : "body starts after buffer end";
|
135
|
-
assert parser.mark < len : "mark is after buffer end";
|
136
|
-
assert parser.field_len <= len : "field has length longer than whole buffer";
|
137
|
-
assert parser.field_start < len : "field starts after buffer end";
|
138
|
-
|
139
|
-
if(parser.body_start>0) {
|
140
|
-
/* final \r\n combo encountered so stop right here */
|
141
|
-
%%write eof;
|
142
|
-
parser.nread++;
|
143
|
-
}
|
144
|
-
|
145
|
-
return parser.nread;
|
146
|
-
}
|
147
|
-
|
148
|
-
public int finish() {
|
149
|
-
int cs = parser.cs;
|
150
|
-
|
151
|
-
%%write eof;
|
152
|
-
|
153
|
-
parser.cs = cs;
|
154
|
-
|
155
|
-
if(has_error()) {
|
156
|
-
return -1;
|
157
|
-
} else if(is_finished()) {
|
158
|
-
return 1;
|
159
|
-
} else {
|
160
|
-
return 0;
|
161
|
-
}
|
162
|
-
}
|
163
|
-
|
164
|
-
public boolean has_error() {
|
165
|
-
return parser.cs == http_parser_error;
|
166
|
-
}
|
167
|
-
|
168
|
-
public boolean is_finished() {
|
169
|
-
return parser.cs == http_parser_first_final;
|
170
|
-
}
|
171
|
-
}
|
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 snake_upcase_field { /* FIXME stub */ }
|
17
|
+
action write_field {
|
18
|
+
parser.field_len = fpc-parser.field_start;
|
19
|
+
}
|
20
|
+
|
21
|
+
action start_value { parser.mark = fpc; }
|
22
|
+
action write_value {
|
23
|
+
if(parser.http_field != null) {
|
24
|
+
parser.http_field.call(parser.data, parser.field_start, parser.field_len, parser.mark, fpc-parser.mark);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
action request_method {
|
28
|
+
if(parser.request_method != null)
|
29
|
+
parser.request_method.call(parser.data, parser.mark, fpc-parser.mark);
|
30
|
+
}
|
31
|
+
action request_uri {
|
32
|
+
if(parser.request_uri != null)
|
33
|
+
parser.request_uri.call(parser.data, parser.mark, fpc-parser.mark);
|
34
|
+
}
|
35
|
+
action fragment {
|
36
|
+
if(parser.fragment != null)
|
37
|
+
parser.fragment.call(parser.data, parser.mark, fpc-parser.mark);
|
38
|
+
}
|
39
|
+
|
40
|
+
action start_query {parser.query_start = fpc; }
|
41
|
+
action query_string {
|
42
|
+
if(parser.query_string != null)
|
43
|
+
parser.query_string.call(parser.data, parser.query_start, fpc-parser.query_start);
|
44
|
+
}
|
45
|
+
|
46
|
+
action http_version {
|
47
|
+
if(parser.http_version != null)
|
48
|
+
parser.http_version.call(parser.data, parser.mark, fpc-parser.mark);
|
49
|
+
}
|
50
|
+
|
51
|
+
action request_path {
|
52
|
+
if(parser.request_path != null)
|
53
|
+
parser.request_path.call(parser.data, parser.mark, fpc-parser.mark);
|
54
|
+
}
|
55
|
+
|
56
|
+
action done {
|
57
|
+
parser.body_start = fpc + 1;
|
58
|
+
if(parser.header_done != null)
|
59
|
+
parser.header_done.call(parser.data, fpc + 1, pe - fpc - 1);
|
60
|
+
fbreak;
|
61
|
+
}
|
62
|
+
|
63
|
+
include http_parser_common "http11_parser_common.rl";
|
64
|
+
|
65
|
+
}%%
|
66
|
+
|
67
|
+
/** Data **/
|
68
|
+
%% write data;
|
69
|
+
|
70
|
+
public static interface ElementCB {
|
71
|
+
public void call(Object data, int at, int length);
|
72
|
+
}
|
73
|
+
|
74
|
+
public static interface FieldCB {
|
75
|
+
public void call(Object data, int field, int flen, int value, int vlen);
|
76
|
+
}
|
77
|
+
|
78
|
+
public static class HttpParser {
|
79
|
+
int cs;
|
80
|
+
int body_start;
|
81
|
+
int content_len;
|
82
|
+
int nread;
|
83
|
+
int mark;
|
84
|
+
int field_start;
|
85
|
+
int field_len;
|
86
|
+
int query_start;
|
87
|
+
|
88
|
+
Object data;
|
89
|
+
ByteList buffer;
|
90
|
+
|
91
|
+
public FieldCB http_field;
|
92
|
+
public ElementCB request_method;
|
93
|
+
public ElementCB request_uri;
|
94
|
+
public ElementCB fragment;
|
95
|
+
public ElementCB request_path;
|
96
|
+
public ElementCB query_string;
|
97
|
+
public ElementCB http_version;
|
98
|
+
public ElementCB header_done;
|
99
|
+
|
100
|
+
public void init() {
|
101
|
+
cs = 0;
|
102
|
+
|
103
|
+
%% write init;
|
104
|
+
|
105
|
+
body_start = 0;
|
106
|
+
content_len = 0;
|
107
|
+
mark = 0;
|
108
|
+
nread = 0;
|
109
|
+
field_len = 0;
|
110
|
+
field_start = 0;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
public final HttpParser parser = new HttpParser();
|
115
|
+
|
116
|
+
public int execute(ByteList buffer, int off) {
|
117
|
+
int p, pe;
|
118
|
+
int cs = parser.cs;
|
119
|
+
int len = buffer.realSize;
|
120
|
+
assert off<=len : "offset past end of buffer";
|
121
|
+
|
122
|
+
p = off;
|
123
|
+
pe = len;
|
124
|
+
byte[] data = buffer.bytes;
|
125
|
+
parser.buffer = buffer;
|
126
|
+
|
127
|
+
%% write exec;
|
128
|
+
|
129
|
+
parser.cs = cs;
|
130
|
+
parser.nread += (p - off);
|
131
|
+
|
132
|
+
assert p <= pe : "buffer overflow after parsing execute";
|
133
|
+
assert parser.nread <= len : "nread longer than length";
|
134
|
+
assert parser.body_start <= len : "body starts after buffer end";
|
135
|
+
assert parser.mark < len : "mark is after buffer end";
|
136
|
+
assert parser.field_len <= len : "field has length longer than whole buffer";
|
137
|
+
assert parser.field_start < len : "field starts after buffer end";
|
138
|
+
|
139
|
+
if(parser.body_start>0) {
|
140
|
+
/* final \r\n combo encountered so stop right here */
|
141
|
+
%%write eof;
|
142
|
+
parser.nread++;
|
143
|
+
}
|
144
|
+
|
145
|
+
return parser.nread;
|
146
|
+
}
|
147
|
+
|
148
|
+
public int finish() {
|
149
|
+
int cs = parser.cs;
|
150
|
+
|
151
|
+
%%write eof;
|
152
|
+
|
153
|
+
parser.cs = cs;
|
154
|
+
|
155
|
+
if(has_error()) {
|
156
|
+
return -1;
|
157
|
+
} else if(is_finished()) {
|
158
|
+
return 1;
|
159
|
+
} else {
|
160
|
+
return 0;
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
public boolean has_error() {
|
165
|
+
return parser.cs == http_parser_error;
|
166
|
+
}
|
167
|
+
|
168
|
+
public boolean is_finished() {
|
169
|
+
return parser.cs == http_parser_first_final;
|
170
|
+
}
|
171
|
+
}
|