parsecph / clobbr

⚡️ A tool to check the speed and resilience of your API endpoints against multiple parallel or sequence requests.
https://clobbr.app
MIT License
191 stars 13 forks source link

Cli is sending incorrect Content-Length header preventing to test anything behind cloudfront #166

Closed andrejguran closed 1 year ago

andrejguran commented 1 year ago

When profiling a website behind cloudfront i.e: https://docs.aws.amazon.com/ I receive error: All of the 1 iterations have failed ❌ Command npx @clobbr/cli run --url https://docs.aws.amazon.com/ -i 1 --debug returns this JSON:

[
  {
    "url": "https://docs.aws.amazon.com/",
    "verb": "get",
    "headers": {},
    "metas": {
      "number": "#001",
      "formatted": "#001: Failed 403 (Forbidden)",
      "status": "403 (Forbidden)",
      "statusText": "Forbidden",
      "index": 0,
      "duration": 44
    },
    "formatted": "#001: Failed",
    "failed": true,
    "error": {
      "message": "Request failed with status code 403",
      "name": "Error",
      "stack": "Error: Request failed with status code 403\n    at createError (/Users/andrejguran/.npm/_npx/b54976efefe97df9/node_modules/@clobbr/cli/dist/index.js:1547:15)\n    at settle (/Users/andrejguran/.npm/_npx/b54976efefe97df9/node_modules/@clobbr/cli/dist/index.js:1809:12)\n    at IncomingMessage.handleStreamEnd (/Users/andrejguran/.npm/_npx/b54976efefe97df9/node_modules/@clobbr/cli/dist/index.js:849:11)\n    at IncomingMessage.emit (node:events:525:35)\n    at endReadableNT (node:internal/streams/readable:1358:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)",
      "config": {
        "url": "https://docs.aws.amazon.com/",
        "method": "get",
        "data": "{}",
        "headers": {
          "Accept": "application/json, text/plain, */*",
          "User-Agent": "clobbr/1.13.1",
          "Content-Type": "application/json",
          "Content-Length": 2
        },
        "transformRequest": [
          null
        ],
        "transformResponse": [
          null
        ],
        "timeout": 10000,
        "xsrfCookieName": "XSRF-TOKEN",
        "xsrfHeaderName": "X-XSRF-TOKEN",
        "maxContentLength": -1,
        "maxBodyLength": -1,
        "maxRedirects": 99,
        "transitional": {
          "silentJSONParsing": true,
          "forcedJSONParsing": true,
          "clarifyTimeoutError": false
        },
        "timeoutErrorMessage": "Request timed out (10s)"
      }
    }
  }
]

Notice that there is a header: "Content-Length": 2 present which is breaking HTTP standard as GET should always be "Content-Length": 0, I am also not able to override it with --headers and providing "Content-Length": 0 override.

npx @clobbr/cli --version 1.13.1

danmindru commented 1 year ago

thanks @andrejguran, Will take a look at it right away.

danmindru commented 1 year ago

Hi @andrejguran so awesome for you to find this out. Should be fixed in cli v1.13.4 let me know if you have any other issues! Cheers, Dan

npx @clobbr/cli@v1.13.4 run --url https://docs.aws.amazon.com/ -i 1
Screenshot 2023-05-04 at 11 41 00