Smee seems to reformat JSON without updating Content-Length header
See original GitHub issueHi,
I am using smee-client in front of a custom Node app. During my tests using curl
, I noticed the following kind of error from it:
Error: socket hang up
at connResetException (internal/errors.js:570:14)
at Socket.socketOnEnd (_http_client.js:440:23)
at Socket.emit (events.js:215:7)
at endReadableNT (_stream_readable.js:1183:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'ECONNRESET',
response: undefined
}
By observing the payload, I finally realized that the ‘Content-Length’ header coming from smee client was still equal to what my curl command was sending whereas the JSON payload itself had been reformatted to a compact format.
This leads my app to hang, waiting for more bytes to come from the smee client:
BadRequestError: request aborted
at IncomingMessage.onAborted (/app/node_modules/raw-body/index.js:231:10)
at IncomingMessage.emit (events.js:210:5)
at abortIncoming (_http_server.js:492:9)
at socketOnClose (_http_server.js:485:3)
at Socket.emit (events.js:215:7)
at TCP.<anonymous> (net.js:658:12)
Simple example to reproduce:
curl https://smee.io/XXXXX --data '{ }' -H 'Content-Type: application/json'
The tcpdump
trace of the corresponding HTTP request coming from smee client to my app:
POST / HTTP/1.1
host: smee.io
Accept-Encoding: gzip, deflate
user-agent: curl/7.54.0
content-type: application/json
connection: close
accept: */*
x-request-id: 3e3de197-3708-4dd2-8202-21c3f3e6ccd5
x-forwarded-for: 70.36.61.12
x-forwarded-proto: https
x-forwarded-port: 443
via: 1.1 vegur
connect-time: 0
x-request-start: 1572802450843
total-route-time: 0
content-length: 3
timestamp: 1572802450846
{}
I have no idea what part of the pipeline is at fault but I would expect that either the JSON format should be left alone or that the content length should be recalculated accordingly to the new format.
smee client version: 1.1.0
Thanks. Philippe
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:7
Top GitHub Comments
Issue-Label Bot is automatically applying the label
bug
to this issue, with a confidence of 0.54. Please mark this comment with 👍 or 👎 to give our bot feedback!Links: app homepage, dashboard and code for this bot.
still relevant 👍 , happened to me today