Skip to content
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

is chunked request bodies supported? #32

Closed
willdonggg opened this issue Dec 8, 2016 · 6 comments
Closed

is chunked request bodies supported? #32

willdonggg opened this issue Dec 8, 2016 · 6 comments

Comments

@willdonggg
Copy link

I'm developing a file server with openresty, the client is a java program which upload the file with stream so that not too much memory used , but I get the error "chunked request bodies not supported yet", so I want to know does lua_resty_upload support chunked request bodies? if not, is there any suggest to handle this, thanks.

@agentzh
Copy link
Member

agentzh commented Dec 9, 2016

@willdonggg I think the error message you're getting is quite self-explanatory :)

@willdonggg
Copy link
Author

@agentzh thanks, as the message says, lua_resty_upload does not support Chunked Transfer. would you like to give some suggestion that how to handle chunked request body with openresty or nginx

@agentzh
Copy link
Member

agentzh commented Dec 11, 2016

@willdonggg Well, you can use ngx.req.read_body and ngx.re.get_body_data instead which uses nginx's built-in request body reader with chunked encoding support (if your nginx core is modern enough). But the current nginx built-in request body reader API lacks streaming processing support like the ngx.req.socket Lua API used by this lua-resty-upload library.

The ultimate solution is to add chunked encoding support to the ngx.req.socket(false) API (excluding those raw downstream cosockets) so that this Lua library can work out of the box without any Lua code changes. Patches welcome :)

@willdonggg
Copy link
Author

@agentzh thanks for your answer

@wyxloading
Copy link

hi @agentzh , sorry to bother. Does this issue has any progress?

After checking ngx.req.read_body and ngx.req.get_body_data, i found that this solution may cause performance issue (since read_body may read the whole request body synchronously, even more if the request body larger than client_body_buffer_size, it will write to file instead, which cost more disk io).

Since the ngx.req.socket method support streaming processing, i think it is definitely cost less memory and disk io.

Any suggestions to solve this problem ?

thanks

@Triple-Z
Copy link

I have the same question as @wyxloading . In the documentation it says:

"Instead of writing the data chunk into files (as shown in the example above), you can also write the data chunks to upstream cosocket connections if you do not want to save the data on local file systems."

Can anyone do a little showcase here to show us how to "write the data chunks to upstream cosocket connections"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants