Skip navigation.
 
mlRe: Odd NSData initWithContentsOfURL: issue
FROM : Nicko van Someren
DATE : Thu Mar 17 21:40:49 2005

On 15 Mar 2005, at 20:01, John Stiles wrote:
> On Mar 15, 2005, at 11:46 AM, John C. Randolph wrote:

>> On Mar 13, 2005, at 10:01 PM, Nicko van Someren wrote:

...
>>> 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

...
>>> 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.


The problem is is does not do that.  There is no compressed data at
that URL.

> I think most users would argue that the compression of the data is an
> artifact of the transport mechanism, and does not represent the actual
> data at that URL. And you should not be explicitly advertising gzip
> support to the server on the client's behalf if you aren't going to
> take responsibility for the actual gzip decompression.


Absolutely.  The data is not compressed on the server and it is only
being compressed in transit at the (erroneous) request of the client. 
If you make an access to the same URL using, say, wget, you get the raw
data.  If you access the URL with Safari and display the source you get
the raw data.  If you access the URL with initWithContentsOfURL your
get the compressed transport stream and not the data at the URL.

The compression of the data is an un-requested artefact of the manner
in which initWithContentsOfURL asks for the data.  There is no way for
the user to know in advance if the server supports compression and
therefore will be effected by the Accept-encoding: header line that
gets sent.  Do you honestly think that this is a feature, let alone a
useful one, and not a honest-to-goodness bug?

   Nicko

Related mailsAuthorDate
mlOdd NSData initWithContentsOfURL: issue Michael J. Sherman Mar 14, 04:27
mlRe: Odd NSData initWithContentsOfURL: issue Kevin Ballard Mar 14, 05:14
mlRe: Odd NSData initWithContentsOfURL: issue Nicko van Someren Mar 14, 07:01
mlRe: Odd NSData initWithContentsOfURL: issue John C. Randolph Mar 15, 20:46
mlRe: Odd NSData initWithContentsOfURL: issue John Stiles Mar 15, 21:01
mlRe: Odd NSData initWithContentsOfURL: issue Michael J. Sherman Mar 16, 04:06
mlRe: Odd NSData initWithContentsOfURL: issue John C. Randolph Mar 16, 06:51
mlRe: Odd NSData initWithContentsOfURL: issue Will Mason Mar 16, 09:38
mlRe: Odd NSData initWithContentsOfURL: issue John C. Randolph Mar 16, 20:43
mlRe: Odd NSData initWithContentsOfURL: issue Nicko van Someren Mar 17, 21:40