Re: Odd NSData initWithContentsOfURL: issue
Re: Odd NSData initWithContentsOfURL: issue
- Subject: Re: Odd NSData initWithContentsOfURL: issue
- From: Kevin Ballard <email@hidden>
- Date: Sun, 13 Mar 2005 23:14:55 -0500
Yes, I know exactly what's going on. The server is returning it as a
gzipped file. initWithContentsOfURL is obviously saying it can handle
gzip, but it's not decompressing it for you. This is surprising -
either it shouldn't say it can handle gzip, or it should decompress it
for you.
I suggest passing any data you get back through a gzip decompressor
(you could use libz directly, or you could see if anybody's written a
Cocoa wrapper). If it's not gzip data, libz returns it unmodified, and
if it is, libz returns the correct data.
On Mar 13, 2005, at 10:27 PM, 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. Here is the little snippet of code I'm using:
NSURL *xmlURL = [[NSURL alloc] initWithString:feedURL];
NSData *theXMLFile = [[NSData alloc] initWithContentsOfURL:xmlURL];
[theXMLFile writeToFile:@"/tmp/blaa.xml" atomically:TRUE];
Ok, so all it should do, given the URL as the NSString 'feedURL', is
grab the data using that URL, then write it out to /tmp/blaa.xml.
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.
For example, this XML file works fine:
http://www.coverville.com/index.xml
But this one doesn't:
http://vinylpodcast.com/wp-rss2.php
If I load 'em up in Firefox or Safari and view source, they both look
like valid XML text files. The first is saved as a valid XML text
file. The second is saved as binary junk. The .php extension
shouldn't matter, since that is a server-side scripting that just
sends back a valid XML file.
Any ideas at all???
--
Kevin Ballard
email@hidden
http://www.tildesoft.com
http://kevin.sb.org
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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