You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by mo...@apache.org on 2023/05/24 04:03:49 UTC
[apisix] branch master updated: fix(http-logger): default request path should be '/' (#9472)
This is an automated email from the ASF dual-hosted git repository.
monkeydluffy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 59b82e228 fix(http-logger): default request path should be '/' (#9472)
59b82e228 is described below
commit 59b82e2284311c0084dc0770261ea45624c8bec3
Author: Tristan <ji...@foxmail.com>
AuthorDate: Wed May 24 12:03:42 2023 +0800
fix(http-logger): default request path should be '/' (#9472)
---
apisix/plugins/http-logger.lua | 2 +-
t/plugin/http-logger2.t | 52 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/apisix/plugins/http-logger.lua b/apisix/plugins/http-logger.lua
index 399d50da1..5dd52240f 100644
--- a/apisix/plugins/http-logger.lua
+++ b/apisix/plugins/http-logger.lua
@@ -122,7 +122,7 @@ local function send_http_data(conf, log_message)
local httpc_res, httpc_err = httpc:request({
method = "POST",
- path = url_decoded.path,
+ path = #url_decoded.path ~= 0 and url_decoded.path or "/",
query = url_decoded.query,
body = log_message,
headers = {
diff --git a/t/plugin/http-logger2.t b/t/plugin/http-logger2.t
index 09572439c..12ee8b437 100644
--- a/t/plugin/http-logger2.t
+++ b/t/plugin/http-logger2.t
@@ -88,6 +88,12 @@ add_block_preprocessor(sub {
end
}
}
+
+ location / {
+ content_by_lua_block {
+ ngx.log(ngx.WARN, "test http logger for root path")
+ }
+ }
}
_EOC_
@@ -305,3 +311,49 @@ test-http-logger-request
--- error_log
received Authorization header: [nil]
--- wait: 1.5
+
+
+
+=== TEST 10: add default path
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+ local code, body = t('/apisix/admin/routes/1',
+ ngx.HTTP_PUT,
+ [[{
+ "plugins": {
+ "http-logger": {
+ "uri": "http://127.0.0.1:12001",
+ "batch_max_size": 1,
+ "max_retry_count": 1,
+ "retry_delay": 2,
+ "buffer_duration": 2,
+ "inactive_timeout": 2
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:12001": 1
+ },
+ "type": "roundrobin"
+ },
+ "uri": "/http-logger/test"
+ }]])
+
+ if code >= 300 then
+ ngx.status = code
+ end
+ ngx.say(body)
+ }
+ }
+--- response_body
+passed
+
+
+
+=== TEST 11: hit
+--- request
+GET /http-logger/test
+--- error_log
+test http logger for root path