
Rosetree - 2009-05-12 11:42:27
Hi,
Great class, but I'nm struggling with the basic authentication.
My script:
$http = new http_class;
$http->timeout=0;
$http->data_timeout=0;
$http->debug=1;
$http->html_debug=0;
$http->user_agent="own agent string";
$http->follow_redirect=1;
$http->redirection_limit=5;
$http->exclude_address="";
$http->prefer_curl=0;
$user= "correct username";
$password= "correct password";
$realm=""; /* Authentication realm or domain */
$workstation=""; /* Workstation for NTLM authentication */
$authentication=(strlen($user) ? UrlEncode($user).":".UrlEncode($password)."@" : "");
$error=$http->GetRequestArguments($url,$arguments);
if(strlen($realm))
$arguments["AuthRealm"]=$realm;
if(strlen($workstation))
$arguments["AuthWorkstation"]=$workstation;
$http->authentication_mechanism=""; // force a given authentication mechanism;
$arguments["Headers"]["Pragma"]="nocache";
$arguments["Headers"]["Accept-Language"]="nl, nl-nl, nl-be";
and onwards the default code Open/SendRequest/ReadReplyHeaders
I tried to add:
$arguments["AuthUser"]= UrlEncode($user);
$arguments["AuthPassword"]= UrlEncode($password);
$arguments["RequestMethod"]="GET";
to the script, no luck:
url = http://new-www.cyso.nl/ with: username:password
debug response:
Connecting to new-www.cyso.nl
Resolving HTTP server domain "new-www.cyso.nl"...
Connecting to HTTP server IP 93.94.224.133 port 80...
Connected to new-www.cyso.nl
C GET / HTTP/1.1
C Host: new-www.cyso.nl
C User-Agent: own agent string
C Pragma: nocache
C Accept-Language: nl, nl-nl, nl-be
C
S HTTP/1.1 401 Authorization Required
S Server: nginx/0.6.32
S Date: Tue, 12 May 2009 11:35:17 GMT
S Content-Type: text/html; charset=iso-8859-1
S Connection: keep-alive
S WWW-Authenticate: Basic realm="Sorry, not public!"
S Content-Length: 519
S
Disconnected from new-www.cyso.nl
error server response: 401
What am I doing wrong?
thx,
M