HiĀ !

I'm kind of new to this mailing list, I hope I did post this message correctly 
and in the right place.

I'm facing a strange issue with libcurl and I do not understand if this is a 
"standard" behavior: I'm using libcurl to send multiple file to a web server on 
an embedded system. This web server can unfortunately not handle multipart 
requests. So I have to send each files one after the other. The files are 
pretty light (~10k). The problem is that for each transfer, libcurls falls one 
or two times in a select() timeout of 1000[ms]. Each files takes 2 seconds to 
transfer... which is too much ofr our client.

On libcurl side, the select timeout is in select.c, in Curl_socket_ready() 
function when the windows api select() function is called. Since we are 
supporting windows XP on the client side, we can not use the macro 
HAVE_POLL_FINE.

On our side, The code we use to send a file is the following (the cleanup of 
the CURL handle is done in the destructor. The object "CurlWrapper" is 
recreated for each transfer) :

int CurlWrapper::PushFile(
        const YString& _sourcePath,
        const YString& _URL,
        const YString& _targetFileName,
        bool* bCancelFlag)
{
        m_formpost = NULL;
        m_lastptr = NULL;
        m_headerlist = NULL;


        /* Fill in the file upload field */ 
        curl_formadd(
                &m_formpost,
                &m_lastptr,
                CURLFORM_COPYNAME, "sendfile",
                CURLFORM_FILE, _sourcePath.c_str(),
                CURLFORM_END );

        /* Fill in the filename field */ 
        curl_formadd(
                &m_formpost,
                &m_lastptr,
                CURLFORM_COPYNAME, "filename",
                CURLFORM_COPYCONTENTS, _targetFileName.c_str(),
                CURLFORM_END );

        /* Fill in the submit field too, even if this is rarely needed */ 
        curl_formadd(
                &m_formpost,
                &m_lastptr,
                CURLFORM_COPYNAME, "submit",
                CURLFORM_COPYCONTENTS, "send",
                CURLFORM_END );

        CURLcode res = CURLE_INTERFACE_FAILED;

        if ( m_curl_handle )
        {
                LOG_KMS_INFO( "CURL Handle successfully created" );

                //Todo construct URL

                curl_easy_setopt( m_curl_handle, CURLOPT_URL, _URL.c_str() );
                curl_easy_setopt( m_curl_handle, CURLOPT_PORT, m_port );
                curl_easy_setopt( m_curl_handle, CURLOPT_WRITEFUNCTION, 
&LOGWriter );
                curl_easy_setopt( m_curl_handle, CURLOPT_HTTPPOST, m_formpost );
                curl_easy_setopt( m_curl_handle, CURLOPT_PROGRESSDATA, 
bCancelFlag );

                LOG_KMS_INFO( "Sending HTTP request" );

                res = curl_easy_perform( m_curl_handle );

                if ( res != 0 )
                        LOG_KMS_INFO( "HTTP request returned error %d.", res );
                else
                        LOG_KMS_INFO( "Upload complete!" );

                /* cleanup */ 
                curl_formfree( m_formpost );
        //      curl_slist_free_all( headerlist );
        }
        else
        {
                LOG_KMS_INFO( "CURL Handle not created (Init error?)" );
        }
        return TranslateCurlError(res);
}

Has anyone already faced this issue ? Am I doing something completely wrong in 
my code ?

Thanks in advance for the help,

Daniel Peppicelli
Software engineer
Switzerland




Please be advised that this email may contain confidential 
information.  If you are not the intended recipient, please notify us 
by email by replying to the sender and delete this message.  The 
sender disclaims that the content of this email constitutes an offer 
to enter into, or the acceptance of, any agreement; provided that the 
foregoing does not invalidate the binding effect of any digital or 
other electronic reproduction of a manual signature that is included 
in any attachment.



-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to