0

I use this code:

var options = {
    hostname: 'torcache.net',
    path: '/torrent/4C1E01E1E7AE19082F4BAC9C3C82B5B2CD0EEA23.torrent',
    port: 80,
    method: 'GET'
};

http.request(options, function (res) {

    var chunks = [];
    res.on('data', function (chunk) {
        chunks.push(chunk);
    });

    res.on('end', function () {
        if (res.statusCode !== 200) {
            callback(res.statusCode);
            return;
        }

        //...
    });
}).on('error', function (err) {
    callback(err);
}).end();

the statusCode is 200, but open the url(http://torcache.net/torrent/4C1E01E1E7AE19082F4BAC9C3C82B5B2CD0EEA23.torrent) is Chrome, the statusCode is 404. what's wrong with the code?

update:
I find if I use this options:

{
    hostname: 'torcache.net',
    path: '/torrent/4C1E01E1E7AE19082F4BAC9C3C82B5B2CD0EEA23.torrent',
    port: 80,
    method: 'GET',
    secureProtocol: 'SSLv3_method',
    headers: {
        'accept-charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
        'accept-language': 'en-US,en;q=0.8',
        'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2',
        'accept-encoding': 'gzip,deflate',
        'referer': 'http://torcache.net'  // !!!
    }
}

when the headers['referer'] is not null, the res.statusCode is wrong. but I don't know why?

0

1 Answer 1

1

The request does indeed return with a 200. It is later redirect with JavaScript to a 404 page, which Node doesn't follow.

Sign up to request clarification or add additional context in comments.

1 Comment

if the headers['referer'] is null, the request return with 200.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.