Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(http-logger): default request path should be '/' #9472

Merged
merged 2 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apisix/plugins/http-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
52 changes: 52 additions & 0 deletions t/plugin/http-logger2.t
Original file line number Diff line number Diff line change
Expand Up @@ -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_

Expand Down Expand Up @@ -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