openresty / lua-resty-upload

Streaming reader and parser for http file uploading based on ngx_lua cosocket
404 stars 113 forks source link

feature: preserve body after parse #63

Closed suikabreaker closed 2 years ago

suikabreaker commented 2 years ago

Fix #41 and #42. Inspired from this PR: #43.

My goal is to leave the request body unchanged after "regeneration" and decouple the implementation of #61 from this, so I implement this in another way and try to make fewer modifications to the original logic.

suikabreaker commented 2 years ago

@zhuizhuhaomeng May you review this PR?

xiaocang commented 2 years ago

And there is a small doubt on my own: what is the scenario for the use of the function of preserving the request body here, and is it common enough?

suikabreaker commented 2 years ago

And there is a small doubt on my own: what is the scenario for the use of the function of preserving the request body here, and is it common enough?

There is. I have been working on a WAF project, which acts as a proxy filtering request body. It needs to pass the body(and if we can, do not modify the body) if there's no attempt of attack found.

suikabreaker commented 2 years ago

The document of the preserve option is also needed.

Note that it should be stated that if the preserve option is turned on, the memory usage is doubled.

Seems other two options are also not documented. Added description.

xiaocang commented 2 years ago

@suikabreaker there's still typo: warpped -> wrapped.

suikabreaker commented 2 years ago

@suikabreaker there's still typo: warpped -> wrapped.

Fixed.

xiaocang commented 2 years ago

The other part looks good to me.

suikabreaker commented 2 years ago

The other part looks good to me.

I have re-requested review.

xiaocang commented 2 years ago

could you help check this PR? ping @zhuizhuhaomeng @doujiang24