/**
 * Send html with status code.
 * @function serverside.res._sendFile
 * @param {object} res - Response object.
 * @param {string} filename - Html file name.
 * @param {options} [options] - Optional settings.
 * @param {number} [options.statusCode=200] - Status code to set.
 * @param {string} [options.contentType=''] - Content type to set.
 * @param {function} callback - Callback when done.
 * @protected
 * @todo cache
 * @ignore
 * @author Taka Okunishi
 *
 */
var fs = require('fs');
module.exports = function (res, filename, options, callback) {
    fs.stat(filename, function (err, stats) {
        if (err) {
            callback && callback(err);
            return;
        }
        var statusCode = options.statusCode || 200,
            contentType = options.contentType || 'application/octet-stream';
        res.writeHead(statusCode, {
            'Content-Type': contentType,
            'Content-Length': stats.size
        });
        var stream = fs.createReadStream(filename);
        stream.pipe(res);
        callback(null);
    });
};