zhangweidongyyl opened a new issue #5693:
URL: https://github.com/apache/apisix/issues/5693


   ### Issue description
   
   when i write plugin like response_rewrite ,curl can not return result, but 
the log is all right,this is why。response_rewrite plugin can right exec
   `
   
   do
   
   function _M.body_filter(conf, ctx)
   
       local function push_data(premature, uri,args,result)
           if premature then
               return
           end
           local httpc, err = http:new()
           if err then
               result = "fail create http conn"
           end
           httpc:set_timeout(time)
           httpc:set_timeout(connect_timeout,
                   send_timeout, read_timeout)
           local url = "http://"; .. host_str ..":" .. host_port
           local res, err = httpc:request_uri(url,{path = uri,query = args})
           if not res then
               result = "fail to request"
               core.log.error("failed to request : ", err)
               return
           end
           result = result .. res.body
           core.log.info("res.body:",res.body)                                  
             -- 输出响应体
           core.log.info("result:", result)
       end
       local ok, err = ngx.timer.at(0, push_data,ngx.var.uri, 
ngx.var.args,result)
       if err then
           ngx.log(ngx.ERR, "failed to create timer: ", err)
           return
       end
       if not ok then
           ngx.log(ngx.ERR, "failed to create timer: ", err)
           return
       end
       ngx.arg[1] = result
       ngx.arg[2] = true
   end
   end
   `
   
   ### Environment
   
   - apisix version (cmd: `apisix version`):
   - OS (cmd: `uname -a`):
   - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
   - etcd version, if have (cmd: run `curl 
http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
   - apisix-dashboard version, if have:
   - 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`):
   
   
   ### Steps to reproduce
   
   do plugin like this
   
   ### Actual result
   
   can right return res
   
   ### Error log
   
   no err log
   
   ### Expected result
   
   _No response_


-- 
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]


Reply via email to