Re: Odd NSData initWithContentsOfURL: issue
Re: Odd NSData initWithContentsOfURL: issue
- Subject: Re: Odd NSData initWithContentsOfURL: issue
- From: "Michael J. Sherman" <email@hidden>
- Date: Tue, 15 Mar 2005 22:06:45 -0500
On Mar 15, 2005, at 2:46 PM, John C. Randolph wrote:
On Mar 13, 2005, at 10:01 PM, Nicko van Someren wrote:
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 :-(
That would be a feature request, rather than a bug report.
-initWithContentsOfURL: is supposed to give you whatever's at that
URL, without any modifications.
But the library is advertising to the remote server the fact that it
can handle gzip, but it never bothers to unzip it when it gets it.
What am I supposed to do with the gzipped return data? Do you have a
solution?
_______________________________________________
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