Re: Odd NSData initWithContentsOfURL: issue
Re: Odd NSData initWithContentsOfURL: issue
- Subject: Re: Odd NSData initWithContentsOfURL: issue
- From: Nicko van Someren <email@hidden>
- Date: Mon, 14 Mar 2005 06:01:12 +0000
On 14 Mar 2005, at 3:27, Michael J. Sherman wrote:
I'm trying to grab XML files from various URLs and save the XML file
to disk as a text file.
...
NSData *theXMLFile = [[NSData alloc] initWithContentsOfURL:xmlURL];
...
It works for most URLs I try. But there are some that result in
binary garbage data in the blaa.xml file! I'm wondering if anyone has
any clue where I can look to start figuring this out.
I ran into the same problem the other day but with the
initWithContentsOfURL: message in NSXMLParser instead of NSData.
Another site that fails is the C|Net RSS feed at:
http://news.com.com/2547-1_3-0-5.xml At the time I didn't have enough
time to fully test things and then I went off on holiday but seeing
your mail made me come back and look at this again.
It seems that there is a real bug in the initWithContentsOfURL: code
for NSData and NSString and by extension every class that uses them. A
quick check of the headers sent with the request shows that they
include:
Accept-Encoding: gzip, deflate;q=1.0, identity;q=0.5, *;q=0
The problem is that when the server does send back gziped data it's not
getting unpacked. I just tried your code to download from the site you
mentioned and from CNet and the resulting files unpack just fine on the
command line using gunzip.
I will file a bug report with Apple. Given that 10.3.9 is in seed
already I guess it won't get fixed before Tiger :-(
Nicko
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden