Git Product home page Git Product logo

Comments (9)

zhangfee avatar zhangfee commented on August 28, 2024

Maybe it is not caused by urlencode.
The http req is sent by libcurl. Browser is ok.
Is it caused by libcurl?

from lua-resty-mysql.

agentzh avatar agentzh commented on August 28, 2024

Everytime you get a 500 error page, you should really really look up your nginx's error.log file for the reason.

Also ensure you are not using a too high error log filtering level in your error_log directive. Basically, using notice is fine, as in

error_log logs/error.log notice;

from lua-resty-mysql.

zhangfee avatar zhangfee commented on August 28, 2024

according to your method, I get error log:
[error] 3450#0: *97455 lua entry thread aborted: runtime error: [string "content_by_lua"]:3: attempt to concatenate field 'arg_v' (a nil value)
stack traceback:
coroutine 0:
[string "content_by_lua"]: in function <[string "content_by_lua"]:1>, client: 127.0.0.1, server: my.linkaddress.com, request: "POST /rest HTTP/1.1", host: "my.linkaddress.com"

My req parameter is below:
key=123456&field=cpromotion&format=json&method=get&session=610518d449043&sign=0D056C41617&id=2306008141&timestamp=2013%2d11%2d20%2017%3a12%3a52&v=2%2e0

In order to get v, using ngx.var.arg_v on server

if I copy req parameter and submit it by browser, it is ok.

from lua-resty-mysql.

agentzh avatar agentzh commented on August 28, 2024

@zhangfee Your error message already told you why. You should have looked closer.

The ngx.var.arg_v value could be nil when there is no "v" querystring argument in your request URL at all. You should take this special case into account in you Lua code. And you can never concatenate a nil value with other (string) values in Lua.

from lua-resty-mysql.

zhangfee avatar zhangfee commented on August 28, 2024

How to get post request http header and post body in lua-resty-mysql code ?

from lua-resty-mysql.

agentzh avatar agentzh commented on August 28, 2024

@zhangfee This is not related to lua-resty-mysql at all. Check out ngx_lua's documentation for the related API functions:

https://github.com/chaoslawful/lua-nginx-module#ngxreqget_headers

https://github.com/chaoslawful/lua-nginx-module#ngxreqget_body_data

from lua-resty-mysql.

zhangfee avatar zhangfee commented on August 28, 2024

Thanks for your reply,I found the problem from the following reason:

1 client use post method, server get parameter by get method.
2 client send url encoding parameter, server need to decode url parameter.

How should I work it? Thank you!

from lua-resty-mysql.

agentzh avatar agentzh commented on August 28, 2024

Hello!

On Thu, Nov 21, 2013 at 5:09 AM, zhangfee [email protected] wrote:

1 client use post method, server get parameter by get method.

You should use ngx.req.read_body() and ngx.req.get_post_args() instead here. See

https://github.com/chaoslawful/lua-nginx-module#ngxreqget_post_args

2 client send url encoding parameter, server need to decode url parameter.

Are you using ngx.var.arg_NAME to fetch URL arguments? The $arg_NAME
Nginx variable does not automatically decode the value for you. You
need to call ngx.unescape_uri() on the Lua land yourself:

https://github.com/chaoslawful/lua-nginx-module#ngxunescape_uri

Alternatively, you can use the ngx.req.get_uri_args() API instead:

https://github.com/chaoslawful/lua-nginx-module#ngxreqget_uri_args

This API will do URI unescaping automatically for you.

How should I work it? Thank you!

BTW, please read the official documentation of ngx_lua more carefully.
I've found myself keeping pasting documentation links for your
questions.

Also, as I've said, these questions are not directly related to
lua-resty-mysql, so you should not ask here as lua-resty-mysql issues.
Rather, these questions are for ngx_lua. You're recommended to ask
such general questions on the openresty (Chinese) mailing list or
openresty-en (English) list. See

https://github.com/chaoslawful/lua-nginx-module#community

Thanks for your cooperation!
-agentzh

from lua-resty-mysql.

zhangfee avatar zhangfee commented on August 28, 2024

1 It is ok by using ngx.req.read_body() and ngx.req.get_post_args().
2 Do not need to process parameter by url decoder agin.
Thinks!

I'm sorry, never used mailing lists, thinking that it is here.

from lua-resty-mysql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.