cURL / Mailing Lists / curl-library / Single Mail

curl-library

Can someone explain why curl_easy_reset is not working?

From: Jonathan C. <well.bad_at_hotmail.com>
Date: Sat, 24 May 2014 05:58:50 +0000

This is the code: https://github.com/JCMais/node-libcurl/blob/develop/src/Curl.cc#L938

It's a binding for Node.js.

I cannot put the whole code here in context. But the binding for the reset method is basically just:

    curl_easy_reset( obj->curl );

Where obj->curl is a pointer to the curl handler in question.

However, looks like it's not resetting the handler, I tested it doing a request, resetting it, and calling perform immediately after (the perform method adds the handler to the internal multi curl instance).

Expected result: An error is thrown, because there is no url set for given handler.
Current result: It does another request to the url set previously.

Code to test if anyone is willing to do so (need to have node.js installed, and node-libcurl, npm install node-libcurl):

var Curl = require( 'node-libcurl' ).Curl;

var curl = new Curl(),
    url = process.argv[2] || 'http://www.google.com',
    firstRun = true;

//you can use a string as option
curl.setOpt( 'URL', url );
curl.setOpt( Curl.option.VERBOSE, true );

curl.on( 'end', function ( statusCode, body, headers ) {

    if ( !firstRun )
        throw Error( "Reset didn't worked." );

    firstRun = false;

    this.reset();

    this.perform();

});

curl.on( 'error', function ( err, curlErrCode ) {

    console.error( 'Err: ', err );
    this.close();
});

curl.perform();

Jonathan Cardoso Machado [JCM]
Full-stack Web Developer
                                               
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-05-24