chill117 / proxy-verifier

NodeJS module to check proxies: if functional, anonymity level, tunneling, supported protocols.
MIT License
76 stars 16 forks source link

Pass request option in Test function #19

Closed mnlbox closed 7 years ago

mnlbox commented 7 years ago

Is it possible to set request options in Test function like testAll and other functions? I can't see related note in docs. I want to increase request connection timeout value. Can you guide me about it?

chill117 commented 7 years ago

Yes, this is possible. You can use the requestOptions option, like this:

ProxyVerifier.test(proxy, {
    requestOptions: {
        // request options go here.
    },
    testUrl: 'https://www.google.com/?q=test',
    testFn: function(data, status, headers) {

        // Check the response data, status, and headers.

        // Throw an error if the test failed.
        throw new Error('Test failed!');

        // Do nothing if the test passed.
    }
}, function(error, results) {
    // Do something with error or results.
});

This isn't documented yet, but it should be stable enough to use going forward.