Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Do not make copy of options in http.request #14569

Closed
mogadanez opened this issue Apr 8, 2015 · 1 comment
Closed

Do not make copy of options in http.request #14569

mogadanez opened this issue Apr 8, 2015 · 1 comment
Labels

Comments

@mogadanez
Copy link

introduced in d6bbb19

This cause to ignore params if options is constructed object with getters

var http = require("http");

function call ( options, cb ){
    var req = http.request(options, function(res) {
        res.setEncoding('utf8');
        res.on('data', function (chunk) {
            console.log('BODY: ' + chunk);
            if (cb )
                cb();
        });
    });
    req.end();
}

var HttpMeta = function() {}

var options = new HttpMeta ()
options.host = "node-path-test.s3-website-us-east-1.amazonaws.com" ;
options.method = "get";
options.path =  "/sub/inner.txt";

call( options, function(){
    delete options.path;
    Object.defineProperty(HttpMeta.prototype, 'path', {
        get: function() {
            return "/sub/inner.txt";
        },
        enumerable: true
    });
    call(options);
});

Fixed in io.js nodejs/node@06cfff9

@frankcash
Copy link

I'm curious as to whether or not the contributor team is accepting PRs to solve things in Node that have been solved in io.js, even though this appears to be a simple fix. (sorry if I'm over looking if they already commented on this)

mogadanez referenced this issue in nodejs/node May 8, 2015
This reverts commit 06cfff9.

Reverted because it introduced a regression where (because options were
modified in the later functionality) options.host and options.port would
be overridden with values provided in other, supported ways.

PR-URL: #1467
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@jasnell jasnell added the http label Jun 25, 2015
@Trott Trott closed this as completed Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants