Use a body stream for worker requests#268
Conversation
|
@augustoccesar - noticed this when debugging some performance problems, WDYT? |
Yeah, this makes a lot of sense. I will take a look if this re-introduces the issue that we were having with the body. If it does, I think we are probably better just reverting #263 to rely on the The issue was the "misunderstanding" if there was a body to process or not for non-standard requests. I'm not sure if the issue was with |
|
Yeah, this brings back the issue that we were trying to solve with #263 😞 I will investigate here if can get both things working! |
|
For context: the issue is that when doing Granted, DELETE requests shouldn't really have bodies, but we do have some "non-conforming" endpoints at the moment. Funny enough, it does not happen if running the worker locally, only once it is deployed to Cloudflare. |
### Description On #263 we changed the conversion of the request from the internal try_into from workers-rs for a manual one to be able to proxy DELETE requests with body. This caused the performance issues reported and with a proposed fix on #268. The changes on #268 however re-introduced the original issue that #263 was attempting to fix, as in it's core, it is what the `try_into` does. As a middle ground, this PR proposes a workaround for the DELETE with body without compromising the performance of other requests.
### Description On #263 we changed the conversion of the request from the internal try_into from workers-rs for a manual one to be able to proxy DELETE requests with body. This caused the performance issues reported and with a proposed fix on #268. The changes on #268 however re-introduced the original issue that #263 was attempting to fix, as in it's core, it is what the `try_into` does. As a middle ground, this PR proposes a workaround for the DELETE with body without compromising the performance of other requests.
Reading the entire request body to memory as a string is less efficient as being able to use stream primitives. This should increase performance of large request bodies for example file uploads.