cURL / Mailing Lists / curl-library / Single Mail

curl-library

[Q]: http proxy authorization using libcurl --III?

From: James Kuo <jskuo_at_cht.com.tw>
Date: Mon, 11 Aug 2003 16:59:35 +0800

Hi,

Thanks for your reply.

This problem is occurred because of referencing to an invalid variable.
The variable szProxyInfo is disappear before curl_easy_perform is executed.
As a consequence, there's no any information is sent to curl actually.

if (!szProxy_.empty()) {
string szProxyInfo(szProxy_ + ":" + szPort_);
if (!szProxy_.empty()) ::curl_easy_setopt(hCurl_, CURLOPT_PROXY,
szProxyInfo.c_str());

// the same situation
//if (!szProxy_.empty()) ::curl_easy_setopt(hCurl_, CURLOPT_PROXY,
(szProxy_ + ":" + szPort_).c_str());
}

::curl_easy_perform(hCurl_);

Finally, I solved this problem today.

When I changed the above code to the following, it worked.
It means that curl only copy the address of variables, not the cotents
of the variables.
The same situation occurred in sending username and passwd to curl.

Wstring szProxyInfo(szProxy_ + ":" + szPort_);
Wstring szUserInfo(szUser_ + ":"+ szPasswd_);

//if (!IsBypassProxyHost(chUrl)) {
if (!szProxy_.empty()) ::curl_easy_setopt(hCurl_, CURLOPT_PROXY,
szProxyInfo.c_str());
}
....
::curl_easy_perform(hCurl_);

Thanks.

James Kuo

>>It's also fine when I used the command-line version curl.exe in the dos-box.
>>I issues such a command in the dos-box and it's ok.
>>"curl --proxy 10.100.100.100:8080 --proxy-user user_abc:passwd_abc
>>--dump-header a.txt --verbose www.google.com"
>>
>>It's fine when fetching pages in those sites behind my http proxy using
>>my program called libcurl directly.
>>However, when my program tried to access those pages outside of proxy,
>>some problems got, especially in proxy authorization.
>>
>>
>
>I don't think I follow you here. You can get pages fine through the proxy, but
>not without it? Isn't that because of how your network is setup?
>
>
>
>>When I issue these instructions in my program, te libcurl returned a code of
>>5 which means
>>
>>"Couldn't resolve proxy. The given proxy host could not be resolved." found
>>in http://curl.haxx.se/libcurl/c/libcurl-errors.html
>>
>>
>
>That would indicate that you passed a bad proxy name to libcurl.
>
>
>
>>It seemed that I didn't submit correct username and password.
>>
>>
>
>It does. Check the headers libcurl sends off when used with your program and
>compare them with those that curl the tool sends off. The Proxy-Authorization:
>headers should be identical.
>
>
>

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
Received on 2003-08-11