puma 3.9.1 → 4.3.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

Files changed (82) hide show
  1. checksums.yaml +5 -5
  2. data/History.md +232 -0
  3. data/README.md +162 -224
  4. data/docs/architecture.md +37 -0
  5. data/{DEPLOYMENT.md → docs/deployment.md} +24 -4
  6. data/docs/images/puma-connection-flow-no-reactor.png +0 -0
  7. data/docs/images/puma-connection-flow.png +0 -0
  8. data/docs/images/puma-general-arch.png +0 -0
  9. data/docs/plugins.md +38 -0
  10. data/docs/restart.md +41 -0
  11. data/docs/signals.md +56 -3
  12. data/docs/systemd.md +130 -37
  13. data/docs/tcp_mode.md +96 -0
  14. data/ext/puma_http11/PumaHttp11Service.java +2 -0
  15. data/ext/puma_http11/extconf.rb +13 -0
  16. data/ext/puma_http11/http11_parser.c +115 -140
  17. data/ext/puma_http11/http11_parser.java.rl +21 -37
  18. data/ext/puma_http11/http11_parser.rl +9 -9
  19. data/ext/puma_http11/http11_parser_common.rl +3 -3
  20. data/ext/puma_http11/mini_ssl.c +104 -8
  21. data/ext/puma_http11/org/jruby/puma/Http11.java +106 -114
  22. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +90 -108
  23. data/ext/puma_http11/org/jruby/puma/IOBuffer.java +72 -0
  24. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +21 -4
  25. data/ext/puma_http11/puma_http11.c +2 -0
  26. data/lib/puma.rb +16 -0
  27. data/lib/puma/accept_nonblock.rb +7 -1
  28. data/lib/puma/app/status.rb +40 -26
  29. data/lib/puma/binder.rb +57 -74
  30. data/lib/puma/cli.rb +26 -7
  31. data/lib/puma/client.rb +243 -190
  32. data/lib/puma/cluster.rb +78 -34
  33. data/lib/puma/commonlogger.rb +2 -0
  34. data/lib/puma/configuration.rb +24 -16
  35. data/lib/puma/const.rb +36 -18
  36. data/lib/puma/control_cli.rb +46 -19
  37. data/lib/puma/detect.rb +2 -0
  38. data/lib/puma/dsl.rb +329 -68
  39. data/lib/puma/events.rb +6 -1
  40. data/lib/puma/io_buffer.rb +3 -6
  41. data/lib/puma/jruby_restart.rb +2 -1
  42. data/lib/puma/launcher.rb +120 -58
  43. data/lib/puma/minissl.rb +69 -27
  44. data/lib/puma/minissl/context_builder.rb +76 -0
  45. data/lib/puma/null_io.rb +2 -0
  46. data/lib/puma/plugin.rb +7 -2
  47. data/lib/puma/plugin/tmp_restart.rb +2 -1
  48. data/lib/puma/rack/builder.rb +4 -1
  49. data/lib/puma/rack/urlmap.rb +2 -0
  50. data/lib/puma/rack_default.rb +2 -0
  51. data/lib/puma/reactor.rb +224 -34
  52. data/lib/puma/runner.rb +25 -4
  53. data/lib/puma/server.rb +148 -62
  54. data/lib/puma/single.rb +16 -5
  55. data/lib/puma/state_file.rb +2 -0
  56. data/lib/puma/tcp_logger.rb +2 -0
  57. data/lib/puma/thread_pool.rb +61 -38
  58. data/lib/puma/util.rb +2 -6
  59. data/lib/rack/handler/puma.rb +10 -4
  60. data/tools/docker/Dockerfile +16 -0
  61. data/tools/jungle/README.md +12 -2
  62. data/tools/jungle/init.d/README.md +2 -0
  63. data/tools/jungle/init.d/puma +8 -8
  64. data/tools/jungle/init.d/run-puma +1 -1
  65. data/tools/jungle/rc.d/README.md +74 -0
  66. data/tools/jungle/rc.d/puma +61 -0
  67. data/tools/jungle/rc.d/puma.conf +10 -0
  68. data/tools/trickletest.rb +1 -2
  69. metadata +29 -56
  70. data/.github/issue_template.md +0 -20
  71. data/Gemfile +0 -14
  72. data/Manifest.txt +0 -78
  73. data/Rakefile +0 -165
  74. data/Release.md +0 -9
  75. data/gemfiles/2.1-Gemfile +0 -12
  76. data/lib/puma/compat.rb +0 -14
  77. data/lib/puma/convenient.rb +0 -23
  78. data/lib/puma/daemon_ext.rb +0 -31
  79. data/lib/puma/delegation.rb +0 -11
  80. data/lib/puma/java_io_buffer.rb +0 -45
  81. data/lib/puma/rack/backports/uri/common_193.rb +0 -33
  82. data/puma.gemspec +0 -20
@@ -2,6 +2,8 @@
2
2
  // line 1 "ext/puma_http11/http11_parser.java.rl"
3
3
  package org.jruby.puma;
4
4
 
5
+ import org.jruby.Ruby;
6
+ import org.jruby.RubyHash;
5
7
  import org.jruby.util.ByteList;
6
8
 
7
9
  public class Http11Parser {
@@ -9,12 +11,12 @@ public class Http11Parser {
9
11
  /** Machine **/
10
12
 
11
13
 
12
- // line 65 "ext/puma_http11/http11_parser.java.rl"
14
+ // line 58 "ext/puma_http11/http11_parser.java.rl"
13
15
 
14
16
 
15
17
  /** Data **/
16
18
 
17
- // line 18 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
19
+ // line 20 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
18
20
  private static byte[] init__puma_parser_actions_0()
19
21
  {
20
22
  return new byte [] {
@@ -33,8 +35,8 @@ private static short[] init__puma_parser_key_offsets_0()
33
35
  return new short [] {
34
36
  0, 0, 8, 17, 27, 29, 30, 31, 32, 33, 34, 36,
35
37
  39, 41, 44, 45, 61, 62, 78, 80, 81, 89, 97, 107,
36
- 115, 125, 134, 142, 150, 159, 168, 177, 186, 195, 204, 213,
37
- 222, 231, 240, 249, 258, 267, 276, 285, 294, 303, 312, 313
38
+ 115, 124, 132, 140, 149, 158, 167, 176, 185, 194, 203, 212,
39
+ 221, 230, 239, 248, 257, 266, 275, 284, 293, 302, 303
38
40
  };
39
41
  }
40
42
 
@@ -53,24 +55,23 @@ private static char[] init__puma_parser_trans_keys_0()
53
55
  48, 57, 65, 90, 94, 122, 13, 32, 13, 32, 60, 62,
54
56
  127, 0, 31, 34, 35, 32, 60, 62, 127, 0, 31, 34,
55
57
  35, 43, 58, 45, 46, 48, 57, 65, 90, 97, 122, 32,
56
- 34, 35, 60, 62, 127, 0, 31, 32, 34, 35, 59, 60,
57
- 62, 63, 127, 0, 31, 32, 34, 35, 60, 62, 63, 127,
58
- 0, 31, 32, 34, 35, 60, 62, 127, 0, 31, 32, 34,
59
- 35, 60, 62, 127, 0, 31, 32, 36, 95, 45, 46, 48,
60
- 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90,
61
- 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95,
62
- 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48,
63
- 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90,
64
- 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95,
65
- 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48,
66
- 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90,
67
- 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95,
68
- 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48,
69
- 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90,
70
- 32, 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95,
71
- 45, 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48,
72
- 57, 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90,
73
- 32, 0
58
+ 34, 35, 60, 62, 127, 0, 31, 32, 34, 35, 60, 62,
59
+ 63, 127, 0, 31, 32, 34, 35, 60, 62, 127, 0, 31,
60
+ 32, 34, 35, 60, 62, 127, 0, 31, 32, 36, 95, 45,
61
+ 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57,
62
+ 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32,
63
+ 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45,
64
+ 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57,
65
+ 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32,
66
+ 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45,
67
+ 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57,
68
+ 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32,
69
+ 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45,
70
+ 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57,
71
+ 65, 90, 32, 36, 95, 45, 46, 48, 57, 65, 90, 32,
72
+ 36, 95, 45, 46, 48, 57, 65, 90, 32, 36, 95, 45,
73
+ 46, 48, 57, 65, 90, 32, 36, 95, 45, 46, 48, 57,
74
+ 65, 90, 32, 0
74
75
  };
75
76
  }
76
77
 
@@ -82,8 +83,8 @@ private static byte[] init__puma_parser_single_lengths_0()
82
83
  return new byte [] {
83
84
  0, 2, 3, 4, 2, 1, 1, 1, 1, 1, 0, 1,
84
85
  0, 1, 1, 4, 1, 4, 2, 1, 4, 4, 2, 6,
85
- 8, 7, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3,
86
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0
86
+ 7, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3,
87
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0
87
88
  };
88
89
  }
89
90
 
@@ -95,8 +96,8 @@ private static byte[] init__puma_parser_range_lengths_0()
95
96
  return new byte [] {
96
97
  0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1,
97
98
  1, 1, 0, 6, 0, 6, 0, 0, 2, 2, 4, 1,
98
- 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3,
99
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0
99
+ 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
100
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0
100
101
  };
101
102
  }
102
103
 
@@ -108,8 +109,8 @@ private static short[] init__puma_parser_index_offsets_0()
108
109
  return new short [] {
109
110
  0, 0, 6, 13, 21, 24, 26, 28, 30, 32, 34, 36,
110
111
  39, 41, 44, 46, 57, 59, 70, 73, 75, 82, 89, 96,
111
- 104, 114, 123, 131, 139, 146, 153, 160, 167, 174, 181, 188,
112
- 195, 202, 209, 216, 223, 230, 237, 244, 251, 258, 265, 267
112
+ 104, 113, 121, 129, 136, 143, 150, 157, 164, 171, 178, 185,
113
+ 192, 199, 206, 213, 220, 227, 234, 241, 248, 255, 257
113
114
  };
114
115
  }
115
116
 
@@ -127,21 +128,20 @@ private static byte[] init__puma_parser_indicies_0()
127
128
  24, 23, 23, 23, 23, 23, 23, 23, 23, 1, 26, 27,
128
129
  25, 29, 28, 30, 1, 1, 1, 1, 1, 31, 32, 1,
129
130
  1, 1, 1, 1, 33, 34, 35, 34, 34, 34, 34, 1,
130
- 8, 1, 9, 1, 1, 1, 1, 35, 36, 1, 38, 39,
131
- 1, 1, 40, 1, 1, 37, 8, 1, 9, 1, 1, 42,
132
- 1, 1, 41, 43, 1, 45, 1, 1, 1, 1, 44, 46,
133
- 1, 48, 1, 1, 1, 1, 47, 2, 49, 49, 49, 49,
134
- 49, 1, 2, 50, 50, 50, 50, 50, 1, 2, 51, 51,
135
- 51, 51, 51, 1, 2, 52, 52, 52, 52, 52, 1, 2,
136
- 53, 53, 53, 53, 53, 1, 2, 54, 54, 54, 54, 54,
137
- 1, 2, 55, 55, 55, 55, 55, 1, 2, 56, 56, 56,
138
- 56, 56, 1, 2, 57, 57, 57, 57, 57, 1, 2, 58,
139
- 58, 58, 58, 58, 1, 2, 59, 59, 59, 59, 59, 1,
140
- 2, 60, 60, 60, 60, 60, 1, 2, 61, 61, 61, 61,
141
- 61, 1, 2, 62, 62, 62, 62, 62, 1, 2, 63, 63,
142
- 63, 63, 63, 1, 2, 64, 64, 64, 64, 64, 1, 2,
143
- 65, 65, 65, 65, 65, 1, 2, 66, 66, 66, 66, 66,
144
- 1, 2, 1, 1, 0
131
+ 8, 1, 9, 1, 1, 1, 1, 35, 36, 1, 38, 1,
132
+ 1, 39, 1, 1, 37, 40, 1, 42, 1, 1, 1, 1,
133
+ 41, 43, 1, 45, 1, 1, 1, 1, 44, 2, 46, 46,
134
+ 46, 46, 46, 1, 2, 47, 47, 47, 47, 47, 1, 2,
135
+ 48, 48, 48, 48, 48, 1, 2, 49, 49, 49, 49, 49,
136
+ 1, 2, 50, 50, 50, 50, 50, 1, 2, 51, 51, 51,
137
+ 51, 51, 1, 2, 52, 52, 52, 52, 52, 1, 2, 53,
138
+ 53, 53, 53, 53, 1, 2, 54, 54, 54, 54, 54, 1,
139
+ 2, 55, 55, 55, 55, 55, 1, 2, 56, 56, 56, 56,
140
+ 56, 1, 2, 57, 57, 57, 57, 57, 1, 2, 58, 58,
141
+ 58, 58, 58, 1, 2, 59, 59, 59, 59, 59, 1, 2,
142
+ 60, 60, 60, 60, 60, 1, 2, 61, 61, 61, 61, 61,
143
+ 1, 2, 62, 62, 62, 62, 62, 1, 2, 63, 63, 63,
144
+ 63, 63, 1, 2, 1, 1, 0
145
145
  };
146
146
  }
147
147
 
@@ -151,12 +151,12 @@ private static final byte _puma_parser_indicies[] = init__puma_parser_indicies_0
151
151
  private static byte[] init__puma_parser_trans_targs_0()
152
152
  {
153
153
  return new byte [] {
154
- 2, 0, 3, 28, 4, 22, 24, 23, 5, 20, 6, 7,
155
- 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 47, 17,
154
+ 2, 0, 3, 27, 4, 22, 24, 23, 5, 20, 6, 7,
155
+ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 46, 17,
156
156
  18, 19, 14, 18, 19, 14, 5, 21, 5, 21, 22, 23,
157
- 5, 24, 20, 25, 26, 25, 26, 5, 27, 20, 5, 27,
158
- 20, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
159
- 40, 41, 42, 43, 44, 45, 46
157
+ 5, 24, 20, 25, 5, 26, 20, 5, 26, 20, 28, 29,
158
+ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
159
+ 42, 43, 44, 45
160
160
  };
161
161
  }
162
162
 
@@ -169,9 +169,9 @@ private static byte[] init__puma_parser_trans_actions_0()
169
169
  1, 0, 11, 0, 1, 1, 1, 1, 13, 13, 1, 0,
170
170
  0, 0, 0, 0, 0, 0, 19, 0, 0, 28, 23, 3,
171
171
  5, 7, 31, 7, 0, 9, 25, 1, 15, 0, 0, 0,
172
- 37, 0, 37, 21, 21, 0, 0, 40, 17, 40, 34, 0,
173
- 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
174
- 0, 0, 0, 0, 0, 0, 0
172
+ 37, 0, 37, 21, 40, 17, 40, 34, 0, 34, 0, 0,
173
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
174
+ 0, 0, 0, 0
175
175
  };
176
176
  }
177
177
 
@@ -179,20 +179,20 @@ private static final byte _puma_parser_trans_actions[] = init__puma_parser_trans
179
179
 
180
180
 
181
181
  static final int puma_parser_start = 1;
182
- static final int puma_parser_first_final = 47;
182
+ static final int puma_parser_first_final = 46;
183
183
  static final int puma_parser_error = 0;
184
184
 
185
185
  static final int puma_parser_en_main = 1;
186
186
 
187
187
 
188
- // line 69 "ext/puma_http11/http11_parser.java.rl"
188
+ // line 62 "ext/puma_http11/http11_parser.java.rl"
189
189
 
190
190
  public static interface ElementCB {
191
- public void call(Object data, int at, int length);
191
+ public void call(Ruby runtime, RubyHash data, ByteList buffer, int at, int length);
192
192
  }
193
193
 
194
194
  public static interface FieldCB {
195
- public void call(Object data, int field, int flen, int value, int vlen);
195
+ public void call(Ruby runtime, RubyHash data, ByteList buffer, int field, int flen, int value, int vlen);
196
196
  }
197
197
 
198
198
  public static class HttpParser {
@@ -205,28 +205,19 @@ static final int puma_parser_en_main = 1;
205
205
  int field_len;
206
206
  int query_start;
207
207
 
208
- Object data;
208
+ RubyHash data;
209
209
  ByteList buffer;
210
210
 
211
- public FieldCB http_field;
212
- public ElementCB request_method;
213
- public ElementCB request_uri;
214
- public ElementCB fragment;
215
- public ElementCB request_path;
216
- public ElementCB query_string;
217
- public ElementCB http_version;
218
- public ElementCB header_done;
219
-
220
211
  public void init() {
221
212
  cs = 0;
222
213
 
223
214
 
224
- // line 225 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
215
+ // line 218 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
225
216
  {
226
217
  cs = puma_parser_start;
227
218
  }
228
219
 
229
- // line 104 "ext/puma_http11/http11_parser.java.rl"
220
+ // line 90 "ext/puma_http11/http11_parser.java.rl"
230
221
 
231
222
  body_start = 0;
232
223
  content_len = 0;
@@ -239,7 +230,7 @@ static final int puma_parser_en_main = 1;
239
230
 
240
231
  public final HttpParser parser = new HttpParser();
241
232
 
242
- public int execute(ByteList buffer, int off) {
233
+ public int execute(Ruby runtime, Http11 http, ByteList buffer, int off) {
243
234
  int p, pe;
244
235
  int cs = parser.cs;
245
236
  int len = buffer.length();
@@ -253,7 +244,7 @@ static final int puma_parser_en_main = 1;
253
244
  parser.buffer = buffer;
254
245
 
255
246
 
256
- // line 257 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
247
+ // line 250 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
257
248
  {
258
249
  int _klen;
259
250
  int _trans = 0;
@@ -334,91 +325,82 @@ case 1:
334
325
  switch ( _puma_parser_actions[_acts++] )
335
326
  {
336
327
  case 0:
337
- // line 13 "ext/puma_http11/http11_parser.java.rl"
328
+ // line 15 "ext/puma_http11/http11_parser.java.rl"
338
329
  {parser.mark = p; }
339
330
  break;
340
331
  case 1:
341
- // line 15 "ext/puma_http11/http11_parser.java.rl"
332
+ // line 17 "ext/puma_http11/http11_parser.java.rl"
342
333
  { parser.field_start = p; }
343
334
  break;
344
335
  case 2:
345
- // line 16 "ext/puma_http11/http11_parser.java.rl"
336
+ // line 18 "ext/puma_http11/http11_parser.java.rl"
346
337
  { /* FIXME stub */ }
347
338
  break;
348
339
  case 3:
349
- // line 17 "ext/puma_http11/http11_parser.java.rl"
340
+ // line 19 "ext/puma_http11/http11_parser.java.rl"
350
341
  {
351
342
  parser.field_len = p-parser.field_start;
352
343
  }
353
344
  break;
354
345
  case 4:
355
- // line 21 "ext/puma_http11/http11_parser.java.rl"
346
+ // line 23 "ext/puma_http11/http11_parser.java.rl"
356
347
  { parser.mark = p; }
357
348
  break;
358
349
  case 5:
359
- // line 22 "ext/puma_http11/http11_parser.java.rl"
360
- {
361
- if(parser.http_field != null) {
362
- parser.http_field.call(parser.data, parser.field_start, parser.field_len, parser.mark, p-parser.mark);
363
- }
350
+ // line 24 "ext/puma_http11/http11_parser.java.rl"
351
+ {
352
+ Http11.http_field(runtime, parser.data, parser.buffer, parser.field_start, parser.field_len, parser.mark, p-parser.mark);
364
353
  }
365
354
  break;
366
355
  case 6:
367
356
  // line 27 "ext/puma_http11/http11_parser.java.rl"
368
- {
369
- if(parser.request_method != null)
370
- parser.request_method.call(parser.data, parser.mark, p-parser.mark);
357
+ {
358
+ Http11.request_method(runtime, parser.data, parser.buffer, parser.mark, p-parser.mark);
371
359
  }
372
360
  break;
373
361
  case 7:
374
- // line 31 "ext/puma_http11/http11_parser.java.rl"
375
- {
376
- if(parser.request_uri != null)
377
- parser.request_uri.call(parser.data, parser.mark, p-parser.mark);
362
+ // line 30 "ext/puma_http11/http11_parser.java.rl"
363
+ {
364
+ Http11.request_uri(runtime, parser.data, parser.buffer, parser.mark, p-parser.mark);
378
365
  }
379
366
  break;
380
367
  case 8:
381
- // line 35 "ext/puma_http11/http11_parser.java.rl"
382
- {
383
- if(parser.fragment != null)
384
- parser.fragment.call(parser.data, parser.mark, p-parser.mark);
368
+ // line 33 "ext/puma_http11/http11_parser.java.rl"
369
+ {
370
+ Http11.fragment(runtime, parser.data, parser.buffer, parser.mark, p-parser.mark);
385
371
  }
386
372
  break;
387
373
  case 9:
388
- // line 40 "ext/puma_http11/http11_parser.java.rl"
374
+ // line 37 "ext/puma_http11/http11_parser.java.rl"
389
375
  {parser.query_start = p; }
390
376
  break;
391
377
  case 10:
392
- // line 41 "ext/puma_http11/http11_parser.java.rl"
393
- {
394
- if(parser.query_string != null)
395
- parser.query_string.call(parser.data, parser.query_start, p-parser.query_start);
378
+ // line 38 "ext/puma_http11/http11_parser.java.rl"
379
+ {
380
+ Http11.query_string(runtime, parser.data, parser.buffer, parser.query_start, p-parser.query_start);
396
381
  }
397
382
  break;
398
383
  case 11:
399
- // line 46 "ext/puma_http11/http11_parser.java.rl"
400
- {
401
- if(parser.http_version != null)
402
- parser.http_version.call(parser.data, parser.mark, p-parser.mark);
384
+ // line 42 "ext/puma_http11/http11_parser.java.rl"
385
+ {
386
+ Http11.http_version(runtime, parser.data, parser.buffer, parser.mark, p-parser.mark);
403
387
  }
404
388
  break;
405
389
  case 12:
406
- // line 51 "ext/puma_http11/http11_parser.java.rl"
390
+ // line 46 "ext/puma_http11/http11_parser.java.rl"
407
391
  {
408
- if(parser.request_path != null)
409
- parser.request_path.call(parser.data, parser.mark, p-parser.mark);
392
+ Http11.request_path(runtime, parser.data, parser.buffer, parser.mark, p-parser.mark);
410
393
  }
411
394
  break;
412
395
  case 13:
413
- // line 56 "ext/puma_http11/http11_parser.java.rl"
396
+ // line 50 "ext/puma_http11/http11_parser.java.rl"
414
397
  {
415
- parser.body_start = p + 1;
416
- if(parser.header_done != null)
417
- parser.header_done.call(parser.data, p + 1, pe - p - 1);
398
+ parser.body_start = p + 1;
399
+ http.header_done(runtime, parser.data, parser.buffer, p + 1, pe - p - 1);
418
400
  { p += 1; _goto_targ = 5; if (true) continue _goto;}
419
401
  }
420
402
  break;
421
- // line 422 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
403
+ // line 406 "ext/puma_http11/org/jruby/puma/Http11Parser.java"
422
404
  }
423
405
  }
424
406
  }
@@ -438,7 +420,7 @@ case 5:
438
420
  break; }
439
421
  }
440
422
 
441
- // line 130 "ext/puma_http11/http11_parser.java.rl"
423
+ // line 116 "ext/puma_http11/http11_parser.java.rl"
442
424
 
443
425
  parser.cs = cs;
444
426
  parser.nread += (p - off);
@@ -0,0 +1,72 @@
1
+ package org.jruby.puma;
2
+
3
+ import org.jruby.*;
4
+ import org.jruby.anno.JRubyMethod;
5
+ import org.jruby.runtime.ObjectAllocator;
6
+ import org.jruby.runtime.ThreadContext;
7
+ import org.jruby.runtime.builtin.IRubyObject;
8
+ import org.jruby.util.ByteList;
9
+
10
+ /**
11
+ * @author kares
12
+ */
13
+ public class IOBuffer extends RubyObject {
14
+
15
+ private static final ObjectAllocator ALLOCATOR = new ObjectAllocator() {
16
+ public IRubyObject allocate(Ruby runtime, RubyClass klass) {
17
+ return new IOBuffer(runtime, klass);
18
+ }
19
+ };
20
+
21
+ public static void createIOBuffer(Ruby runtime) {
22
+ RubyModule mPuma = runtime.defineModule("Puma");
23
+ RubyClass cIOBuffer = mPuma.defineClassUnder("IOBuffer", runtime.getObject(), ALLOCATOR);
24
+ cIOBuffer.defineAnnotatedMethods(IOBuffer.class);
25
+ }
26
+
27
+ private static final int DEFAULT_SIZE = 4096;
28
+
29
+ final ByteList buffer = new ByteList(DEFAULT_SIZE);
30
+
31
+ IOBuffer(Ruby runtime, RubyClass klass) {
32
+ super(runtime, klass);
33
+ }
34
+
35
+ @JRubyMethod
36
+ public RubyInteger used(ThreadContext context) {
37
+ return context.runtime.newFixnum(buffer.getRealSize());
38
+ }
39
+
40
+ @JRubyMethod
41
+ public RubyInteger capacity(ThreadContext context) {
42
+ return context.runtime.newFixnum(buffer.unsafeBytes().length);
43
+ }
44
+
45
+ @JRubyMethod
46
+ public IRubyObject reset() {
47
+ buffer.setRealSize(0);
48
+ return this;
49
+ }
50
+
51
+ @JRubyMethod(name = { "to_s", "to_str" })
52
+ public RubyString to_s(ThreadContext context) {
53
+ return RubyString.newStringShared(context.runtime, buffer.unsafeBytes(), 0, buffer.getRealSize());
54
+ }
55
+
56
+ @JRubyMethod(name = "<<")
57
+ public IRubyObject add(IRubyObject str) {
58
+ addImpl(str.convertToString());
59
+ return this;
60
+ }
61
+
62
+ @JRubyMethod(rest = true)
63
+ public IRubyObject append(IRubyObject[] strs) {
64
+ for (IRubyObject str : strs) addImpl(str.convertToString());
65
+ return this;
66
+ }
67
+
68
+ private void addImpl(RubyString str) {
69
+ buffer.append(str.getByteList());
70
+ }
71
+
72
+ }
@@ -23,6 +23,7 @@ import javax.net.ssl.SSLPeerUnverifiedException;
23
23
  import javax.net.ssl.SSLSession;
24
24
  import java.io.FileInputStream;
25
25
  import java.io.IOException;
26
+ import java.nio.Buffer;
26
27
  import java.nio.ByteBuffer;
27
28
  import java.security.KeyManagementException;
28
29
  import java.security.KeyStore;
@@ -65,7 +66,7 @@ public class MiniSSL extends RubyObject {
65
66
 
66
67
  public void clear() { buffer.clear(); }
67
68
  public void compact() { buffer.compact(); }
68
- public void flip() { buffer.flip(); }
69
+ public void flip() { ((Buffer) buffer).flip(); }
69
70
  public boolean hasRemaining() { return buffer.hasRemaining(); }
70
71
  public int position() { return buffer.position(); }
71
72
 
@@ -89,7 +90,7 @@ public class MiniSSL extends RubyObject {
89
90
  public void resize(int newCapacity) {
90
91
  if (newCapacity > buffer.capacity()) {
91
92
  ByteBuffer dstTmp = ByteBuffer.allocate(newCapacity);
92
- buffer.flip();
93
+ flip();
93
94
  dstTmp.put(buffer);
94
95
  buffer = dstTmp;
95
96
  } else {
@@ -101,7 +102,7 @@ public class MiniSSL extends RubyObject {
101
102
  * Drains the buffer to a ByteList, or returns null for an empty buffer
102
103
  */
103
104
  public ByteList asByteList() {
104
- buffer.flip();
105
+ flip();
105
106
  if (!buffer.hasRemaining()) {
106
107
  buffer.clear();
107
108
  return null;
@@ -158,7 +159,17 @@ public class MiniSSL extends RubyObject {
158
159
  sslCtx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
159
160
  engine = sslCtx.createSSLEngine();
160
161
 
161
- String[] protocols = new String[] { "TLSv1", "TLSv1.1", "TLSv1.2" };
162
+ String[] protocols;
163
+ if(miniSSLContext.callMethod(threadContext, "no_tlsv1").isTrue()) {
164
+ protocols = new String[] { "TLSv1.1", "TLSv1.2" };
165
+ } else {
166
+ protocols = new String[] { "TLSv1", "TLSv1.1", "TLSv1.2" };
167
+ }
168
+
169
+ if(miniSSLContext.callMethod(threadContext, "no_tlsv1_1").isTrue()) {
170
+ protocols = new String[] { "TLSv1.2" };
171
+ }
172
+
162
173
  engine.setEnabledProtocols(protocols);
163
174
  engine.setUseClientMode(false);
164
175
 
@@ -170,6 +181,12 @@ public class MiniSSL extends RubyObject {
170
181
  engine.setNeedClientAuth(true);
171
182
  }
172
183
 
184
+ IRubyObject sslCipherListObject = miniSSLContext.callMethod(threadContext, "ssl_cipher_list");
185
+ if (!sslCipherListObject.isNil()) {
186
+ String[] sslCipherList = sslCipherListObject.convertToString().asJavaString().split(",");
187
+ engine.setEnabledCipherSuites(sslCipherList);
188
+ }
189
+
173
190
  SSLSession session = engine.getSession();
174
191
  inboundNetData = new MiniSSLBuffer(session.getPacketBufferSize());
175
192
  outboundAppData = new MiniSSLBuffer(session.getApplicationBufferSize());