-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39771eb
commit 1af1ee4
Showing
5 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
diff --git src/ngx_http_lua_bodyfilterby.c src/ngx_http_lua_bodyfilterby.c | ||
index 9024889..88af761 100644 | ||
--- src/ngx_http_lua_bodyfilterby.c | ||
+++ src/ngx_http_lua_bodyfilterby.c | ||
@@ -22,6 +22,9 @@ | ||
#include "ngx_http_lua_misc.h" | ||
#include "ngx_http_lua_consts.h" | ||
#include "ngx_http_lua_output.h" | ||
+#if (NGX_HTTP_APISIX) | ||
+#include "ngx_http_apisix_module.h" | ||
+#endif | ||
|
||
|
||
static void ngx_http_lua_body_filter_by_lua_env(lua_State *L, | ||
@@ -241,6 +244,12 @@ ngx_http_lua_body_filter(ngx_http_request_t *r, ngx_chain_t *in) | ||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | ||
"lua body filter for user lua code, uri \"%V\"", &r->uri); | ||
|
||
+#if (NGX_HTTP_APISIX) | ||
+ if (ngx_http_apisix_is_body_filter_by_lua_skipped(r)) { | ||
+ return ngx_http_next_body_filter(r, in); | ||
+ } | ||
+#endif | ||
+ | ||
llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module); | ||
|
||
if (llcf->body_filter_handler == NULL || r->header_only) { | ||
diff --git src/ngx_http_lua_headerfilterby.c src/ngx_http_lua_headerfilterby.c | ||
index ed0c3a6..5f04992 100644 | ||
--- src/ngx_http_lua_headerfilterby.c | ||
+++ src/ngx_http_lua_headerfilterby.c | ||
@@ -19,6 +19,9 @@ | ||
#include "ngx_http_lua_string.h" | ||
#include "ngx_http_lua_misc.h" | ||
#include "ngx_http_lua_consts.h" | ||
+#if (NGX_HTTP_APISIX) | ||
+#include "ngx_http_apisix_module.h" | ||
+#endif | ||
|
||
|
||
static ngx_http_output_header_filter_pt ngx_http_next_header_filter; | ||
@@ -80,6 +83,12 @@ ngx_http_lua_header_filter_by_chunk(lua_State *L, ngx_http_request_t *r) | ||
#endif | ||
ngx_http_lua_ctx_t *ctx; | ||
|
||
+#if (NGX_HTTP_APISIX) | ||
+ if (ngx_http_apisix_is_header_filter_by_lua_skipped(r)) { | ||
+ return NGX_OK; | ||
+ } | ||
+#endif | ||
+ | ||
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module); | ||
if (ctx->exited) { | ||
old_exit_code = ctx->exit_code; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use t::APISIX_NGINX 'no_plan'; | ||
|
||
run_tests; | ||
|
||
__DATA__ | ||
|
||
=== TEST 1: skip header_filter_by_lua | ||
--- config | ||
location /t { | ||
access_by_lua_block { | ||
local resp = require("resty.apisix.response") | ||
assert(resp.skip_header_filter_by_lua()) | ||
|
||
ngx.header["Test"] = "one" | ||
ngx.say("ok") | ||
} | ||
header_filter_by_lua_block { | ||
ngx.header["Test"] = "two" | ||
} | ||
} | ||
--- response_headers | ||
Test: one | ||
|
||
|
||
|
||
=== TEST 2: skip body_filter_by_lua | ||
--- config | ||
location /t { | ||
access_by_lua_block { | ||
local resp = require("resty.apisix.response") | ||
assert(resp.skip_body_filter_by_lua()) | ||
|
||
ngx.say("ok") | ||
} | ||
body_filter_by_lua_block { | ||
ngx.arg[1] = "no" | ||
ngx.arg[2] = true | ||
} | ||
} | ||
--- response_body | ||
ok |