You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/03/02 13:38:23 UTC
[GitHub] [apisix] starsz commented on a change in pull request #6487: test(http-logger): fetch request and response body test case
starsz commented on a change in pull request #6487:
URL: https://github.com/apache/apisix/pull/6487#discussion_r817697617
##########
File path: t/plugin/http-logger2.t
##########
@@ -32,6 +32,64 @@ add_block_preprocessor(sub {
$block->set_value("no_error_log", "[error]");
}
+ my $http_config = $block->http_config // <<_EOC_;
+ server {
+ listen 12001;
+
+ location /http-logger/test {
+ content_by_lua_block {
+ ngx.say("test-http-logger-response")
+ }
+ }
+
+ location /http-logger/center {
+ content_by_lua_block {
+ local function str_split(str, reps)
+ local str_list = {}
+ string.gsub(str, '[^' .. reps .. ']+', function(w)
+ table.insert(str_list, w)
+ end)
+ return str_list
+ end
+
+ local args = ngx.req.get_uri_args()
+ local query = args.query or nil
+ ngx.req.read_body()
+ local body = ngx.req.get_body_data()
+
+ if query then
+ if type(query) == "string" then
+ query = {query}
+ end
+
+ local data, err = require("cjson").decode(body)
Review comment:
Hi, Why do we need to decode the body?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org