-
-
Notifications
You must be signed in to change notification settings - Fork 727
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
set req.length #214
Comments
That sounds mostly OK, but we need to impact what setting a |
Agreed about the name conflict, don't see a way to validate the it upfront. What about |
Can you just use the
|
Hi @dcolens I'm circling back around on this, and was wondering if you could say what your use-case is. The reason is not to dismiss this request, but rather to determine the best way to implement the request. Basically looking to better understand the "why?" to it to make sure everything lines up once implemented. |
I receive a JSON body, in some cases I want to forward it to another service and I need to stringify it, but I only want to do that if its size is less than 100KB. The only way to test it, is to JSON.stringify it which is blocking (I know that JSON.parse is too), I'd rather check the size before calling JSON.stringify. |
@dcolens gotcha. What do you do if the size is over 100KB? |
POST it to a remote service, i.e. JSON.stringify |
Oh, I thought it said you didn't want to send it to the remove service if it was over 100KB? |
Sorry, misunderstood, indeed, in that case I omit the incoming payload from the outgoing call to the remote service! |
Makes sense! And to clarify, in all the cases you do actually look at the body locally, just the size is what determines if you want to forward it? |
yes pretty much |
Any update on this? |
can i take up this issue ? |
it would be nice that body-parser sets the length of the body, my use case is I'd like to know the length of a JSON payload POSTED using chunked-encoding, so there is no content-length header and req.body is set to an Object thanks to body-parser.
Sounds like the only way to get the body size is to stringify req.body and get the length :/ or use raw-parser and JSON.parse.
Any chance we could set req.length or similar to the size of the raw body before parsing it ? (other suggestions are welcome)
The text was updated successfully, but these errors were encountered: