Skip to content

How to reconstruct body after upload #41

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

Closed
asyncer opened this issue Jan 28, 2018 · 1 comment · Fixed by #63
Closed

How to reconstruct body after upload #41

asyncer opened this issue Jan 28, 2018 · 1 comment · Fixed by #63

Comments

@asyncer
Copy link

asyncer commented Jan 28, 2018

I'm trying to make an anti-virus middle ware which first check the uploaded files with help of lua-resty-upload and if they are not infected proxy_pass them to some dynamic proxy target.
I was able to handle the first part easily thanks to lua-resty-upload but the issue is when I proxy_pass the request after anti-virus check the body is empty. which seems pretty normal because lua-resty-upload has consumed the body already.
So I should reconstruct the body again after virus check, But I don't have the raw binary data of request at that point to easily reconstruct the body, all I have is parsed body which is hard to be converted to raw binary again.
Is there any shortcut method which can give me the raw binary data after process of lua-resty-upload is finished?

@bungle
Copy link
Member

bungle commented Feb 21, 2018

I think this library should possibly get an option to:
https://github.com/openresty/lua-nginx-module#ngxreqinit_body
https://github.com/openresty/lua-nginx-module#ngxreqappend_body
https://github.com/openresty/lua-nginx-module#ngxreqfinish_body

So that it rewrites the buffer back (while it reads it). Currently you cannot use e.g. proxy module to forward the body read by lua-resty-upload. So in that sense it is not proxy friendly currently.

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

Successfully merging a pull request may close this issue.

2 participants