Skip to content

Instantly share code, notes, and snippets.

@stash
Created July 9, 2013 23:38
Show Gist options
  • Select an option

  • Save stash/5962276 to your computer and use it in GitHub Desktop.

Select an option

Save stash/5962276 to your computer and use it in GitHub Desktop.
Node script that pretends to send a 10 MiB JSON to an https server, but then just hangs there.
/*jshint node:true */
'use strict';
var tls = require('tls');
var auth = new Buffer('username:password').toString('base64');
var CRLF = "\r\n";
var opts = {
host: '127.0.0.1',
port: 443,
servername: 'host',
rejectUnauthorized: false
};
var size = process.argv[2] || '10485760';
var sock = tls.connect(opts, function() {
var head = [
'POST /v1/apps/2/acl HTTP/1.1',
'Host: host',
'Authorization: Basic '+auth,
'Content-Type: application/json',
'Content-Length: '+size,
''
].join(CRLF) + CRLF;
// process.stdout.write(head);
sock.write(head);
// just hang
});
sock.pipe(process.stdout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment