cURL / Mailing Lists / curl-library / Single Mail

curl-library

Strange intermittent problems with libcurl and SQUID

From: Andreas Falco <andreasfalco_at_hotmail.com>
Date: Fri, 28 Nov 2003 13:20:03 -0800

I use libcurl.dll with SSL support from a C++ program under windows 98 and
XP. With a direct internet connection everything works just fine. But when I
go through SQUID running on our linux gateway, set up to operate only with
passwordsthings go wrong. Some of the time I can get through without
problems, but most of the time I receive 'Proxy requires authorization (56)'
  When I run SQUID using the maximum debug level I see in the log file that
the last letter of my password gets corrupted. I could not find an error in
my code.

Can you help me?

Here is the code I use (Remarks: 1. AnsiString is Borland's string class, if
s is an AnsiString then s.c_str() is the character pointer, 2. the debug
function logs all messages and from the log It seems that the correct
password is used):
/----------------------------------------------------------------------------------------------------
curl = curl_easy_init();
if(curl)
{
   sprintf(postthis, "user=%s&pwd=%s&file=%s&dest=@CF01", sUser.c_str(),
                       sPwd.c_str(), name);

   curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_NONE);
   curl_easy_setopt(curl, CURLOPT_URL, sServer);
   curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis);
   curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
   /* if we don't provide POSTFIELDSIZE, libcurl will strlen() by
      itself */
   curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(postthis));
   curl_easy_setopt(curl, CURLOPT_TIMEOUT, 600);
   curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, Progress);
   curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false);
   curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buff);
   curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);

   if(proxyEnabled)
   {
     curl_easy_setopt(curl, CURLOPT_PROXYPORT, lProxyPort);
     curl_easy_setopt(curl, CURLOPT_PROXY, sProxy.c_str());
     AnsiString s = (sProxyUser + ":" + sProxyPwd);
     curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, s.c_str());
   }
   ffOut = fopen(fname, "wb");

   if(!ffOut) // if a file with this name has already been
downloaded
   {
     // error message here
     lblError->Caption = "A '" + (AnsiString)fname + "' fájl nem hozható
létre!";
     curl_easy_cleanup(curl);

     return -4; // signal error
   }
#ifndef _SIMUL_
// DEBUG
#ifdef _DEBUG_
   curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
   curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, _debug_function);
#endif
// end DEBUG
   res = curl_easy_perform(curl);
   if(res)
     lblError->Caption = (AnsiString)error_buff + " (" + IntToStr(res) +
")";

   /* always cleanup */
   curl_easy_cleanup(curl);

   fclose(ffOut);
}
return res;
----------------------------------------------------------------------/

Thank you
                                                   Andras

_________________________________________________________________
Gift-shop online from the comfort of home at MSN Shopping! No crowds, free
parking. http://shopping.msn.com

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
Received on 2003-11-28