Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Downloading off a .mac homepage

Downloading off a .mac homepage
Thread Tools
Fresh-Faced Recruit
Join Date: Dec 2001
Location: Wisconsin
Status: Offline
Reply With Quote
Jul 22, 2003, 12:16 AM
 
I am trying to download a file off a .mac account. I wrote a small program like this:
[socket connectToHost:someHost port:80];
[socket writeString:@"GET %@ HTTP/1.1\r\n\r\n", theDirectory];
while ([socket isConnected])
[socket readData:data];
NSLog(@"%@", [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]);
This works for basically every web page. However, on a .mac page, i just get something like this:
HTTP/1.1 403 Forbidden
Date: Tue, 22 Jul 2003 05:09:41 GMT
Content-Length: 257
Content-Type: text/html
Server: NetCache (NetApp/5.2.1R2D2)

<HTML>
<HEAD><TITLE>403 Forbidden</TITLE></HEAD>
<BODY>
<H1>Forbidden</H1>
<H4>
You were denied access because:<P>
Access denied by access control list.

</H4>
<HR>
</BODY>
</HTML>
But if i type the address into a browser, the page will come up fine. It isn't password protected but other parts of the site are. How can I fix this...
     
Mac Elite
Join Date: Sep 2000
Location: New York
Status: Offline
Reply With Quote
Jul 25, 2003, 11:10 AM
 
Just an idea since I don't know much about this, but maybe you should add a fake user agent string. The server may be rejecting what it thinks are webcrawlers or non-browser clients.
     
Banned
Join Date: Apr 2002
Location: -
Status: Offline
Reply With Quote
Jul 25, 2003, 11:34 AM
 
Originally posted by seppak:
I am trying to download a file off a .mac account. I wrote a small program like this:This works for basically every web page. However, on a .mac page, i just get something like this:

But if i type the address into a browser, the page will come up fine. It isn't password protected but other parts of the site are. How can I fix this...
HTTP is pretty tricky.

Use CURLHandle instead (or NSURLHandle)

http://curlhandle.sf.net

it comes with a nice example application.
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jul 27, 2003, 09:36 AM
 
Either that or you could use the new stuff in Foundation as of Safari 1.0 (NSURL*)
     
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
Jul 27, 2003, 11:20 PM
 
You are being refused because that is an invalid HTTP/1.1 request. All HTTP/1.1 requests MUST have a Host: header in the request, or send an absolute URI in the request. Sending an absolute URI in the request however, should, as of HTTP/1.1, only be used when talking directly to a proxy (transparent proxies don't count in this case).

Your request should look something like this:

GET /steve/ HTTP/1.1
Host: homepage.mac.com

You will probably be best off doing this stuff via the Cocoa classes mentioned before, mainly NSURLHandle.

- proton
     
seppak  (op)
Fresh-Faced Recruit
Join Date: Dec 2001
Location: Wisconsin
Status: Offline
Reply With Quote
Aug 4, 2003, 04:47 PM
 
Well i can now download stuff by sending a user-agent to the http server and other header info. There are still two problems; it takes quite some time for the http server to disconnect when the download is complete and when you decompress a file downloaded, you get an extra file you usually do not get. Can anyone explain why this is happening? Download my test program here that downloads itself to illustrate these problems. It is very rough around the edges(not multi-threaded, ect...) but it should be adequate.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:12 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2