Created
August 15, 2011 22:55
-
-
Save TooTallNate/1148093 to your computer and use it in GitHub Desktop.
Example script of how `request` (and node) drops any `query` param passed to http.request()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http') | |
, assert = require('assert') | |
, request = require('./') | |
, url = require('url') | |
, path = 'http://localhost/test' | |
http.createServer(function (req, res) { | |
assert.equal('/test?foo=bar', req.url) | |
res.end() | |
}).listen(0, function () { | |
var port = this.address().port | |
, parsed = url.parse(path, true) | |
// Overriding the requested port works fine: | |
parsed.port = port | |
// But any 'query' value will be completely ignored | |
parsed.query.foo = 'bar' | |
request({ | |
method: 'GET' | |
, uri: parsed | |
}, this.close.bind(this)) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment