Skip to content

Instantly share code, notes, and snippets.

@codeboost
Created November 12, 2010 10:15
Show Gist options
  • Save codeboost/673946 to your computer and use it in GitHub Desktop.
Save codeboost/673946 to your computer and use it in GitHub Desktop.
Sending large buffers through SSL connection causes the other side to stop receiving the data
const
util = require('util'),
net = require('net'),
crypto = require('crypto'),
fs = require('fs'),
Buffer = require('buffer').Buffer,
http = require('http'),
url = require('url');
var privateKey = fs.readFileSync('../cert/privatekey.pem').toString();
var certificate = fs.readFileSync('../cert/certificate.pem').toString();
var credentials = crypto.createCredentials({key: privateKey, cert: certificate});
util.log('SSL certificate and key loaded');
var httpServer = http.createServer(function(req, res){
var buffer = new Buffer(143000);
for (var k = 0; k < buffer.length; k++){
buffer.write('a', k);
}
util.log('HTTP: sending ' + buffer.length + ' bytes');
res.writeHead(200, {'Content-type': 'text/plain', 'Content-length': buffer.length});
res.write(buffer);
res.end();
});
httpServer.setSecure(credentials);
httpServer.listen(81);
util.log('HTTPS server listening on 81');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment