Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
Created August 15, 2011 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TooTallNate/1148093 to your computer and use it in GitHub Desktop.
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()
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