Skip to content

maxBodyLength does not work with disabled redirects #3769

@misos1

Description

@misos1

Describe the bug

maxBodyLength does not work with disabled redirects like when using { maxRedirects: 0, maxBodyLength: 100 } in options.

To Reproduce

require("axios")
	.put("http://www.example.com", Buffer.alloc(1000), { maxRedirects: 0, maxBodyLength: 100 })
	.catch(e => console.log("axios returned error:", e));

Expected behavior

It should print something like:

axios returned error: Error [ERR_FR_MAX_BODY_LENGTH_EXCEEDED]: Request body larger than maxBodyLength limit
...

As this example does:

require("axios")
	.put("http://www.example.com", Buffer.alloc(1000), { maxBodyLength: 100 })
	.catch(e => console.log("axios returned error:", e));

Environment

  • Axios Version 0.21.1
  • Adapter HTTP
  • Node.js Version v15.12.0

Additional context/Screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions