Skip to content

Instantly share code, notes, and snippets.

@carlosvillu
Created March 2, 2012 11:21
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 carlosvillu/1957869 to your computer and use it in GitHub Desktop.
Save carlosvillu/1957869 to your computer and use it in GitHub Desktop.
(function() {
var google, nock, req, request;
request = require('http').request;
nock = require('nock');
google = nock("www.google.com").get('/').reply(200, {
response: "ok!"
});
req = request({
host: 'www.google.com',
port: 80,
path: '/',
method: 'GET'
}, function(res) {
var response;
response = '';
res.on('data', function(chuck) {
console.log('Datos: ', chuck.toString());
return response += chuck;
});
return res.on('end', function() {
return console.log("Respuesta: ", response);
});
});
req.end();
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment