cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: HTTP proxy authentication with wrong username:password hangs

From: Jane Liu <jliu_at_n-able.com>
Date: Tue, 09 Dec 2003 11:33:34 -0500

  Here is what I got from the output, the same contented is repeating
very fast. So it is not hanging, it is just running in a indefinate
loop.

> < HTTP/1.0 407 Proxy Authentication Required
< Server: squid/2.5.STABLE1
< Mime-Version: 1.0
< Date: Tue, 09 Dec 2003 16:26:59 GMT
< Content-Type: text/html
< Content-Length: 1386
< Expires: Tue, 09 Dec 2003 16:26:59 GMT
< X-Squid-Error: ERR_CACHE_ACCESS_DENIED 0
< Proxy-Authenticate: Basic realm="Squid proxy-caching web server"
< X-Cache: MISS from shallett
< Proxy-Connection: close
* Closing connection #0
* Issue another request to this URL:
'http://192.168.40.7/ui/download/3.0.0.37/win32/kill.exe'
* About to connect() to 192.168.20.110:8095
* Connected to 192.168.20.110 (192.168.20.110) port 8095
* Proxy auth using Basic with user 'test'
> GET http://192.168.40.7/ui/download/3.0.0.37/win32/kill.exe HTTP/1.1
Proxy-authorization: Basic dGVzdDo=
Host: 192.168.40.7
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*

Jane Liu wrote:

> Hi,
>
> I need help.
> When I am using HTTP/HTTPS proxy authentication, if username:password
> is correct, there is no problem. But if the username:password is wrong,
> then the program using HTTP hangs, while the program using HTTPS will
> tell me Proxy connect aborted. This is happening on both Linux and
> Windows.
>
> Here is my code for Linux:
>
> #include <stdio.h>
> #include <curl/curl.h>
>
> int main(void)
> {
> CURL *curl;
> CURLcode res;
> FILE *fp;
> char *error_buffer[CURL_ERROR_SIZE];
>
> fp = fopen("/tmp/kill.exe", "wb");
>
> curl = curl_easy_init();
> if(curl) {
> /* First set the URL that is about to receive our POST. This URL can
> just as well be a https:// URL if that is what should receive the
> data. */
> curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buffer);
> curl_easy_setopt(curl, CURLOPT_URL,
> "http://192.168.40.7/ui/download/3.0.0.37/win32/kill.exe");
> /* Now specify the POST data */
> curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
> curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE);
> curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, FALSE);
> curl_easy_setopt(curl, CURLOPT_PROXY,"http://192.168.20.110");
> curl_easy_setopt(curl, CURLOPT_PROXYPORT, 8095);
> curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "test:");
>
> /* Perform the request, res will get the return code */
> res = curl_easy_perform(curl);
> printf("res = %d, message: %s\n", res, error_buffer);
>
> /* always cleanup */
> curl_easy_cleanup(curl);
> }
>
> fclose(fp);
> return 0;
> }
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
> Free Linux Tutorials. Learn everything from the bash shell to sys admin.
> Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click

-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Received on 2003-12-09