koajs / bodyparser

Koa body parsing middleware
MIT License
1.3k stars 116 forks source link

Option to disable content-length check on request #133

Closed rightaway closed 1 year ago

rightaway commented 4 years ago

If I send a request with a content-length header that doesn't match the exact length of the request's content, it doesn't work. If it's too short, the content gets truncated to that length. If it's too long, then the request just hangs as the server expects the remaining bytes to come in.

Could we have an option to disable this so we can switch it off in development? If I'm changing the request body of an existing request in chrome dev tools, I need to always remember to delete the content-length header before sending the request, otherwise things break.

Like koa doesn't enforce a request body length when there's no content-length header, it would also be useful in development to have an option to disable the check even when the content-length header is provided.

3imed-jaberi commented 1 year ago

I see that koa and/or koa-bodyparser behave correctly in the mentioned scenario. Any server engine should respect the used headers.

rightaway commented 1 year ago

@3imed-jaberi Can we get an option to disable this check? It's not always necessary in development and takes time to manually update the header before sending a modified request.