The client uses Content-Type:application/x-www-form-urlencoded to access the HTTP API. After decrypting the body to json, I reset the request header by r.Header().Set("Content-Type", "application/json;charset=UTF-8"), but found that it sometimes does not work.
I have attempted to request 100 times, but there are 9 cases where it does not take effect
the code of plugin:
r.Header().Set("Content-Type", "application/json;charset=UTF-8")
r.SetBody(origBodyByte)
// pluginLogger is a wrapper for log that can output traceId
pluginLogger.Infof("request get Content-Type: %s", r.Header().Get("Content-Type"))
the log of the plugin:
2024/01/09 20:15:00 [warn] 302#302: *913 [lua] init.lua:961: 2024-01-09T20:15:00.941+0800 INFO pluginlogger/logger.go:34
[00-3334f5bcb64c9c9cdf0da1997a9a81b6-5ff503ca821603ae-01] request get Content-Type: application/json;charset=UTF-8
Issue description
The client uses
Content-Type:application/x-www-form-urlencoded
to access the HTTP API. After decrypting the body to json, I reset the request header byr.Header().Set("Content-Type", "application/json;charset=UTF-8")
, but found that it sometimes does not work.I have attempted to request 100 times, but there are 9 cases where it does not take effect
the code of plugin:
the log of the plugin:
the log of http api:
Is there anyone who can help explain the reason?
Environment