Skip to content

Instantly share code, notes, and snippets.

@drj11
Created May 24, 2012 15:27
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 drj11/2782236 to your computer and use it in GitHub Desktop.
Save drj11/2782236 to your computer and use it in GitHub Desktop.
drj$ cat fixture.js
nock=require('nock')
nock('www.google.com')
.get('/')
.reply(200, "<HTML><HEAD><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">\n<TITLE>BOB</TITLE></HEAD><BODY>\n<H1>Hello from nock</H1>\r\n</BODY></HTML>\r\n", { location: 'http://www.google.co.uk/',
'content-type': 'text/html; charset=UTF-8',
date: 'Thu, 24 May 2012 15:08:01 GMT'
});
drj$ cat get.js
http.get({host:'www.google.com',port:80,path:'/',method:'GET'},function(res){res.on('data', function(chunk){console.log('chunk '+chunk)})})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment