Skip to content

Instantly share code, notes, and snippets.

@samsonjs
Created July 6, 2010 06:02
Show Gist options
  • Save samsonjs/465070 to your computer and use it in GitHub Desktop.
Save samsonjs/465070 to your computer and use it in GitHub Desktop.
var http = require('http'),
sys = require('sys'),
params = {
text: '"some text" with +symbols',
page: 3
},
props = Object.getOwnPropertyNames(params),
body = props.map(function(p){return escape(p) + '=' + escape(params[p])}).join('&'),
client = http.createClient(80, 'example.com'),
request = client.request('POST', '/search', {'content-type': 'application/x-www-form-urlencoded')
request.end(body)
request.on('response', function (r) {
sys.puts('status code: ' + r.statusCode)
// do something with the response
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment