cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

curl_easy_reset AND How I'm a CVS Idiot...

From: Casey ODonnell <caseyodonnell_at_gmail.com>
Date: Tue, 6 Jul 2004 10:48:30 -0400

I'm completely unfamiliar with CVS (VSS having contributed to this
lacking), but I wanted to go ahead and put this code out there for
everyone to peruse and test. I'm using it to reset my SessionHandle
in an existing application, and it seems to be working well.

At the same time, I'm not familiar with the code well enough to ensure
that I'm not munging anything. Based on the documentation, I
shouldn't be...I'm not an SSL user either, so again...I could be doing
bad things.

I don't know who should test/check this into the code tree, but if
anyone who was having trouble with residual data in their CURL handles
could test this, it would be wonderful. I don't touch any code
elsewhere, so it should be a safe addition.

It isn't a very useful function for one-shot or single-type (only
GET/PUT/etc) activity from LibCURL. It's only useful if you're doing
several heterogeneous calls to LibCURL with the same handle, but want
to return that handle to a more generic state. (I'm using it to make
several "custom" calls (WebDAV), and I tend to do PROPGET's and PUT's
interspersed with one another).

Cheers.
Casey

Here are the changes I made:

Added to /include/curl/easy.h:

/*
 * NAME curl_easy_reset()
 *
 * DESCRIPTION
 *
 * Re-initializes user defined (UserDefined) data in the session handle. The
 * entire struct is zeroed out, and then initialized to the cURL defaults.
 *
 */
void curl_easy_reset(CURL *curl);

Added to /lib/easy.c:

/*
 * curl_easy_reset() is an external interface that allows an app to re-
 * initialize a session handle to the default values.
 */
void curl_easy_reset(CURL *curl)
{
        struct SessionHandle *data = (struct SessionHandle *)curl;

        memset(&data->set, 0, sizeof(struct UserDefined)); /* zero out
UserDefined data */
        memset(&data->progress, 0, sizeof(struct Progress)); /* zero out
Progress data */

        /* The remainder of these calls have been taken from Curl_open() */

    data->set.out = stdout; /* default output to stdout */
    data->set.in = stdin; /* default input from stdin */
    data->set.err = stderr; /* default stderr to stderr */

    /* use fwrite as default function to store output */
    data->set.fwrite = (curl_write_callback)fwrite;

    /* use fread as default function to read input */
    data->set.fread = (curl_read_callback)fread;

    data->set.infilesize = -1; /* we don't know any size */

    data->state.current_speed = -1; /* init to negative == impossible */

    data->set.httpreq = HTTPREQ_GET; /* Default HTTP request */
    data->set.ftp_use_epsv = TRUE; /* FTP defaults to EPSV operations */
    data->set.ftp_use_eprt = TRUE; /* FTP defaults to EPRT operations */

    data->set.dns_cache_timeout = 60; /* Timeout every 60 seconds by default */

    /* make libcurl quiet by default: */
    data->set.hide_progress = TRUE; /* CURLOPT_NOPROGRESS changes these */

    /* Set the default size of the SSL session ID cache */
    data->set.ssl.numsessions = 5;

    data->set.proxyport = 1080;
    data->set.proxytype = CURLPROXY_HTTP; /* defaults to HTTP proxy */
    data->set.httpauth = CURLAUTH_BASIC; /* defaults to basic */
    data->set.proxyauth = CURLAUTH_BASIC; /* defaults to basic */

    /*
     * libcurl 7.10 introduced SSL verification *by default*! This needs to be
     * switched off unless wanted.
     */
    data->set.ssl.verifypeer = TRUE;
    data->set.ssl.verifyhost = 2;
#ifdef CURL_CA_BUNDLE
    /* This is our prefered CA cert bundle since install time */
    data->set.ssl.CAfile = (char *)CURL_CA_BUNDLE;
#endif
}

Added to /lib/libcurl.def:

curl_easy_reset @ 43
Received on 2004-07-06

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET