lua-resty-reqargs icon indicating copy to clipboard operation
lua-resty-reqargs copied to clipboard

Lib only works for GET args

Open lordnynex opened this issue 7 years ago • 5 comments

https://github.com/bungle/lua-resty-reqargs/blob/master/lib/resty/reqargs.lua#L86

ngx.var.content_type seems to always be nil.

lordnynex avatar May 15 '17 23:05 lordnynex

Good catch! Thanks!

bungle avatar May 16 '17 06:05 bungle

@lordnynex I submitted one patch, is this: https://github.com/bungle/lua-resty-reqargs/commit/b023f4c7cc83ba699b3c6c8924943144cbffc4dd

what you were looking at?

bungle avatar May 16 '17 06:05 bungle

What comes to this: http://nginx.org/en/docs/http/ngx_http_core_module.html#var_content_type

aka $content_type being always nil. That seems strange if you do pass the Content-Type header.

bungle avatar May 16 '17 07:05 bungle

@bungle I'm realizing that this bug is weird and probably invalid. For whatever reason it's always nil in my tests outside of reqargs. But the issue that caused me to dive into the code to see why post was not populated was my own stupid issue where I was posting invalid JSON.

Long story short, I think you can close this bug as invalid, because the lib appears to work. The line I linked, if it was a valid bug, means POST would never work regardless of content type. I'm a little stumped here.

lordnynex avatar May 19 '17 17:05 lordnynex

@lordnynex, great, but I think you pointed me to one obvious flaw (not related to your issue). Have you checked the latest master, and if yes, does it cause any problems. I mean, should I still revert to the old code. It feels that the original code was a bit opinionated. But the commit I made is not 100% bc compatible. I still it right thing to do (e.g. not to default application/x-www-form-urlencoded unless asked for it. It is the most common way to send parameters though).

bungle avatar May 19 '17 21:05 bungle