You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/08/13 06:20:57 UTC

[GitHub] [apisix] yfgcq opened a new issue #2053: request help: how to get post data of form-data、x-www-form-urlencoded、data-raw(json)

yfgcq opened a new issue #2053:
URL: https://github.com/apache/apisix/issues/2053


   ### Issue description
    how to get post data of form-data、x-www-form-urlencoded、data-raw(json)?
   怎么获取这几种form-data、x-www-form-urlencoded、data-raw(json) post请求的post data ?
   
   ngx.req.get_post_args()可以获取 x-www-form-urlencoded请求的post data
   ngx.req.get_body_data()可以获取data-raw(json) ,必须指定ContentType:application/json,
   但是有时postman 或者curl 请求时 没指定ContentType
       curl xxx POST -i -d ' {"AppKey": "a1", "id": 22234666}'
       apisix 判断逻辑: 
   `
         if string.find(ngx.req.get_headers()["Content-Type"] or "","application/json", 1, true) then
           ngx.req.get_body_data()
         else
           ngx.req.get_post_args() --
          end
   `
   问题1:这种情况怎么办?
   问题2:form-data 不知道怎么获取?
   
   ### Environment
   
   * apisix version (cmd: `apisix version`):1.4.1
   * OS:linux
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] yfgcq commented on issue #2053: request help: how to get post data of form-data、x-www-form-urlencoded、data-raw(json)

Posted by GitBox <gi...@apache.org>.
yfgcq commented on issue #2053:
URL: https://github.com/apache/apisix/issues/2053#issuecomment-673299926


   ???


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] membphis commented on issue #2053: request help: how to get post data of form-data、x-www-form-urlencoded、data-raw(json)

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2053:
URL: https://github.com/apache/apisix/issues/2053#issuecomment-673989743


   1. read the request header
   2. check the `Content-Type`
   3. different type, use different way.
   
   https://moonbingbing.gitbooks.io/openresty-best-practices/content/
   
   this book may help you.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] membphis closed issue #2053: request help: how to get post data of form-data、x-www-form-urlencoded、data-raw(json)

Posted by GitBox <gi...@apache.org>.
membphis closed issue #2053:
URL: https://github.com/apache/apisix/issues/2053


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] jiezaizone commented on issue #2053: request help: how to get post data of form-data、x-www-form-urlencoded、data-raw(json)

Posted by GitBox <gi...@apache.org>.
jiezaizone commented on issue #2053:
URL: https://github.com/apache/apisix/issues/2053#issuecomment-673288228


   发自我的华为手机-------- 原始邮件 --------发件人: yfgcq <no...@github.com>日期: 2020年8月13日周四 下午2:21收件人: apache/apisix <ap...@noreply.github.com>抄送: Subscribed <su...@noreply.github.com>主    题: [apache/apisix] request help: how to get post data of form-data、x-www-form-urlencoded、data-raw(json) (#2053)
   Issue description
   how to get post data of form-data、x-www-form-urlencoded、data-raw(json)?
   怎么获取这几种form-data、x-www-form-urlencoded、data-raw(json) post请求的post data ?
   ngx.req.get_post_args()可以获取 x-www-form-urlencoded请求的post data
   ngx.req.get_body_data()可以获取data-raw(json) ,必须指定ContentType:application/json,
   但是有时postman 或者curl 请求时 没指定ContentType
   curl xxx POST -i -d ' {"AppKey": "a1", "id": 22234666}'
   apisix 判断逻辑:
   if string.find(ngx.req.get_headers()["Content-Type"] or "","application/json", 1, true) then ngx.req.get_body_data() else ngx.req.get_post_args() -- end
   问题1:这种情况怎么办?
   问题2:form-data 不知道怎么获取?
   Environment
   apisix version (cmd: apisix version):1.4.1OS:linux
   
   —You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org