cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: HTTP Authentication failed!!

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Wed, 21 Dec 2011 00:33:50 -0800

On Wed, Dec 21, 2011 at 04:25:07PM +0800, hui wrote:
> About HTTP Authentication failed
>
> video its URL have no "username:password" can be play,
> now I want to play the video its URL is "http://
> etele:Xdr56tFc_at_89.147.64.204:8888/RtlKlub", play failed!!!
>
> following is options set:
>
> curl_easy_setopt(fileData->curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
> curl_easy_setopt(fileData->curl, CURLOPT_USERPWD, "etele:Xdr56tFc");
>
> curl_easy_setopt(fileData->curl, CURLOPT_HTTP_VERSION,
> CURL_HTTP_VERSION_1_1);
> curl_easy_setopt(fileData->curl, CURLOPT_URL, "http://
> 89.147.64.204:8888/RtlKlub");
> curl_easy_setopt(fileData->curl, CURLOPT_VERBOSE, 1);
> curl_easy_setopt(fileData->curl, CURLOPT_NOPROGRESS, 1);
> curl_easy_setopt(fileData->curl, CURLOPT_FORBID_REUSE, 1);

Note that these integers and all the others set here must be of type long,
not int. And unless you have a specific reason to do so, you shouldn't need
to set CURLOPT_FORBID_REUSE.

> curl_easy_setopt(fileData->curl, CURLOPT_WRITEDATA, file);
> curl_easy_setopt(fileData->curl, CURLOPT_WRITEFUNCTION, write_callback);
> curl_easy_setopt(fileData->curl, CURLOPT_WRITEHEADER, file);
> curl_easy_setopt(fileData->curl, CURLOPT_HEADERFUNCTION, header_callback);
>
> curl_easy_setopt(fileData->curl, CURLOPT_USERAGENT, " TechniSat Mediaplayer
> (CE-HTML); HbbTV/1.1.1 (; ; ; ; ; )");
>
> #ifdef PROXY_SETTING // PROXY_SETTING not define
> curl_easy_setopt(fileData->curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
> curl_easy_setopt(fileData->curl, CURLOPT_PROXY, (char*)"http://
> 164.129.133.10:8080");
> curl_easy_setopt(fileData->curl, CURLOPT_PROXYUSERPWD, "username:password");
> #endif /* PROXY_SETTING */
>
> #ifdef URL_REDIRECTION // URL_REDIRECTION have been defined
> curl_easy_setopt( fileData->curl, CURLOPT_FOLLOWLOCATION, TRUE );
> curl_easy_setopt( fileData->curl, CURLOPT_MAXREDIRS, 10 );
> #endif /* URL_REDIRECTION */
>
> if (headers)
> {
> curl_easy_setopt(fileData->curl, CURLOPT_HTTPHEADER, headers);
> }
>
>
>
> following is debug infos:
>
> * About to connect() to 89.147.64.204 port 8888 (#0)
> * Trying 89.147.64.204... * Connected to 89.147.64.204 (89.147.64.204) port
> 8888 (#0)
> > GET /RtlKlub HTTP/1.1
>
> User-Agent: TechniSat Mediaplayer (CE-HTML); HbbTV/1.1.1 (; ; ; ; ; )
>
> Host: 89.147.64.204:8888
>
> Accept: */*
>
>
> * HTTP 1.0, assume close after body
> < HTTP/1.0 403 Forbidden
> < Server: MCast server 0.1
>
> < Accept-Ranges: bytes
>
> < Allow: GET
> < Select Timeout
> * Closing connection #0

HTTP error code 403 is defined in the HTTP/1.1 spec as:

   The server understood the request, but is refusing to fulfill it.
   Authorization will not help and the request SHOULD NOT be repeated.

So, since there's no point in trying again, libcurl (correctly) aborts.
If the server is actually lying and should be returning error code 401,
you could try setting CURLOPT_HTTPAUTH to a specific authentication
method and the server might let you in. I suspect that the problem is
elsewhere, though, like an incorrect URL or a missing cookie.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-12-21