• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Odd NSData initWithContentsOfURL: issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Odd NSData initWithContentsOfURL: issue


  • Subject: Re: Odd NSData initWithContentsOfURL: issue
  • From: "John C. Randolph" <email@hidden>
  • Date: Tue, 15 Mar 2005 11:46:48 -0800


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.


-jcr


John C. Randolph <email@hidden> (408) 974-8819 Sr. Cocoa Software Engineer, Apple Worldwide Developer Relations http://developer.apple.com/cocoa/index.html



_______________________________________________
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


  • Follow-Ups:
    • Re: Odd NSData initWithContentsOfURL: issue
      • From: "Michael J. Sherman" <email@hidden>
    • Re: Odd NSData initWithContentsOfURL: issue
      • From: John Stiles <email@hidden>
References: 
 >Odd NSData initWithContentsOfURL: issue (From: "Michael J. Sherman" <email@hidden>)
 >Re: Odd NSData initWithContentsOfURL: issue (From: Nicko van Someren <email@hidden>)

  • Prev by Date: Re: email and cocoa
  • Next by Date: Re: Odd NSData initWithContentsOfURL: issue
  • Previous by thread: Re: Odd NSData initWithContentsOfURL: issue
  • Next by thread: Re: Odd NSData initWithContentsOfURL: issue
  • Index(es):
    • Date
    • Thread