Skip to content

Instantly share code, notes, and snippets.

@chapel
Forked from solmenor/receiver.js
Created February 19, 2011 20:07
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 chapel/835322 to your computer and use it in GitHub Desktop.
Save chapel/835322 to your computer and use it in GitHub Desktop.
var http = require('http');
var querystring = require('querystring');
var data = {
message: 'Hello'
};
var form_data = querystring.stringify(data);
var options = {
host: 'localhost',
port: 8088,
path: '/test',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': form_data.length
}
};
var req = http.request(options);
req.write(form_data);
req.end();
var express = require('express');
var app = express.createServer();
app.use(express.bodyDecoder());
app.post('/test', function(req, res){
console.log(req.body.message);
});
app.listen(8088);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment