saiyoofan opened a new issue #6643:
URL: https://github.com/apache/apisix/issues/6643


   ### Description
   
   modify ctx.lua  to support content-type 
application/x-www-form-urlencoded;charset=utf-8 to match route
   like this:
      ```
    253             elseif core_str.has_prefix(key, "post_arg_") then
       254                 -- only match default post form
       255                 local con_t = request.header(nil, "Content-Type")
       256                 local con_t_s = sub_str(con_t, 1, 33)
       257                 if con_t_s == "application/x-www-form-urlencoded" 
then
       258                     local arg_key = sub_str(key, 10)
       259                     local args = request.get_post_args()[arg_key]
       260                     if args then
       261                         if type(args) == "table" then
       262                             val = args[1]
       263                         else
       264                             val = args
       265                         end
       266                     end
       267                 end
   ```
   
   get some errors:
   ```
   [error] 51#51: *10048 lua entry thread aborted: runtime error: 
/usr/local/apisix/apisix/core/ctx.lua:256: bad argument #1 to 'sub_str' (string 
expected, got nil)
   stack traceback:
   coroutine 0:
        [C]: in function 'sub_str'
        /usr/local/apisix/apisix/core/ctx.lua:256: in function '__index'
        /usr/local/apisix//deps/share/lua/5.1/resty/expr/v1.lua:291: in 
function 'eval'
        /usr/local/apisix/apisix/plugins/traffic-split.lua:253: in function 
'phase_func'
        /usr/local/apisix/apisix/plugin.lua:720: in function 'run_plugin'
        /usr/local/apisix/apisix/init.lua:471: in function 'http_access_phase
   ```
   so ,how can I repair it.
   thx.
   
   ### Environment
   
   - APISIX version (run `apisix version`):
   - Operating system (run `uname -a`):
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
   - etcd version, if relevant (run `curl 
http://127.0.0.1:9090/v1/server_info`):
   - APISIX Dashboard version, if relevant:
   - Plugin runner version, for issues related to plugin runners:
   - LuaRocks version, for installation issues (run `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]


Reply via email to