<commit_before>'use strict';

var $http = require('request');

module.exports = function (req, res) {
    if (req.query && req.query.url) {
        $http
            .get({
                url: encodeURI(decodeURI(req.query.url)),
                headers: {
                    'User-Agent': 'googlebot'
                }
            })
            .pipe(res)
            .on('error', function (err) {
                res.status(404).json({
                    err: err || true,
                    msg: 'error request'
                });
            });
    } else {
        res.status(404).json({
            err: true,
            msg: 'error url'
        });
    }
};<commit_msg>fix api get res on close<commit_after>'use strict';

var $http = require('request');

module.exports = function (req, res) {
    if (req.query && req.query.url) {
        var _req = $http
            .get({
                url: encodeURI(decodeURI(req.query.url)),
                headers: {
                    'User-Agent': 'googlebot'
                }
            })
            .on('error', function (err) {
                res.status(404).json({
                    err: err || true,
                    msg: 'error request'
                });
            })
            .pipe(res);
    } else {
        res.status(404).json({
            err: true,
            msg: 'error url'
        });
    }

    res.on('close', function () {
        if (_req && typeof _req.destroy === 'function') {
            _req.destroy();
        }
    });
};
{'fraction_non_alphanumeric': 0.14780902550686723, 'fraction_numerical': 0.007848266841072597, 'mean_word_length': 1.1191135734072022, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '237641', 'n_tokens_mistral': 443, 'n_tokens_neox': 417, 'n_words': 89}