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
Sending requests with content-length equal to zero raises an error #920
Comments
Please address this issues. We are using https://github.com/google/google-api-nodejs-client which is using |
+1 |
1 similar comment
+1 |
Bug: a zero-length body causes a false error.Lines 419 to 440 in 8162961
Hold on; over 4 years' passed, yet still no fix for the single irresponsible line Workaround for you guysLine 424 in 8162961
Lines 141 to 149 in 8162961
Apparently, it doesn't filter a zero-length body out when await request.put({ // I'm using “request-promise-native” module.
uri: "http://localhost/" + destination_file_path,
qs: {timestamp, auth_code},
headers: {
"Content-Type": "application/octet-stream",
"Content-Length": file_data.length
},
body: file_data
}); |
fix check for if length is set in order to allow passing a 0-length buffer as body
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. |
In the request.js file there is a check:
if (length) {
if (!self.hasHeader('content-length')) self.setHeader('content-length', length)
} else {
throw new Error('Argument error, options.body.')
}
which prevents sending files with zero length. I understand this not very important issue, but still. Specification says "Any Content-Length greater than or equal to zero is a valid value." (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html)
I faced with this restriction when using cradle which we use to save user files to CouchDB and some of files have zero length (CouchDB also accepts empty files), so the problem is caused only by the request module.
The text was updated successfully, but these errors were encountered: