HttpRequest: don't send body for GET/DELETE methods

This commit is contained in:
Nicholas O'Leary 2013-10-10 09:56:07 +01:00
parent ae6fa8b6c0
commit 80b76fba88
1 changed files with 2 additions and 2 deletions

View File

@ -82,7 +82,7 @@ function HTTPRequest(n) {
this.on("input",function(msg) {
var opts = urllib.parse(msg.url||url);
opts.method = msg.method||method;
opts.method = (msg.method||method).toUpperCase();
if (msg.headers) {
opts.header = msg.headers;
}
@ -105,7 +105,7 @@ function HTTPRequest(n) {
msg.statusCode = err.code;
node.send(msg);
});
if (msg.payload) {
if (msg.payload && (method == "PUSH" || method == "PUT") ) {
if (typeof msg.payload === "string" || Buffer.isBuffer(msg.payload)) {
req.write(msg.payload);
} else if (typeof msg.payload == "number") {