We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent baeda7e commit 3d482a6Copy full SHA for 3d482a6
lib/XMLHttpRequest.js
@@ -327,14 +327,18 @@ exports.XMLHttpRequest = function() {
327
}
328
329
// Set content length header
330
- if (settings.method == "GET" || settings.method == "HEAD") {
+ if (settings.method === "GET" || settings.method === "HEAD") {
331
data = null;
332
} else if (data) {
333
headers["Content-Length"] = Buffer.byteLength(data);
334
335
if (!headers["Content-Type"]) {
336
headers["Content-Type"] = "text/plain;charset=UTF-8";
337
338
+ } else if (settings.method === "POST") {
339
+ // For a post with no data set Content-Length: 0.
340
+ // This is required by buggy servers that don't meet the specs.
341
+ headers["Content-Length"] = 0;
342
343
344
var options = {
0 commit comments