kingmouse-yx opened a new issue, #6932:
URL: https://github.com/apache/apisix/issues/6932
### Current Behavior
In the rewrite phase, modifying the http request mode will cause multiple
request calls
I customized a plug-in, and in the rewrite phase, I rewritten the request
method and uri_args of this request. Here is my code:
```lua
-- 将ng中的请求数据换成转换完成的数据
local req_data_uri_args_json = core.json.decode(req_data_format)
log.warn(type(req_data_uri_args_json))
ngx.req.set_method(ngx.HTTP_GET)
ngx.req.set_uri_args(req_data_uri_args_json)
log.warn("设置之后的请求方法:",ngx.req.get_method())
```
But when I tested it, I found that apisix would make multiple requests. At
the same time, I found a lot of such request information in the access.log:
```log
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 504 175 6.009 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 504 6.002 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.880 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.872 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.922 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.916 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.939 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.930 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 504 175 6.009 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 504 6.003 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 6.004 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.996 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 504 175 6.009 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 504 6.003 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.864 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.856 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.894 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.888 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.908 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.901 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.953 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.946 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.970 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.962 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.986 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.979 "http://127.0.0.1:9080"
```
I want to ask why my operation causes such problems in the rewrite phase?
> Note: This doesn't happen every time(most of the time). Sometimes, after
deleting the route and re-creating it, it may only initiate two requests, but
sometimes it is normal
### Expected Behavior
I can modify it in rewite phase without triggering multiple calls
### Error Logs
```log
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 504 175 6.009 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 504 6.002 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.880 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.872 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.922 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.916 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.939 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.930 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 504 175 6.009 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 504 6.003 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 6.004 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.996 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 504 175 6.009 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 504 6.003 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.864 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.856 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.894 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.888 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.908 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.901 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.953 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.946 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.970 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.962 "http://127.0.0.1:9080"
172.20.0.1 - - [26/Apr/2022:06:15:45 +0000] 127.0.0.1:9080 "POST
/get/basicinfo?type=abs&processId=1 HTTP/1.1" 400 241 5.986 "-"
"PostmanRuntime/7.28.2" 10.201.2.107:80 400 5.979 "http://127.0.0.1:9080"
```
### Steps to Reproduce
1.add upstream
2.add route, Enable custom plug-ins
3.access with apisix
### Environment
- apisix version (cmd: apisix version): 2.13.0-alpine
- OS (cmd: uname -a): Darwin kingmouse.local 21.4.0 Darwin Kernel Version
21.4.0: Mon Feb 21 20:36:53 PST 2022; root:xnu-8020.101.4~2/RELEASE_ARM64_T8101
arm64
- OpenResty / Nginx version (cmd: nginx -V or openresty -V):
openresty/1.19.3.1
- etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info
to get the info from server-info API): 3.4.0
- apisix-dashboard version, if have: 2.10.1
- the plugin runner version, if the issue is about a plugin runner (cmd:
depended on the kind of runner):
- luarocks version, if the issue is about installation (cmd: luarocks
--version):
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]