Skip to content

Commit 82f20cd

Browse files
committed
Initial Checkin
1 parent 2739575 commit 82f20cd

File tree

4 files changed

+698
-25
lines changed

4 files changed

+698
-25
lines changed

LICENSE

100644100755
Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
1-
BSD 2-Clause License
2-
3-
Copyright (c) 2022, Taymindis Woon
4-
All rights reserved.
5-
6-
Redistribution and use in source and binary forms, with or without
7-
modification, are permitted provided that the following conditions are met:
8-
9-
1. Redistributions of source code must retain the above copyright notice, this
10-
list of conditions and the following disclaimer.
11-
12-
2. Redistributions in binary form must reproduce the above copyright notice,
13-
this list of conditions and the following disclaimer in the documentation
14-
and/or other materials provided with the distribution.
15-
16-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1+
/**
2+
* @file ngx_http_if_request_body_module.c
3+
* @author taymindis <minikawoon99@gmail.com>
4+
* @date Sat MAR 26 12:06:52 2022
5+
*
6+
* @brief A nginx-if-request-body module for Nginx.
7+
*
8+
* @section LICENSE
9+
*
10+
* Copyright (c) 2022, Taymindis <minikawoon99@gmail.com>
11+
*
12+
* This module is licensed under the terms of the BSD license.
13+
*
14+
* Redistribution and use in source and binary forms, with or without
15+
* modification, are permitted provided that the following conditions are met:
16+
*
17+
* 1. Redistributions of source code must retain the above copyright notice, this
18+
* list of conditions and the following disclaimer.
19+
* 2. Redistributions in binary form must reproduce the above copyright notice,
20+
* this list of conditions and the following disclaimer in the documentation
21+
* and/or other materials provided with the distribution.
22+
*
23+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
27+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33+
*/

README

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Catch body filter module for nginx.
2+
3+
This is a test module, to check request body filters experimental
4+
machinery to be introduced.
5+
6+
Example:
7+
8+
```nginx
9+
error_page 418 =200 /welcome_if_request_body;
10+
location /welcome_if_request_body {
11+
add_header Content-Type text/plain;
12+
return 200 "welcome_if_request_body, you hit it";
13+
}
14+
15+
location = / {
16+
if_request_body on;
17+
return_status_if_body_eq "ASD" 418 on;
18+
return_status_if_body_eq "foo" 418;
19+
return_status_if_body_eq "john" 418;
20+
return_status_if_body_startswith "report" 418;
21+
return_status_if_body_contains "report" 418;
22+
return_status_if_body_regex "^[\d]+?abc" 418;
23+
proxy_pass http://localhost:7777;
24+
25+
}
26+
27+
```

config

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# (C) Taymindis Woon
2+
# Configuration for ngx_http_if_request_body_module.
3+
4+
ngx_addon_name="ngx_http_if_request_body_module"
5+
6+
if test -n "$ngx_module_link"; then
7+
ngx_module_type=HTTP
8+
ngx_module_name=$ngx_addon_name
9+
ngx_module_deps="$NGX_ADDON_DEPS"
10+
ngx_module_srcs="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_if_request_body_module.c"
11+
12+
. auto/module
13+
else
14+
HTTP_MODULES="$HTTP_MODULES $ngx_addon_name"
15+
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_if_request_body_module.c"
16+
# NGX_ADDON_DEPS="$NGX_ADDON_DEPS $HTTP_LINK_FUNC_DEPS"
17+
fi

0 commit comments

Comments
 (0)