-
-
Notifications
You must be signed in to change notification settings - Fork 628
Ensure request body Content-Length is set correctly #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just silently ignoring non-strings isn't ideal.
We should at least log a message that you're trying to send something that's being ignored.
Would it be better to try and convert to a string? Just with tostring
, no serialising or anything.
If you set body to a number or a bool its reasonable to expect that to work and just send a stringified version? Certainly for numbers anyway.
I guess I was of the opinion that the API is perfectly clear (as is But yeah, it's perhaps more idiomatic to assume we'll send string representations magically, and I guess that's harmless enough. I wouldn't be surprised if LuaJIT elides |
On closer inspection this is actually about not having a I also thought I'd be good and return an error if your body is an iterator and you haven't set a length. But I'd forgotten about the This all feels like some foggy distant memory so any thoughts appreciated! |
Chunked request bodies aren't supported by ngx.req.socket so that's why they aren't tested / won't work with But you might be sourcing a chunked body from somewhere else. I think if you're setting the body to a function (and you're not proxying and therefore copying the request headers) you're in a fairly advanced use case and should be able to figure out content length / chunking yourself? |
Fails on chunked input until supported by ngx_lua
Co-authored-by: Thijs Schreijer <[email protected]>
Fixes #217