puma 3.9.1-java → 3.10.0-java
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.
- checksums.yaml +4 -4
- data/History.md +29 -0
- data/README.md +124 -229
- data/docs/plugins.md +28 -0
- data/docs/restart.md +39 -0
- data/docs/signals.md +56 -3
- data/docs/systemd.md +102 -37
- data/ext/puma_http11/http11_parser.c +130 -146
- data/ext/puma_http11/http11_parser.rl +9 -9
- data/ext/puma_http11/mini_ssl.c +2 -2
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +13 -16
- data/lib/puma/app/status.rb +8 -0
- data/lib/puma/binder.rb +6 -5
- data/lib/puma/client.rb +1 -0
- data/lib/puma/cluster.rb +8 -2
- data/lib/puma/configuration.rb +3 -2
- data/lib/puma/const.rb +3 -2
- data/lib/puma/control_cli.rb +2 -2
- data/lib/puma/dsl.rb +10 -0
- data/lib/puma/jruby_restart.rb +0 -1
- data/lib/puma/launcher.rb +31 -14
- data/lib/puma/minissl.rb +19 -25
- data/lib/puma/plugin/tmp_restart.rb +0 -1
- data/lib/puma/puma_http11.jar +0 -0
- data/lib/puma/reactor.rb +3 -0
- data/lib/puma/server.rb +25 -19
- data/lib/puma/thread_pool.rb +2 -2
- data/lib/rack/handler/puma.rb +2 -0
- data/tools/jungle/README.md +4 -0
- data/tools/trickletest.rb +1 -1
- metadata +9 -57
- data/.github/issue_template.md +0 -20
- data/DEPLOYMENT.md +0 -91
- data/Gemfile +0 -14
- data/Manifest.txt +0 -78
- data/Rakefile +0 -165
- data/Release.md +0 -9
- data/gemfiles/2.1-Gemfile +0 -12
- data/puma.gemspec +0 -20
data/docs/plugins.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
## Plugins
|
2
|
+
|
3
|
+
Puma 3.0 added support for plugins that can augment configuration and service operations.
|
4
|
+
|
5
|
+
2 canonical plugins to look to aid in development of further plugins:
|
6
|
+
|
7
|
+
* [tmp\_restart](https://github.com/puma/puma/blob/master/lib/puma/plugin/tmp_restart.rb): Restarts the server if the file `tmp/restart.txt` is touched
|
8
|
+
* [heroku](https://github.com/puma/puma-heroku/blob/master/lib/puma/plugin/heroku.rb): Packages up the default configuration used by puma on Heroku
|
9
|
+
|
10
|
+
Plugins are activated in a puma configuration file (such as `config/puma.rb'`) by adding `plugin "name"`, such as `plugin "heroku"`.
|
11
|
+
|
12
|
+
Plugins are activated based simply on path requirements so, activating the `heroku` plugin will simply be doing `require "puma/plugin/heroku"`. This allows gems to provide multiple plugins (as well as unrelated gems to provide puma plugins).
|
13
|
+
|
14
|
+
The `tmp_restart` plugin is bundled with puma, so it can always be used.
|
15
|
+
|
16
|
+
To use the `heroku` plugin, add `puma-heroku` to your Gemfile or install it.
|
17
|
+
|
18
|
+
### API
|
19
|
+
|
20
|
+
At present, there are 2 hooks that plugins can use: `start` and `config`.
|
21
|
+
|
22
|
+
`start` runs when the server has started and allows the plugin to start other functionality to augment puma.
|
23
|
+
|
24
|
+
`config` runs when the server is being configured and is passed a `Puma::DSL` object that can be used to add additional configuration.
|
25
|
+
|
26
|
+
Any public methods in `Puma::Plugin` are the public API that any plugin may use.
|
27
|
+
|
28
|
+
In the future, more hooks and APIs will be added.
|
data/docs/restart.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Restarts
|
2
|
+
|
3
|
+
To perform a restart, there are 3 builtin mechanisms:
|
4
|
+
|
5
|
+
* Send the `puma` process the `SIGUSR2` signal
|
6
|
+
* Send the `puma` process the `SIGUSR1` signal (rolling restart, cluster mode only)
|
7
|
+
* Use the status server and issue `/restart`
|
8
|
+
|
9
|
+
No code is shared between the current and restarted process, so it should be safe to issue a restart any place where you would manually stop Puma and start it again.
|
10
|
+
|
11
|
+
If the new process is unable to load, it will simply exit. You should therefore run Puma under a process monitor (see below) when using it in production.
|
12
|
+
|
13
|
+
### Normal vs Hot vs Phased Restart
|
14
|
+
|
15
|
+
A hot restart means that no requests will be lost while deploying your new code, since the server socket is kept open between restarts.
|
16
|
+
|
17
|
+
But beware, hot restart does not mean that the incoming requests won’t hang for multiple seconds while your new code has not fully deployed. If you need a zero downtime and zero hanging requests deploy, you must use phased restart.
|
18
|
+
|
19
|
+
When you run pumactl phased-restart, Puma kills workers one-by-one, meaning that at least another worker is still available to serve requests, which lead to zero hanging requests (yay!).
|
20
|
+
|
21
|
+
But again beware, upgrading an application sometimes involves upgrading the database schema. With phased restart, there may be a moment during the deployment where processes belonging to the previous version and processes belonging to the new version both exist at the same time. Any database schema upgrades you perform must therefore be backwards-compatible with the old application version.
|
22
|
+
|
23
|
+
If you perform a lot of database migrations, you probably should not use phased restart and use a normal/hot restart instead (pumactl restart). That way, no code is shared while deploying (in that case, preload_app might help for quicker deployment, see below).
|
24
|
+
|
25
|
+
### Release Directory
|
26
|
+
|
27
|
+
If your symlink releases into a common working directory (i.e., `/current` from Capistrano), Puma won't pick up your new changes when running phased restarts without additional configuration. You should set your working directory within Puma's config to specify the directory it should use. This is a change from earlier versions of Puma (< 2.15) that would infer the directory for you.
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
# config/puma.rb
|
31
|
+
|
32
|
+
directory '/var/www/current'
|
33
|
+
```
|
34
|
+
|
35
|
+
### Cleanup Code
|
36
|
+
|
37
|
+
Puma isn't able to understand all the resources that your app may use, so it provides a hook in the configuration file you pass to `-C` called `on_restart`. The block passed to `on_restart` will be called, unsurprisingly, just before Puma restarts itself.
|
38
|
+
|
39
|
+
You should place code to close global log files, redis connections, etc. in this block so that their file descriptors don't leak into the restarted process. Failure to do so will result in slowly running out of descriptors and eventually obscure crashes as the server is restarted many times.
|
data/docs/signals.md
CHANGED
@@ -36,8 +36,61 @@ Puma cluster responds to these signals:
|
|
36
36
|
- `TTIN` increment the worker count by 1
|
37
37
|
- `TTOU` decrement the worker count by 1
|
38
38
|
- `TERM` send `TERM` to worker. Worker will attempt to finish then exit.
|
39
|
-
- `USR2` restart workers
|
40
|
-
- `USR1` restart workers in phases, a rolling restart.
|
41
|
-
- `HUP` reopen log files defined in stdout_redirect configuration parameter
|
39
|
+
- `USR2` restart workers. This also reloads puma configuration file, if there is one.
|
40
|
+
- `USR1` restart workers in phases, a rolling restart. This will not reload configuration file.
|
41
|
+
- `HUP` reopen log files defined in stdout_redirect configuration parameter. If there is no stdout_redirect option provided it will behave like `INT`
|
42
42
|
- `INT` equivalent of sending Ctrl-C to cluster. Will attempt to finish then exit.
|
43
43
|
- `CHLD`
|
44
|
+
|
45
|
+
## Callbacks order in case of different signals
|
46
|
+
|
47
|
+
### Start application
|
48
|
+
|
49
|
+
```
|
50
|
+
puma configuration file reloaded, if there is one
|
51
|
+
* Pruning Bundler environment
|
52
|
+
puma configuration file reloaded, if there is one
|
53
|
+
|
54
|
+
before_fork
|
55
|
+
on_worker_fork
|
56
|
+
after_worker_fork
|
57
|
+
|
58
|
+
Gemfile in context
|
59
|
+
|
60
|
+
on_worker_boot
|
61
|
+
|
62
|
+
Code of the app is loaded and running
|
63
|
+
```
|
64
|
+
|
65
|
+
### Send USR2
|
66
|
+
|
67
|
+
```
|
68
|
+
on_worker_shutdown
|
69
|
+
on_restart
|
70
|
+
|
71
|
+
puma configuration file reloaded, if there is one
|
72
|
+
|
73
|
+
before_fork
|
74
|
+
on_worker_fork
|
75
|
+
after_worker_fork
|
76
|
+
|
77
|
+
Gemfile in context
|
78
|
+
|
79
|
+
on_worker_boot
|
80
|
+
|
81
|
+
Code of the app is loaded and running
|
82
|
+
```
|
83
|
+
|
84
|
+
### Send USR1
|
85
|
+
|
86
|
+
```
|
87
|
+
on_worker_shutdown
|
88
|
+
on_worker_fork
|
89
|
+
after_worker_fork
|
90
|
+
|
91
|
+
Gemfile in context
|
92
|
+
|
93
|
+
on_worker_boot
|
94
|
+
|
95
|
+
Code of the app is loaded and running
|
96
|
+
```
|
data/docs/systemd.md
CHANGED
@@ -3,10 +3,21 @@
|
|
3
3
|
[systemd](https://www.freedesktop.org/wiki/Software/systemd/) is a
|
4
4
|
commonly available init system (PID 1) on many Linux distributions. It
|
5
5
|
offers process monitoring (including automatic restarts) and other
|
6
|
-
useful features for running Puma in production.
|
7
|
-
puma.service configuration file for systemd:
|
6
|
+
useful features for running Puma in production.
|
8
7
|
|
9
|
-
|
8
|
+
## Service Configuration
|
9
|
+
|
10
|
+
Below is a sample puma.service configuration file for systemd, which
|
11
|
+
can be copied or symlinked to /etc/systemd/system/puma.service, or if
|
12
|
+
desired, using an application or instance specific name.
|
13
|
+
|
14
|
+
Note that this uses the systemd preferred "simple" type where the
|
15
|
+
start command remains running in the foreground (does not fork and
|
16
|
+
exit). See also, the
|
17
|
+
[Alternative Forking Configuration](#alternative-forking-configuration)
|
18
|
+
below.
|
19
|
+
|
20
|
+
~~~~ ini
|
10
21
|
[Unit]
|
11
22
|
Description=Puma HTTP Server
|
12
23
|
After=network.target
|
@@ -21,22 +32,21 @@ Type=simple
|
|
21
32
|
# Preferably configure a non-privileged user
|
22
33
|
# User=
|
23
34
|
|
24
|
-
#
|
25
|
-
#
|
35
|
+
# The path to the puma application root
|
36
|
+
# Also replace the "<WD>" place holders below with this path.
|
37
|
+
WorkingDirectory=
|
26
38
|
|
27
39
|
# Helpful for debugging socket activation, etc.
|
28
40
|
# Environment=PUMA_DEBUG=1
|
29
41
|
|
30
|
-
# The command to start Puma
|
31
|
-
#
|
32
|
-
#
|
33
|
-
|
34
|
-
|
35
|
-
#
|
36
|
-
|
37
|
-
# Alternatively with a config file (in WorkingDirectory) and
|
38
|
-
# comparable `bind` directives
|
42
|
+
# The command to start Puma. This variant uses a binstub generated via
|
43
|
+
# `bundle binstubs puma --path ./sbin` in the WorkingDirectory
|
44
|
+
# (replace "<WD>" below)
|
45
|
+
ExecStart=<WD>/sbin/puma -b tcp://0.0.0.0:9292 -b ssl://0.0.0.0:9293?key=key.pem&cert=cert.pem
|
46
|
+
|
47
|
+
# Variant: Use config file with `bind` directives instead:
|
39
48
|
# ExecStart=<WD>/sbin/puma -C config.rb
|
49
|
+
# Variant: Use `bundle exec --keep-file-descriptors puma` instead of binstub
|
40
50
|
|
41
51
|
Restart=always
|
42
52
|
|
@@ -50,14 +60,22 @@ for additional details.
|
|
50
60
|
## Socket Activation
|
51
61
|
|
52
62
|
systemd and puma also support socket activation, where systemd opens
|
53
|
-
the listening socket(s) in advance and provides them to the puma
|
54
|
-
process on startup. Among other advantages, this keeps
|
55
|
-
sockets open across puma restarts and achieves graceful
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
63
|
+
the listening socket(s) in advance and provides them to the puma
|
64
|
+
master process on startup. Among other advantages, this keeps
|
65
|
+
listening sockets open across puma restarts and achieves graceful
|
66
|
+
restarts, including when upgraded puma, and is compatible with both
|
67
|
+
clustered mode and application preload.
|
68
|
+
|
69
|
+
**Note:** Socket activation doesn't currently work on jruby. This is
|
70
|
+
tracked in [#1367].
|
71
|
+
|
72
|
+
To use socket activation, configure one or more `ListenStream` sockets
|
73
|
+
in a companion `*.socket` unit file. Also uncomment the associated
|
74
|
+
`Requires` directive for the socket unit in the service file (see
|
75
|
+
above.) Here is a sample puma.socket, matching the ports used in the
|
76
|
+
above puma.service:
|
77
|
+
|
78
|
+
~~~~ ini
|
61
79
|
[Unit]
|
62
80
|
Description=Puma HTTP Server Accept Sockets
|
63
81
|
|
@@ -169,29 +187,76 @@ Apr 07 08:40:19 hx puma[28320]: * Activated ssl://0.0.0.0:9234?key=key.pem&cert=
|
|
169
187
|
Apr 07 08:40:19 hx puma[28320]: Use Ctrl-C to stop
|
170
188
|
~~~~
|
171
189
|
|
172
|
-
## Alternative
|
173
|
-
|
174
|
-
|
190
|
+
## Alternative Forking Configuration
|
191
|
+
|
192
|
+
Other systems/tools might expect or need puma to be run as a
|
193
|
+
"traditional" forking server, for example so that the `pumactl`
|
194
|
+
command can be used directly and outside of systemd for
|
195
|
+
stop/start/restart. This use case is incompatible with systemd socket
|
196
|
+
activation, so it should not be configured. Below is an alternative
|
197
|
+
puma.service config sample, using `Type=forking` and the `--daemon`
|
198
|
+
flag in `ExecStart`. Here systemd is playing a role more equivalent to
|
199
|
+
SysV init.d, where it is responsible for starting Puma on boot
|
200
|
+
(multi-user.target) and stopping it on shutdown, but is not performing
|
201
|
+
continuous restarts. Therefore running Puma in cluster mode, where the
|
202
|
+
master can restart workers, is highly recommended. See the systemd
|
203
|
+
[Restart] directive for details.
|
204
|
+
|
205
|
+
~~~~ ini
|
206
|
+
[Unit]
|
207
|
+
Description=Puma HTTP Forking Server
|
208
|
+
After=network.target
|
175
209
|
|
176
|
-
~~~~
|
177
210
|
[Service]
|
178
211
|
# Background process configuration (use with --daemon in ExecStart)
|
179
212
|
Type=forking
|
180
213
|
|
181
|
-
#
|
182
|
-
#
|
183
|
-
|
184
|
-
#
|
185
|
-
# path.
|
214
|
+
# Preferably configure a non-privileged user
|
215
|
+
# User=
|
216
|
+
|
217
|
+
# The path to the puma application root
|
218
|
+
# Also replace the "<WD>" place holders below with this path.
|
219
|
+
WorkingDirectory=
|
220
|
+
|
221
|
+
# The command to start Puma
|
222
|
+
# (replace "<WD>" below)
|
186
223
|
ExecStart=bundle exec puma -C <WD>/shared/puma.rb --daemon
|
187
224
|
|
188
|
-
#
|
189
|
-
#
|
190
|
-
# may differ from this example, for example if you use a Ruby version
|
191
|
-
# manager. `<WD>` is short for "your working directory". Replace it with your
|
192
|
-
# path.
|
225
|
+
# The command to stop Puma
|
226
|
+
# (replace "<WD>" below)
|
193
227
|
ExecStop=bundle exec pumactl -S <WD>/shared/tmp/pids/puma.state stop
|
194
228
|
|
195
|
-
#
|
229
|
+
# Path to PID file so that systemd knows which is the master process
|
196
230
|
PIDFile=<WD>/shared/tmp/pids/puma.pid
|
231
|
+
|
232
|
+
# Should systemd restart puma?
|
233
|
+
# Use "no" (the default) to ensure no interference when using
|
234
|
+
# stop/start/restart via `pumactl`. The "on-failure" setting might
|
235
|
+
# work better for this purpose, but you must test it.
|
236
|
+
# Use "always" if only `systemctl` is used for start/stop/restart, and
|
237
|
+
# reconsider if you actually need the forking config.
|
238
|
+
Restart=no
|
239
|
+
|
240
|
+
[Install]
|
241
|
+
WantedBy=multi-user.target
|
197
242
|
~~~~
|
243
|
+
|
244
|
+
### capistrano3-puma
|
245
|
+
|
246
|
+
By default,
|
247
|
+
[capistrano3-puma](https://github.com/seuros/capistrano-puma) uses
|
248
|
+
`pumactl` for deployment restarts, outside of systemd. To learn the
|
249
|
+
exact commands that this tool would use for `ExecStart` and
|
250
|
+
`ExecStop`, use the following `cap` commands in dry-run mode, and
|
251
|
+
update from the above forking service configuration accordingly. Note
|
252
|
+
also that the configured `User` should likely be the same as the
|
253
|
+
capistrano3-puma `:puma_user` option.
|
254
|
+
|
255
|
+
~~~~ sh
|
256
|
+
stage=production # or different stage, as needed
|
257
|
+
cap $stage puma:start --dry-run
|
258
|
+
cap $stage puma:stop --dry-run
|
259
|
+
~~~~
|
260
|
+
|
261
|
+
[Restart]: https://www.freedesktop.org/software/systemd/man/systemd.service.html#Restart=
|
262
|
+
[#1367]: https://github.com/puma/puma/issues/1367
|
@@ -31,30 +31,27 @@ static void snake_upcase_char(char *c)
|
|
31
31
|
/** Machine **/
|
32
32
|
|
33
33
|
|
34
|
-
#line
|
34
|
+
#line 79 "ext/puma_http11/http11_parser.rl"
|
35
35
|
|
36
36
|
|
37
37
|
/** Data **/
|
38
38
|
|
39
|
-
#line
|
39
|
+
#line 40 "ext/puma_http11/http11_parser.c"
|
40
40
|
static const int puma_parser_start = 1;
|
41
41
|
static const int puma_parser_first_final = 47;
|
42
42
|
static const int puma_parser_error = 0;
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
#line 82 "ext/puma_http11/http11_parser.rl"
|
44
|
+
#line 83 "ext/puma_http11/http11_parser.rl"
|
48
45
|
|
49
46
|
int puma_parser_init(puma_parser *parser) {
|
50
47
|
int cs = 0;
|
51
|
-
|
52
|
-
#line
|
48
|
+
|
49
|
+
#line 53 "ext/puma_http11/http11_parser.c"
|
53
50
|
{
|
54
51
|
cs = puma_parser_start;
|
55
52
|
}
|
56
53
|
|
57
|
-
#line
|
54
|
+
#line 87 "ext/puma_http11/http11_parser.rl"
|
58
55
|
parser->cs = cs;
|
59
56
|
parser->body_start = 0;
|
60
57
|
parser->content_len = 0;
|
@@ -74,16 +71,10 @@ size_t puma_parser_execute(puma_parser *parser, const char *buffer, size_t len,
|
|
74
71
|
const char *p, *pe;
|
75
72
|
int cs = parser->cs;
|
76
73
|
|
77
|
-
assert(off <= len && "offset past end of buffer");
|
78
|
-
|
79
74
|
p = buffer+off;
|
80
75
|
pe = buffer+len;
|
81
76
|
|
82
|
-
|
83
|
-
assert(pe - p == len - off && "pointers aren't same distance");
|
84
|
-
|
85
|
-
|
86
|
-
#line 86 "ext/puma_http11/http11_parser.c"
|
77
|
+
#line 87 "ext/puma_http11/http11_parser.c"
|
87
78
|
{
|
88
79
|
if ( p == pe )
|
89
80
|
goto _test_eof;
|
@@ -107,14 +98,14 @@ st0:
|
|
107
98
|
cs = 0;
|
108
99
|
goto _out;
|
109
100
|
tr0:
|
110
|
-
#line
|
101
|
+
#line 35 "ext/puma_http11/http11_parser.rl"
|
111
102
|
{ MARK(mark, p); }
|
112
103
|
goto st2;
|
113
104
|
st2:
|
114
105
|
if ( ++p == pe )
|
115
106
|
goto _test_eof2;
|
116
107
|
case 2:
|
117
|
-
#line
|
108
|
+
#line 118 "ext/puma_http11/http11_parser.c"
|
118
109
|
switch( (*p) ) {
|
119
110
|
case 32: goto tr2;
|
120
111
|
case 36: goto st28;
|
@@ -130,8 +121,8 @@ case 2:
|
|
130
121
|
goto st28;
|
131
122
|
goto st0;
|
132
123
|
tr2:
|
133
|
-
#line
|
134
|
-
{
|
124
|
+
#line 48 "ext/puma_http11/http11_parser.rl"
|
125
|
+
{
|
135
126
|
parser->request_method(parser, PTR_TO(mark), LEN(mark, p));
|
136
127
|
}
|
137
128
|
goto st3;
|
@@ -139,7 +130,7 @@ st3:
|
|
139
130
|
if ( ++p == pe )
|
140
131
|
goto _test_eof3;
|
141
132
|
case 3:
|
142
|
-
#line
|
133
|
+
#line 143 "ext/puma_http11/http11_parser.c"
|
143
134
|
switch( (*p) ) {
|
144
135
|
case 42: goto tr4;
|
145
136
|
case 43: goto tr5;
|
@@ -156,68 +147,68 @@ case 3:
|
|
156
147
|
goto tr5;
|
157
148
|
goto st0;
|
158
149
|
tr4:
|
159
|
-
#line
|
150
|
+
#line 35 "ext/puma_http11/http11_parser.rl"
|
160
151
|
{ MARK(mark, p); }
|
161
152
|
goto st4;
|
162
153
|
st4:
|
163
154
|
if ( ++p == pe )
|
164
155
|
goto _test_eof4;
|
165
156
|
case 4:
|
166
|
-
#line
|
157
|
+
#line 167 "ext/puma_http11/http11_parser.c"
|
167
158
|
switch( (*p) ) {
|
168
159
|
case 32: goto tr8;
|
169
160
|
case 35: goto tr9;
|
170
161
|
}
|
171
162
|
goto st0;
|
172
163
|
tr8:
|
173
|
-
#line
|
174
|
-
{
|
164
|
+
#line 51 "ext/puma_http11/http11_parser.rl"
|
165
|
+
{
|
175
166
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
176
167
|
}
|
177
168
|
goto st5;
|
178
169
|
tr31:
|
179
|
-
#line
|
170
|
+
#line 35 "ext/puma_http11/http11_parser.rl"
|
180
171
|
{ MARK(mark, p); }
|
181
|
-
#line
|
172
|
+
#line 54 "ext/puma_http11/http11_parser.rl"
|
182
173
|
{
|
183
174
|
parser->fragment(parser, PTR_TO(mark), LEN(mark, p));
|
184
175
|
}
|
185
176
|
goto st5;
|
186
177
|
tr33:
|
187
|
-
#line
|
178
|
+
#line 54 "ext/puma_http11/http11_parser.rl"
|
188
179
|
{
|
189
180
|
parser->fragment(parser, PTR_TO(mark), LEN(mark, p));
|
190
181
|
}
|
191
182
|
goto st5;
|
192
183
|
tr37:
|
193
|
-
#line
|
184
|
+
#line 67 "ext/puma_http11/http11_parser.rl"
|
194
185
|
{
|
195
186
|
parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
|
196
187
|
}
|
197
|
-
#line
|
198
|
-
{
|
188
|
+
#line 51 "ext/puma_http11/http11_parser.rl"
|
189
|
+
{
|
199
190
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
200
191
|
}
|
201
192
|
goto st5;
|
202
193
|
tr44:
|
203
|
-
#line 57 "ext/puma_http11/http11_parser.rl"
|
204
|
-
{ MARK(query_start, p); }
|
205
194
|
#line 58 "ext/puma_http11/http11_parser.rl"
|
206
|
-
{
|
195
|
+
{ MARK(query_start, p); }
|
196
|
+
#line 59 "ext/puma_http11/http11_parser.rl"
|
197
|
+
{
|
207
198
|
parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
|
208
199
|
}
|
209
|
-
#line
|
210
|
-
{
|
200
|
+
#line 51 "ext/puma_http11/http11_parser.rl"
|
201
|
+
{
|
211
202
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
212
203
|
}
|
213
204
|
goto st5;
|
214
205
|
tr47:
|
215
|
-
#line
|
216
|
-
{
|
206
|
+
#line 59 "ext/puma_http11/http11_parser.rl"
|
207
|
+
{
|
217
208
|
parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
|
218
209
|
}
|
219
|
-
#line
|
220
|
-
{
|
210
|
+
#line 51 "ext/puma_http11/http11_parser.rl"
|
211
|
+
{
|
221
212
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
222
213
|
}
|
223
214
|
goto st5;
|
@@ -225,19 +216,19 @@ st5:
|
|
225
216
|
if ( ++p == pe )
|
226
217
|
goto _test_eof5;
|
227
218
|
case 5:
|
228
|
-
#line
|
219
|
+
#line 229 "ext/puma_http11/http11_parser.c"
|
229
220
|
if ( (*p) == 72 )
|
230
221
|
goto tr10;
|
231
222
|
goto st0;
|
232
223
|
tr10:
|
233
|
-
#line
|
224
|
+
#line 35 "ext/puma_http11/http11_parser.rl"
|
234
225
|
{ MARK(mark, p); }
|
235
226
|
goto st6;
|
236
227
|
st6:
|
237
228
|
if ( ++p == pe )
|
238
229
|
goto _test_eof6;
|
239
230
|
case 6:
|
240
|
-
#line
|
231
|
+
#line 241 "ext/puma_http11/http11_parser.c"
|
241
232
|
if ( (*p) == 84 )
|
242
233
|
goto st7;
|
243
234
|
goto st0;
|
@@ -295,21 +286,21 @@ case 13:
|
|
295
286
|
goto st13;
|
296
287
|
goto st0;
|
297
288
|
tr18:
|
298
|
-
#line
|
299
|
-
{
|
289
|
+
#line 63 "ext/puma_http11/http11_parser.rl"
|
290
|
+
{
|
300
291
|
parser->http_version(parser, PTR_TO(mark), LEN(mark, p));
|
301
292
|
}
|
302
293
|
goto st14;
|
303
294
|
tr26:
|
304
|
-
#line 43 "ext/puma_http11/http11_parser.rl"
|
305
|
-
{ MARK(mark, p); }
|
306
295
|
#line 44 "ext/puma_http11/http11_parser.rl"
|
296
|
+
{ MARK(mark, p); }
|
297
|
+
#line 45 "ext/puma_http11/http11_parser.rl"
|
307
298
|
{
|
308
299
|
parser->http_field(parser, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
|
309
300
|
}
|
310
301
|
goto st14;
|
311
302
|
tr29:
|
312
|
-
#line
|
303
|
+
#line 45 "ext/puma_http11/http11_parser.rl"
|
313
304
|
{
|
314
305
|
parser->http_field(parser, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
|
315
306
|
}
|
@@ -318,7 +309,7 @@ st14:
|
|
318
309
|
if ( ++p == pe )
|
319
310
|
goto _test_eof14;
|
320
311
|
case 14:
|
321
|
-
#line
|
312
|
+
#line 322 "ext/puma_http11/http11_parser.c"
|
322
313
|
if ( (*p) == 10 )
|
323
314
|
goto st15;
|
324
315
|
goto st0;
|
@@ -358,9 +349,9 @@ case 16:
|
|
358
349
|
goto tr22;
|
359
350
|
goto st0;
|
360
351
|
tr22:
|
361
|
-
#line
|
362
|
-
{
|
363
|
-
parser->body_start = p - buffer + 1;
|
352
|
+
#line 71 "ext/puma_http11/http11_parser.rl"
|
353
|
+
{
|
354
|
+
parser->body_start = p - buffer + 1;
|
364
355
|
parser->header_done(parser, p + 1, pe - p - 1);
|
365
356
|
{p++; cs = 47; goto _out;}
|
366
357
|
}
|
@@ -369,23 +360,23 @@ st47:
|
|
369
360
|
if ( ++p == pe )
|
370
361
|
goto _test_eof47;
|
371
362
|
case 47:
|
372
|
-
#line
|
363
|
+
#line 373 "ext/puma_http11/http11_parser.c"
|
373
364
|
goto st0;
|
374
365
|
tr21:
|
375
|
-
#line 37 "ext/puma_http11/http11_parser.rl"
|
376
|
-
{ MARK(field_start, p); }
|
377
366
|
#line 38 "ext/puma_http11/http11_parser.rl"
|
367
|
+
{ MARK(field_start, p); }
|
368
|
+
#line 39 "ext/puma_http11/http11_parser.rl"
|
378
369
|
{ snake_upcase_char((char *)p); }
|
379
370
|
goto st17;
|
380
371
|
tr23:
|
381
|
-
#line
|
372
|
+
#line 39 "ext/puma_http11/http11_parser.rl"
|
382
373
|
{ snake_upcase_char((char *)p); }
|
383
374
|
goto st17;
|
384
375
|
st17:
|
385
376
|
if ( ++p == pe )
|
386
377
|
goto _test_eof17;
|
387
378
|
case 17:
|
388
|
-
#line
|
379
|
+
#line 389 "ext/puma_http11/http11_parser.c"
|
389
380
|
switch( (*p) ) {
|
390
381
|
case 33: goto tr23;
|
391
382
|
case 58: goto tr24;
|
@@ -411,72 +402,72 @@ case 17:
|
|
411
402
|
goto tr23;
|
412
403
|
goto st0;
|
413
404
|
tr24:
|
414
|
-
#line
|
415
|
-
{
|
405
|
+
#line 40 "ext/puma_http11/http11_parser.rl"
|
406
|
+
{
|
416
407
|
parser->field_len = LEN(field_start, p);
|
417
408
|
}
|
418
409
|
goto st18;
|
419
410
|
tr27:
|
420
|
-
#line
|
411
|
+
#line 44 "ext/puma_http11/http11_parser.rl"
|
421
412
|
{ MARK(mark, p); }
|
422
413
|
goto st18;
|
423
414
|
st18:
|
424
415
|
if ( ++p == pe )
|
425
416
|
goto _test_eof18;
|
426
417
|
case 18:
|
427
|
-
#line
|
418
|
+
#line 428 "ext/puma_http11/http11_parser.c"
|
428
419
|
switch( (*p) ) {
|
429
420
|
case 13: goto tr26;
|
430
421
|
case 32: goto tr27;
|
431
422
|
}
|
432
423
|
goto tr25;
|
433
424
|
tr25:
|
434
|
-
#line
|
425
|
+
#line 44 "ext/puma_http11/http11_parser.rl"
|
435
426
|
{ MARK(mark, p); }
|
436
427
|
goto st19;
|
437
428
|
st19:
|
438
429
|
if ( ++p == pe )
|
439
430
|
goto _test_eof19;
|
440
431
|
case 19:
|
441
|
-
#line
|
432
|
+
#line 442 "ext/puma_http11/http11_parser.c"
|
442
433
|
if ( (*p) == 13 )
|
443
434
|
goto tr29;
|
444
435
|
goto st19;
|
445
436
|
tr9:
|
446
|
-
#line
|
447
|
-
{
|
437
|
+
#line 51 "ext/puma_http11/http11_parser.rl"
|
438
|
+
{
|
448
439
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
449
440
|
}
|
450
441
|
goto st20;
|
451
442
|
tr38:
|
452
|
-
#line
|
443
|
+
#line 67 "ext/puma_http11/http11_parser.rl"
|
453
444
|
{
|
454
445
|
parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
|
455
446
|
}
|
456
|
-
#line
|
457
|
-
{
|
447
|
+
#line 51 "ext/puma_http11/http11_parser.rl"
|
448
|
+
{
|
458
449
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
459
450
|
}
|
460
451
|
goto st20;
|
461
452
|
tr45:
|
462
|
-
#line 57 "ext/puma_http11/http11_parser.rl"
|
463
|
-
{ MARK(query_start, p); }
|
464
453
|
#line 58 "ext/puma_http11/http11_parser.rl"
|
465
|
-
{
|
454
|
+
{ MARK(query_start, p); }
|
455
|
+
#line 59 "ext/puma_http11/http11_parser.rl"
|
456
|
+
{
|
466
457
|
parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
|
467
458
|
}
|
468
|
-
#line
|
469
|
-
{
|
459
|
+
#line 51 "ext/puma_http11/http11_parser.rl"
|
460
|
+
{
|
470
461
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
471
462
|
}
|
472
463
|
goto st20;
|
473
464
|
tr48:
|
474
|
-
#line
|
475
|
-
{
|
465
|
+
#line 59 "ext/puma_http11/http11_parser.rl"
|
466
|
+
{
|
476
467
|
parser->query_string(parser, PTR_TO(query_start), LEN(query_start, p));
|
477
468
|
}
|
478
|
-
#line
|
479
|
-
{
|
469
|
+
#line 51 "ext/puma_http11/http11_parser.rl"
|
470
|
+
{
|
480
471
|
parser->request_uri(parser, PTR_TO(mark), LEN(mark, p));
|
481
472
|
}
|
482
473
|
goto st20;
|
@@ -484,7 +475,7 @@ st20:
|
|
484
475
|
if ( ++p == pe )
|
485
476
|
goto _test_eof20;
|
486
477
|
case 20:
|
487
|
-
#line
|
478
|
+
#line 488 "ext/puma_http11/http11_parser.c"
|
488
479
|
switch( (*p) ) {
|
489
480
|
case 32: goto tr31;
|
490
481
|
case 60: goto st0;
|
@@ -498,14 +489,14 @@ case 20:
|
|
498
489
|
goto st0;
|
499
490
|
goto tr30;
|
500
491
|
tr30:
|
501
|
-
#line
|
492
|
+
#line 35 "ext/puma_http11/http11_parser.rl"
|
502
493
|
{ MARK(mark, p); }
|
503
494
|
goto st21;
|
504
495
|
st21:
|
505
496
|
if ( ++p == pe )
|
506
497
|
goto _test_eof21;
|
507
498
|
case 21:
|
508
|
-
#line
|
499
|
+
#line 509 "ext/puma_http11/http11_parser.c"
|
509
500
|
switch( (*p) ) {
|
510
501
|
case 32: goto tr33;
|
511
502
|
case 60: goto st0;
|
@@ -519,14 +510,14 @@ case 21:
|
|
519
510
|
goto st0;
|
520
511
|
goto st21;
|
521
512
|
tr5:
|
522
|
-
#line
|
513
|
+
#line 35 "ext/puma_http11/http11_parser.rl"
|
523
514
|
{ MARK(mark, p); }
|
524
515
|
goto st22;
|
525
516
|
st22:
|
526
517
|
if ( ++p == pe )
|
527
518
|
goto _test_eof22;
|
528
519
|
case 22:
|
529
|
-
#line
|
520
|
+
#line 530 "ext/puma_http11/http11_parser.c"
|
530
521
|
switch( (*p) ) {
|
531
522
|
case 43: goto st22;
|
532
523
|
case 58: goto st23;
|
@@ -544,14 +535,14 @@ case 22:
|
|
544
535
|
goto st22;
|
545
536
|
goto st0;
|
546
537
|
tr7:
|
547
|
-
#line
|
538
|
+
#line 35 "ext/puma_http11/http11_parser.rl"
|
548
539
|
{ MARK(mark, p); }
|
549
540
|
goto st23;
|
550
541
|
st23:
|
551
542
|
if ( ++p == pe )
|
552
543
|
goto _test_eof23;
|
553
544
|
case 23:
|
554
|
-
#line
|
545
|
+
#line 555 "ext/puma_http11/http11_parser.c"
|
555
546
|
switch( (*p) ) {
|
556
547
|
case 32: goto tr8;
|
557
548
|
case 34: goto st0;
|
@@ -564,14 +555,14 @@ case 23:
|
|
564
555
|
goto st0;
|
565
556
|
goto st23;
|
566
557
|
tr6:
|
567
|
-
#line
|
558
|
+
#line 35 "ext/puma_http11/http11_parser.rl"
|
568
559
|
{ MARK(mark, p); }
|
569
560
|
goto st24;
|
570
561
|
st24:
|
571
562
|
if ( ++p == pe )
|
572
563
|
goto _test_eof24;
|
573
564
|
case 24:
|
574
|
-
#line
|
565
|
+
#line 575 "ext/puma_http11/http11_parser.c"
|
575
566
|
switch( (*p) ) {
|
576
567
|
case 32: goto tr37;
|
577
568
|
case 34: goto st0;
|
@@ -586,7 +577,7 @@ case 24:
|
|
586
577
|
goto st0;
|
587
578
|
goto st24;
|
588
579
|
tr39:
|
589
|
-
#line
|
580
|
+
#line 67 "ext/puma_http11/http11_parser.rl"
|
590
581
|
{
|
591
582
|
parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
|
592
583
|
}
|
@@ -595,7 +586,7 @@ st25:
|
|
595
586
|
if ( ++p == pe )
|
596
587
|
goto _test_eof25;
|
597
588
|
case 25:
|
598
|
-
#line
|
589
|
+
#line 599 "ext/puma_http11/http11_parser.c"
|
599
590
|
switch( (*p) ) {
|
600
591
|
case 32: goto tr8;
|
601
592
|
case 34: goto st0;
|
@@ -609,7 +600,7 @@ case 25:
|
|
609
600
|
goto st0;
|
610
601
|
goto st25;
|
611
602
|
tr40:
|
612
|
-
#line
|
603
|
+
#line 67 "ext/puma_http11/http11_parser.rl"
|
613
604
|
{
|
614
605
|
parser->request_path(parser, PTR_TO(mark), LEN(mark,p));
|
615
606
|
}
|
@@ -618,7 +609,7 @@ st26:
|
|
618
609
|
if ( ++p == pe )
|
619
610
|
goto _test_eof26;
|
620
611
|
case 26:
|
621
|
-
#line
|
612
|
+
#line 622 "ext/puma_http11/http11_parser.c"
|
622
613
|
switch( (*p) ) {
|
623
614
|
case 32: goto tr44;
|
624
615
|
case 34: goto st0;
|
@@ -631,14 +622,14 @@ case 26:
|
|
631
622
|
goto st0;
|
632
623
|
goto tr43;
|
633
624
|
tr43:
|
634
|
-
#line
|
625
|
+
#line 58 "ext/puma_http11/http11_parser.rl"
|
635
626
|
{ MARK(query_start, p); }
|
636
627
|
goto st27;
|
637
628
|
st27:
|
638
629
|
if ( ++p == pe )
|
639
630
|
goto _test_eof27;
|
640
631
|
case 27:
|
641
|
-
#line
|
632
|
+
#line 642 "ext/puma_http11/http11_parser.c"
|
642
633
|
switch( (*p) ) {
|
643
634
|
case 32: goto tr47;
|
644
635
|
case 34: goto st0;
|
@@ -982,70 +973,63 @@ case 46:
|
|
982
973
|
goto tr2;
|
983
974
|
goto st0;
|
984
975
|
}
|
985
|
-
_test_eof2: cs = 2; goto _test_eof;
|
986
|
-
_test_eof3: cs = 3; goto _test_eof;
|
987
|
-
_test_eof4: cs = 4; goto _test_eof;
|
988
|
-
_test_eof5: cs = 5; goto _test_eof;
|
989
|
-
_test_eof6: cs = 6; goto _test_eof;
|
990
|
-
_test_eof7: cs = 7; goto _test_eof;
|
991
|
-
_test_eof8: cs = 8; goto _test_eof;
|
992
|
-
_test_eof9: cs = 9; goto _test_eof;
|
993
|
-
_test_eof10: cs = 10; goto _test_eof;
|
994
|
-
_test_eof11: cs = 11; goto _test_eof;
|
995
|
-
_test_eof12: cs = 12; goto _test_eof;
|
996
|
-
_test_eof13: cs = 13; goto _test_eof;
|
997
|
-
_test_eof14: cs = 14; goto _test_eof;
|
998
|
-
_test_eof15: cs = 15; goto _test_eof;
|
999
|
-
_test_eof16: cs = 16; goto _test_eof;
|
1000
|
-
_test_eof47: cs = 47; goto _test_eof;
|
1001
|
-
_test_eof17: cs = 17; goto _test_eof;
|
1002
|
-
_test_eof18: cs = 18; goto _test_eof;
|
1003
|
-
_test_eof19: cs = 19; goto _test_eof;
|
1004
|
-
_test_eof20: cs = 20; goto _test_eof;
|
1005
|
-
_test_eof21: cs = 21; goto _test_eof;
|
1006
|
-
_test_eof22: cs = 22; goto _test_eof;
|
1007
|
-
_test_eof23: cs = 23; goto _test_eof;
|
1008
|
-
_test_eof24: cs = 24; goto _test_eof;
|
1009
|
-
_test_eof25: cs = 25; goto _test_eof;
|
1010
|
-
_test_eof26: cs = 26; goto _test_eof;
|
1011
|
-
_test_eof27: cs = 27; goto _test_eof;
|
1012
|
-
_test_eof28: cs = 28; goto _test_eof;
|
1013
|
-
_test_eof29: cs = 29; goto _test_eof;
|
1014
|
-
_test_eof30: cs = 30; goto _test_eof;
|
1015
|
-
_test_eof31: cs = 31; goto _test_eof;
|
1016
|
-
_test_eof32: cs = 32; goto _test_eof;
|
1017
|
-
_test_eof33: cs = 33; goto _test_eof;
|
1018
|
-
_test_eof34: cs = 34; goto _test_eof;
|
1019
|
-
_test_eof35: cs = 35; goto _test_eof;
|
1020
|
-
_test_eof36: cs = 36; goto _test_eof;
|
1021
|
-
_test_eof37: cs = 37; goto _test_eof;
|
1022
|
-
_test_eof38: cs = 38; goto _test_eof;
|
1023
|
-
_test_eof39: cs = 39; goto _test_eof;
|
1024
|
-
_test_eof40: cs = 40; goto _test_eof;
|
1025
|
-
_test_eof41: cs = 41; goto _test_eof;
|
1026
|
-
_test_eof42: cs = 42; goto _test_eof;
|
1027
|
-
_test_eof43: cs = 43; goto _test_eof;
|
1028
|
-
_test_eof44: cs = 44; goto _test_eof;
|
1029
|
-
_test_eof45: cs = 45; goto _test_eof;
|
1030
|
-
_test_eof46: cs = 46; goto _test_eof;
|
976
|
+
_test_eof2: cs = 2; goto _test_eof;
|
977
|
+
_test_eof3: cs = 3; goto _test_eof;
|
978
|
+
_test_eof4: cs = 4; goto _test_eof;
|
979
|
+
_test_eof5: cs = 5; goto _test_eof;
|
980
|
+
_test_eof6: cs = 6; goto _test_eof;
|
981
|
+
_test_eof7: cs = 7; goto _test_eof;
|
982
|
+
_test_eof8: cs = 8; goto _test_eof;
|
983
|
+
_test_eof9: cs = 9; goto _test_eof;
|
984
|
+
_test_eof10: cs = 10; goto _test_eof;
|
985
|
+
_test_eof11: cs = 11; goto _test_eof;
|
986
|
+
_test_eof12: cs = 12; goto _test_eof;
|
987
|
+
_test_eof13: cs = 13; goto _test_eof;
|
988
|
+
_test_eof14: cs = 14; goto _test_eof;
|
989
|
+
_test_eof15: cs = 15; goto _test_eof;
|
990
|
+
_test_eof16: cs = 16; goto _test_eof;
|
991
|
+
_test_eof47: cs = 47; goto _test_eof;
|
992
|
+
_test_eof17: cs = 17; goto _test_eof;
|
993
|
+
_test_eof18: cs = 18; goto _test_eof;
|
994
|
+
_test_eof19: cs = 19; goto _test_eof;
|
995
|
+
_test_eof20: cs = 20; goto _test_eof;
|
996
|
+
_test_eof21: cs = 21; goto _test_eof;
|
997
|
+
_test_eof22: cs = 22; goto _test_eof;
|
998
|
+
_test_eof23: cs = 23; goto _test_eof;
|
999
|
+
_test_eof24: cs = 24; goto _test_eof;
|
1000
|
+
_test_eof25: cs = 25; goto _test_eof;
|
1001
|
+
_test_eof26: cs = 26; goto _test_eof;
|
1002
|
+
_test_eof27: cs = 27; goto _test_eof;
|
1003
|
+
_test_eof28: cs = 28; goto _test_eof;
|
1004
|
+
_test_eof29: cs = 29; goto _test_eof;
|
1005
|
+
_test_eof30: cs = 30; goto _test_eof;
|
1006
|
+
_test_eof31: cs = 31; goto _test_eof;
|
1007
|
+
_test_eof32: cs = 32; goto _test_eof;
|
1008
|
+
_test_eof33: cs = 33; goto _test_eof;
|
1009
|
+
_test_eof34: cs = 34; goto _test_eof;
|
1010
|
+
_test_eof35: cs = 35; goto _test_eof;
|
1011
|
+
_test_eof36: cs = 36; goto _test_eof;
|
1012
|
+
_test_eof37: cs = 37; goto _test_eof;
|
1013
|
+
_test_eof38: cs = 38; goto _test_eof;
|
1014
|
+
_test_eof39: cs = 39; goto _test_eof;
|
1015
|
+
_test_eof40: cs = 40; goto _test_eof;
|
1016
|
+
_test_eof41: cs = 41; goto _test_eof;
|
1017
|
+
_test_eof42: cs = 42; goto _test_eof;
|
1018
|
+
_test_eof43: cs = 43; goto _test_eof;
|
1019
|
+
_test_eof44: cs = 44; goto _test_eof;
|
1020
|
+
_test_eof45: cs = 45; goto _test_eof;
|
1021
|
+
_test_eof46: cs = 46; goto _test_eof;
|
1031
1022
|
|
1032
1023
|
_test_eof: {}
|
1033
1024
|
_out: {}
|
1034
1025
|
}
|
1035
1026
|
|
1036
|
-
#line
|
1027
|
+
#line 115 "ext/puma_http11/http11_parser.rl"
|
1037
1028
|
|
1038
1029
|
if (!puma_parser_has_error(parser))
|
1039
1030
|
parser->cs = cs;
|
1040
1031
|
parser->nread += p - (buffer + off);
|
1041
1032
|
|
1042
|
-
assert(p <= pe && "buffer overflow after parsing execute");
|
1043
|
-
assert(parser->nread <= len && "nread longer than length");
|
1044
|
-
assert(parser->body_start <= len && "body starts after buffer end");
|
1045
|
-
assert(parser->mark < len && "mark is after buffer end");
|
1046
|
-
assert(parser->field_len <= len && "field has length longer than whole buffer");
|
1047
|
-
assert(parser->field_start < len && "field starts after buffer end");
|
1048
|
-
|
1049
1033
|
return(parser->nread);
|
1050
1034
|
}
|
1051
1035
|
|