tags:

views:

35

answers:

0

I am trying to serve some JavaScript files with Node.js and for whatever reason the files are being cut off in the middle of the transmission. The code:

httpsServer = http.createServer(function(req, res) {
    var path = url.parse(req.url).pathname;

    if (path[path.length - 1] == '/') {
            path += 'index.html';
    }

    fs.readFile(root + path, function(err, data){
            if (err) return send404(res);

            res.writeHead(200, {
                'Content-Type': getMimeType(getExtension(path)),
                'Content-Length': data.length});
            res.end(data);

    });
}),

var privateKey = fs.readFileSync(settings.PRIVATE_KEY).toString();
var certificate = fs.readFileSync(settings.CERTIFICATE).toString();

var credentials = crypto.createCredentials({key: privateKey, cert: certificate});
httpsServer.setSecure(credentials);
httpsServer.listen(settings.HTTPS_PORT);

The files http://github.com/LearnBoost/Socket.IO/raw/master/socket.io.js and http://code.jquery.com/jquery-1.4.2.min.js. The first one is cut off at exactly 32KB and the second at exactly 16KB. This does not happen over HTTP, only HTTPS and only over a network (e.g.: not from localhost).

Any help would be really appreciated.