maxContentLength config not working for exceeded content-length response
See original GitHub issueSummary
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:
- Created 5 years ago
- Reactions:5
- Comments:13 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This parameter still doesn’t work.
Tested on: 0.19.2
My project is now receiving alerts on this issue.
See CVE-2019-10742