Skip to content
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

Sending wrong Content-Length value returns status code 500 #124

Open
pavelsaman opened this issue Feb 15, 2020 · 0 comments
Open

Sending wrong Content-Length value returns status code 500 #124

pavelsaman opened this issue Feb 15, 2020 · 0 comments

Comments

@pavelsaman
Copy link

  1. problem

Sending a custom made Content-Length header value that doesn't correspond to the actual length returns 500 with the following stack trace:

SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
	at parse (/app/node_modules/body-parser/lib/types/json.js:89:19)
	at /app/node_modules/body-parser/lib/read.js:121:18
	at invokeCallback (/app/node_modules/raw-body/index.js:224:16)
	at done (/app/node_modules/raw-body/index.js:213:7)
	at IncomingMessage.onEnd (/app/node_modules/raw-body/index.js:273:7)
	at IncomingMessage.emit (events.js:333:22)
	at endReadableNT (_stream_readable.js:1204:12)
	at processTicksAndRejections (internal/process/task_queues.js:84:21)
  1. steps to reproduce

send the following req:

POST /posts HTTP/1.1
Content-Length: 2
Content-Type: application/json
User-Agent: PostmanRuntime/7.22.0
Accept: */*
Host: jsonplaceholder.typicode.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

{
	"a": 5
}
  1. desired behaviour

Treat it as error, respond with status code 400 (Bad Request) and close the connection.

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

No branches or pull requests

1 participant