Skip to content

Instantly share code, notes, and snippets.

@cou929
Created July 14, 2012 17:23
Show Gist options
  • Save cou929/3112275 to your computer and use it in GitHub Desktop.
Save cou929/3112275 to your computer and use it in GitHub Desktop.
set test cookie and return beacon gif
var http = require('http');
var imgdata = [
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01,
0x00, 0x80, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
0x00, 0x21, 0xf9, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,
0x2c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
0x00, 0x02, 0x02, 0x44, 0x01, 0x00, 0x3b
];
var imgbuf = new Buffer(imgdata);
http.createServer(function(request, response) {
console.log(request);
response.writeHead(200, {
'Content-Type': 'image/gif',
'Content-Length': imgdata.length,
'Set-Cookie': ['type=hoge; domain=cookietest.cou929.nu; path=/'],
'Cache-Control': 'private, no-cache, no-cache="Set-Cookie", proxy-revalidate'
});
response.end(imgbuf);
}).listen(5001);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment