Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed incorrect content-length on digest authentication request. (#28… #2998

Closed
wants to merge 1 commit into from

Conversation

liefersfl
Copy link

…65 #2954 #2777)

PR Checklist:

  • I have run npm test locally and all tests are passing.
  • I have added/updated tests for any new behavior.
  • If this is a significant change, an issue has already been created where the problem / solution was discussed: [N/A, or add link to issue here]

PR Description

There was a bug in handling requests with two step authentication (eg. digest) and formdata. In the first step, the content-length of the formdata was calculated and sent in the request header as "content-length: xxx" but the content was not sent. The whole request ended in a timeout while the server was waiting for the content.

The following example produces a timeout:

const options = {
   method: "POST",
   url: "<url to server>",
   auth: {
       user: 'abcde0ab963dc088cca337e19ebb6e95',
       pass: 'abcde1f223f4200e5b74273a1538ecc8752ddde93d6c8e45c50e55c9392a11ec',
       sendImmediately: false
     }
}

var r = request(options, function(err, httpResponse, body) {
   if (err) {
       console.log(err)
   }
   console.log("Done")
})

var form = r.form();
form.append('file', fs.createReadStream("/tmp/test.gz"), {
   filename: 'test.gz'
})

The fix sends a zero content-length when no content will be sent.

All tests passed, i just had to create new server certificates since they expired today ;-).

@stale
Copy link

stale bot commented Aug 31, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 31, 2019
@stale stale bot closed this Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants