cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl-library Digest, Vol 91, Issue 58

From: subrahmanya <sum.sagar_at_gmail.com>
Date: Sat, 23 Mar 2013 17:44:55 +0530

Hi

Yes I've registered CURLOPT_READFUNCTION. The function returns value
"(size_t) -1" when there is no more data to write.

Here is the definition of the function.
size_t request_callback(void *ptr, size_t size, size_t nmemb, void *userp)
{
    struct RequestBuffferStruct *req = (struct RequestBuffferStruct*)userp;
    size_t totalSize = size*nmemb;

    // If size empty, cannot write.
    if(totalSize < 1)
        return 0;

     // Write header (copy to CURL buffer)
    if(req->headerSize)
    {
        return copy(ptr, totalSize,
                        &(req->headerBuf), &(req->headerSize));
    }

    // Write object (copy to CURL buffer)
    if(req->objSize)
    {
        return copy(ptr, totalSize,
                        &(req->objBuf), &(req->objSize));
    }

    // Write footer (copy to CURL buffer)
    if(req->footerSize)
    {
        return copy(ptr, totalSize,
                        &(req->footerBuf), &(req->footerSize));
    }

    /* no more data left to deliver */
    return (size_t)-1;
}

Thanks
Subrahmanya

Date: Fri, 22 Mar 2013 13:50:56 +0100
From: Gisle Vanem <gvanem_at_broadpark.no>
To: libcurl development <curl-library_at_cool.haxx.se>
Subject: Re: Unable to send/receive messages using curl (version
        7.28.1)
Message-ID: <7366872DBDC847C29FD618D342D0EFD5_at_dev.null>
Content-Type: text/plain; CHARSET=US-ASCII; format=flowed;
        reply-type=original

"subrahmanya" <sum.sagar_at_gmail.com> wrote:

> When I run my application I get the value "-1" for "nread". This was not
> considered as error till 7.18.0 release. From release 7.18.0 onwards this
> value is treated as error because of the condition "if((size_t)nread >
> buffersize)". And hence my application breaks.

Do you have a read callback set with 'CURLOPT_READFUNCTION'? If so,
it could be returning a wrong value. Show it to us.

--gv
Date: Fri, 22 Mar 2013 17:43:01 +0530

> From: subrahmanya <sum.sagar_at_gmail.com>
> To: curl-library_at_cool.haxx.se
> Subject: Unable to send/receive messages using curl (version 7.28.1)
> Message-ID:
> <
> CABoXzYKyVvBT4QAs7FqzeB+t-TxCw3YRrPhj0a6rk8Z2fyju5w_at_mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi
>
> We've an application that uses CURL to exchange data with a Java-based HTTP
> server. Till now we were using very older version of CURL (7.15.1). Now we
> are trying to move to the version 7.28.1. But after moving to 7.28.1 our
> application does not work. It fails in "curl_easy_perform" function with
> error "couldn't open/read from file". What would be the reason for the
> failure? Is there any change in the way we have to use APIs between these
> versions?
>
> I tried my application against 7.19.6 it does not work with this version as
> well. The reason for the failure looks to be because of the changes done in
> version "7.18.0". In the below piece of code the lines marked in RED are
> added freshly in 7.18.0 in "Curl_fillreadbuffer" function.
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> if(nread == CURL_READFUNC_ABORT) {
> failf(data, "operation aborted by callback");
> *nreadp = 0;
> return CURLE_ABORTED_BY_CALLBACK;
> }
> else if(nread == CURL_READFUNC_PAUSE) {
> struct SingleRequest *k = &data->req;
> /* CURL_READFUNC_PAUSE pauses read callbacks that feed socket writes */
> k->keepon |= KEEP_SEND_PAUSE; /* mark socket send as paused */
> if(data->req.upload_chunky) {
> /* Back out the preallocation done above */
> data->req.upload_fromhere -= (8 + 2);
> }
> *nreadp = 0;
> return CURLE_OK; /* nothing was read */
> }
> else if((size_t)nread > buffersize) {
> /* the read function returned a too large value */
> *nreadp = 0;
> failf(data, "read function returned funny value");
> return CURLE_READ_ERROR;
> }
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> When I run my application I get the value "-1" for "nread". This was not
> considered as error till 7.18.0 release. From release 7.18.0 onwards this
> value is treated as error because of the condition "if((size_t)nread >
> buffersize)". And hence my application breaks.
>
> Is it a bug in CURL? Or does it require my code to be modified?
>
> Thanks
> Subrahmanya
>
>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-03-23