Comments (9)
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.
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.
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×tamp=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.
@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.
How to get post request http header and post body in lua-resty-mysql code ?
from lua-resty-mysql.
@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.
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.
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.
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)
- TODO: support specify pool_size and backlog in connect method. HOT 1
- create_db, create_user, grant and switch_user
- _recv_packet 函数 遇到错误返回,read_result并没有设置mysql. state=1 而是直接返回nil,导致下一次query失败 HOT 5
- lua entry thread aborted: runtime error: /usr/local/openresty/lualib/resty/mysql.lua:571: bad request
- 腾讯云服务器上mysql,使用lua不能访问数据库 HOT 2
- 为什么查询结果不支持返回number类型,而是将number类型也按string类型返回?
- Hardcoded query works but API disabled in the current context when using a variable HOT 3
- world.sql.gz page was not found, resulting in a CI error HOT 5
- schedule for SQL prepare statement support
- /usr/local/openresty/lualib/resty/mysql.lua:373: attempt to perform arithmetic on field 'packet_no' (a nil value)
- mysql查询是否串行 HOT 1
- bad result: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='
- install by luarocks error HOT 3
- can not use "not res" to judge if the 'res' is empty table
- The connect function is thrown incorrectly
- using lua-resty-mysql query table contents, returned body incorrect
- connect() to unix:/var/lib/mysql/mysql.sock failed (11: Resource temporarily unavailable)
- Client does not support authentication protocol requested by server; consider upgrading MySQL client: 1251 08004 HOT 1
- Why not release the latest version on opm ?
- Connection pooling for php-fpm with nginx unix sockets and resty mysql HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-resty-mysql.