discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loading a website with GNUstep (authentication)


From: Andreas Hoeschler
Subject: Re: Loading a website with GNUstep (authentication)
Date: Sat, 11 May 2002 16:18:17 +0200

Hello Richard,

Use the -resourceDataUsingCache: method of NSURL to get the data,
then use the -initWithDate:encoding: method of NSString to put it in a string.


eg.

NSURL *url = [[NSURL alloc] initWithString: @"http://www.mydomain.de/file.html";];
  NSData *data = [url resourceDataUsingCache: NO];
NSString *htmlCode = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];


Of course, there are much more sophisticated things you can do about error checking etc, but
that's about the simplest code.

Thanks for your reply. The answer to my question is so obvious. I feel a bit like a fool... I tried it and of course it worked at least principally. Unfortunately the machine (web site) I want to grab the html page from requires authentication. So instead of the page I am interested in I get back

<html>
  <head>
  <title>401 Unauthorized</title>
  </head>
<body>

<div align="center"><center>
<table border="1" cellspacing="0" width="100%">
  <tr>
    <td width="100%" bgcolor="#0000A0">
    <p align="center"><font color="#FFFFFF" face="Arial">
    <strong>401 Unauthorized !!!</strong></font></td>
  </tr>
  <tr>
<td width="100%" bgcolor="#F3F3F3" bordercolor="#000080" bordercolordark="#000080">
    <p align="center"><font face="Times New Romain" color="#000000">
<strong>Browser not authentication-capable or authentication failed.</strong></font></td>
  </tr>
</table>
</body>
</html>

Is there any easy way to programmatically pass the user account (username and password) in order to get the page I am really interested in?

Thanks a lot,

   Andreas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]