waitress-core 0.0.3 → 0.0.4

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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/LICENSE +21 -21
  4. data/Rakefile +13 -4
  5. data/bin/waitress +22 -22
  6. data/ext/Thanks.md +1 -1
  7. data/ext/waitress_http11/ext_help.h +15 -15
  8. data/ext/waitress_http11/extconf.rb +6 -6
  9. data/ext/waitress_http11/http11.c +532 -532
  10. data/ext/waitress_http11/http11_parser.c +1216 -1216
  11. data/ext/waitress_http11/http11_parser.h +49 -49
  12. data/ext/waitress_http11/http11_parser.java.rl +171 -171
  13. data/ext/waitress_http11/http11_parser.rl +165 -165
  14. data/ext/waitress_http11/http11_parser_common.rl +55 -55
  15. data/ext/waitress_http11/http11_wrb_parser.h +83 -83
  16. data/lib/waitress/chef.rb +110 -110
  17. data/lib/waitress/configure.rb +116 -116
  18. data/lib/waitress/handlers/dirhandler.rb +39 -39
  19. data/lib/waitress/handlers/handler.rb +57 -57
  20. data/lib/waitress/handlers/handler404.rb +25 -25
  21. data/lib/waitress/handlers/libhandler.rb +58 -58
  22. data/lib/waitress/kernel.rb +182 -182
  23. data/lib/waitress/parse/query.rb +60 -60
  24. data/lib/waitress/request.rb +45 -45
  25. data/lib/waitress/resources/default_config.rb +52 -52
  26. data/lib/waitress/resources/http/404.html +18 -18
  27. data/lib/waitress/resources/http/css/hack.css +37 -37
  28. data/lib/waitress/resources/http/css/waitress.css +57 -57
  29. data/lib/waitress/resources/http/fonts/eot/latin/hack-bold-latin-webfont.eot +0 -0
  30. data/lib/waitress/resources/http/fonts/eot/latin/hack-bolditalic-latin-webfont.eot +0 -0
  31. data/lib/waitress/resources/http/fonts/eot/latin/hack-italic-latin-webfont.eot +0 -0
  32. data/lib/waitress/resources/http/fonts/eot/latin/hack-regular-latin-webfont.eot +0 -0
  33. data/lib/waitress/resources/http/fonts/svg/latin/hack-bold-latin-webfont.svg +240 -240
  34. data/lib/waitress/resources/http/fonts/svg/latin/hack-bolditalic-latin-webfont.svg +240 -240
  35. data/lib/waitress/resources/http/fonts/svg/latin/hack-italic-latin-webfont.svg +240 -240
  36. data/lib/waitress/resources/http/fonts/svg/latin/hack-regular-latin-webfont.svg +240 -240
  37. data/lib/waitress/resources/http/fonts/web-ttf/latin/hack-bold-latin-webfont.ttf +0 -0
  38. data/lib/waitress/resources/http/fonts/web-ttf/latin/hack-bolditalic-latin-webfont.ttf +0 -0
  39. data/lib/waitress/resources/http/fonts/web-ttf/latin/hack-italic-latin-webfont.ttf +0 -0
  40. data/lib/waitress/resources/http/fonts/web-ttf/latin/hack-regular-latin-webfont.ttf +0 -0
  41. data/lib/waitress/resources/http/fonts/woff/latin/hack-bold-latin-webfont.woff +0 -0
  42. data/lib/waitress/resources/http/fonts/woff/latin/hack-bolditalic-latin-webfont.woff +0 -0
  43. data/lib/waitress/resources/http/fonts/woff/latin/hack-italic-latin-webfont.woff +0 -0
  44. data/lib/waitress/resources/http/fonts/woff/latin/hack-regular-latin-webfont.woff +0 -0
  45. data/lib/waitress/resources/http/fonts/woff2/latin/hack-bold-latin-webfont.woff2 +0 -0
  46. data/lib/waitress/resources/http/fonts/woff2/latin/hack-bolditalic-latin-webfont.woff2 +0 -0
  47. data/lib/waitress/resources/http/fonts/woff2/latin/hack-italic-latin-webfont.woff2 +0 -0
  48. data/lib/waitress/resources/http/fonts/woff2/latin/hack-regular-latin-webfont.woff2 +0 -0
  49. data/lib/waitress/resources/http/img/404.png +0 -0
  50. data/lib/waitress/resources/http/index.html +15 -15
  51. data/lib/waitress/response.rb +104 -104
  52. data/lib/waitress/server.rb +126 -115
  53. data/lib/waitress/util.rb +707 -713
  54. data/lib/waitress/version.rb +3 -3
  55. data/lib/waitress/vhost.rb +217 -217
  56. data/lib/waitress.rb +98 -98
  57. data/lib/waitress_http11.bundle +0 -0
  58. data/waitress-core.gemspec +29 -27
  59. metadata +35 -7
  60. data/lib/waitress_http11.so +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
+ }