NSMutableData
will grow to an arbitrary size.
Having run curl http://www.nhara.org/scored_races-2013.htm > file.txt
, I can tell you that the file the server returns is exactly 90810 bytes long. So that's why you get that number of bytes back. It's not the mutable data object that fills up, it's that 90810 is exactly the right length.
Your problem is here:
[[NSString alloc] initWithData:xmlData encoding:NSUTF8StringEncoding]
The string your server is returning isn't valid UTF-8. To verify this for yourself, try NSASCIIStringEncoding
(which is an encoding in which all bytes are valid). You'll see that you correctly accumulate a string.
Having searched the file returned, the specific problem is the byte at position 74,963 — the 0x92 used for a typographic single quote. It looks like you want NSWindowsCP1252StringEncoding
. Whoever uploaded that HTML appears to have used Microsoft's code page 1252.