question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

maxContentLength config not working for exceeded content-length response

See original GitHub issue

Summary

I want to limit response content in bytes, so set maxContentLength to config. But doesn’t work fine. Is there any mistake?

Expected behavior

axios throws Error of maxContentLength size of 100 exceeded

Actual behavior

axios doesn’t throw any error.

Code

These files locate this repo root -> examples -> test dir to reproduce this situation.

  • index.html for client
...
<script>
      axios.get('/test/server', { maxContentLength: 100 }) 
        .then(function (response) {
          console.log(response)
          console.log(JSON.stringify(response))
        })
        .catch(function (err) {
          console.error(err)
        });
</script>
...
  • server.js
module.exports = function(req, res) {
  var str = Array(100000).join('ж');
  res.setHeader('Content-Type', 'text/html; charset=UTF-8');
  res.end(str);
};
  • response
{
  "data": ...,
  "status": 200,
  "statusText": "OK",
  "headers": {
    "date": "Wed, 18 Apr 2018 02:25:46 GMT",
    "connection": "keep-alive",
    "content-length": "199998",
    "content-type": "text/html; charset=UTF-8"
  },
  "config": {
    "url": "/test/server",
    "method": "get",
    "headers": { "Accept": "application/json, text/plain, */*" },
    "transformRequest": [null],
    "transformResponse": [null],
    "timeout": 0,
    "xsrfCookieName": "XSRF-TOKEN",
    "xsrfHeaderName": "X-XSRF-TOKEN",
    "maxContentLength": 100
  },
  "request": {}
}

Context

  • npm version: e.g.: v5.6.0
  • axios version: e.g.: v0.18.0
  • Environment: e.g.: node v9.11.1, chrome 65, macOS

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Kameecodingcommented, Feb 28, 2020

This parameter still doesn’t work.

Tested on: 0.19.2

2reactions
hovissimocommented, May 30, 2019

My project is now receiving alerts on this issue.

See CVE-2019-10742

Read more comments on GitHub >

github_iconTop Results From Across the Web

Increasing maxContentLength and maxBodyLength in Axios
The maxBodyLength seems to work for me in this simple test, I upload data to a local Express server. If I try to...
Read more >
content length too large error when sending and receiving ...
Causes. The content length of the SAML request exceeds the value set for the Maximum allowed content length property. The default value for...
Read more >
Request Limits <requestLimits> - Microsoft Learn
Overview The <requestLimits> element specifies limits on HTTP requests that are processed by the Web server. These limits include the ...
Read more >
HTTP content length exceeded 65536 bytes. - Google Groups
I started a Gremlin rest server and I am trying to submit something to it, but I constantly get the "HTTP content length...
Read more >
withSizeLimit • Akka HTTP
Limit given as parameter overrides limit configured with akka.http.parsing.max-content-length . The whole mechanism of entity size checking is intended to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found