Working delay body and tests.
Depends on rb->filter_need_buffering and rb->buffered, as well as
corresponding changes in the request body reading code to work.
Might not be the best solution, as current body reading code relies
on rb->buffered to be properly set at various stages. Notably,
rb->buffered must be cleared when calling the next filter, since
the save body filter relies on it. Possible future improvements:
implement last buffer checking in the save body filter instead of
checking for (rb->rest == 0 && !rb->buffered).
The code uses its own event to implement delay timer. To remove the timer
in case of abnormal request termination a cleanup handler is added. While
in theory it is possible to use a timer on c->read instead, this implies
additional changes to the request body reading code. Custom event was chosen
to reduce complexity of changes needed.
author |
Maxim Dounin <mdounin@mdounin.ru> |
date |
Fri, 20 Aug 2021 22:35:05 +0300 |
parents |
a386f95c5ae9 |
children |
|
rev |
line source |
0
|
1 Delay body filter module for nginx.
|
|
2
|
|
3 This is a test module, to check request body filters buffering
|
|
4 mechanism to be introduced.
|
|
5
|
|
6 Example:
|
|
7
|
|
8 location / {
|
|
9 delay_body 1s;
|
|
10 }
|
|
11
|
|
12 The module will delay the request body processing for the configured time.
|
|
13
|
|
14 To compile nginx with the delay body module, use the "--add-module <path>"
|
|
15 option of nginx configure.
|