Skip to content

Commit c2ba3df

Browse files
committed
Merge pull request #46 from jbpros/buffer-support
Allow for Buffer instances as request bodies
2 parents 3c8328f + 4ba4386 commit c2ba3df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/XMLHttpRequest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ exports.XMLHttpRequest = function() {
344344
if (settings.method === "GET" || settings.method === "HEAD") {
345345
data = null;
346346
} else if (data) {
347-
headers["Content-Length"] = Buffer.byteLength(data);
347+
headers["Content-Length"] = Buffer.isBuffer(data) ? data.length : Buffer.byteLength(data);
348348

349349
if (!headers["Content-Type"]) {
350350
headers["Content-Type"] = "text/plain;charset=UTF-8";

0 commit comments

Comments
 (0)