This code operates on the full HTTP request; the chunkedData NSData object does not start with the first HTTP chunk, but rather the HTTP headers. So this code scans through the lines of data ending with \r\n until it sees two \r\n tokens in a row, at which point it know that the next line with be a chunk octet which will tell us how big the actual chunk is. It appends that chunk into our joinedData and then parses the next octet value. An octet value of zero means we're done joining chunks.