-
Notifications
You must be signed in to change notification settings - Fork 2k
allow read of chunked request in lua #488
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
base: master
Are you sure you want to change the base?
Conversation
@rzenker Thanks for looking into this. Unfortunately this is not sufficient. We need to parse the chunked encoded data ourselves (we could reuse the chunked request body parser in the nginx, but not much else). |
@agentzh Does it need to be? Your resty-http chunked body reader already works with it this way. Also, in my case I need the raw encoded body to forward on as unmolested as possible. If it forces parse outside of lua it removes the option for people to use that. |
@rzenker Well,
|
Ah, I was confused, but referring to https://github.com/pintsized/lua-resty-http. I did try to use raw socket first, but then it requires me to handle all the response headers differently then I do with a non-chunked request. If there was a read-only raw that still let the normal nginx responses to be sent that would be great. I am not understanding the downside to at least allow the body to be read via the non-raw socket right now as opposed to returning the no chunked support error. I could see a case for not wanting to handle the raw chunked body in lua for ease-of-use, but in my case I am just forwarding the request to the backend (mostly unmodified besides new headers). If it returned just the body, my forwarding code would have to support re-chunking the request to the backend. If I can't convince you of the utility of this option, would you accept a PR that took another argument to |
@rzenker That lua-resty-http library is written by @pintsized and is a 3rd-party OpenResty library. It was used for upstream HTTP communications, instead of downstream (and we're talking about downstream here). Will you explain why you want to parse the chunked request bodies yourself instead of letting ngx_lua (or nginx core) taking care of that automatically for you? Regarding the |
@agentzh My use-case is that i'm proxying the request to a backend server in lua. If I can just read the still-chunk encoded response off and then no need to re-chunk-encode it for the backend. I was pointing out in the https://github.com/pintsized/lua-resty-http/blob/master/lib/resty/http.lua#L286 it already has a compatible reader for chunked if ngx_lua would allow it to be read (as opposed to just refusing). If users need to read a chunked body, but not the chunk encoded version, they could just use that. If the only option is to force the chunk decoding inside nginx, then a dev needs to create another lua class to re-chunk encode it if they're sending to a backend via lua like in my case. |
@rzenker For your use case, you can just assemble the chunked body yourself. That overhead is minimal. I don't see a reason to give you the original chunked data just for that. And ngx_lua still needs to parse the chunked request body somehow if even it does give you the raw chunked data because otherwise it has no ways to determine the end of the request body stream, which MAY cause problems in pipelined or keep-alive requests. |
e7ac10c
to
cfd4f90
Compare
This pull request is now in conflict :( |
f924579
to
fef2581
Compare
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
This pull request is now in conflict :( |
No description provided.