kriswallsmith/Buzz — pull request #70 by Burgov (2012-04-26 20:57:13+00:00)
Title: Made Curl client handle content which looks like headers well

I the content of a request looks like a header, Curl will actually recognize it as a header and fail to correctly decompose the response into headers and content.

This PR will use curl_getinfo($this->curl, CURLINFO_HEADER_SIZE) to correctly figure out where the header stops and the content begins.

I ran into some issues while trying to achive this, the biggest being never really being able to rely on whether \r\n is used for newlines, or only \n. curl_getinfo($this->curl, CURLINFO_HEADER_SIZE) includes the two newlines which conclude the headers, so by diffing the headers and the trimmed headers, I was able to accurately distract and use it later on.

Since there was no way to return this delimiter from the getLastResponse method, I decided to return an array containing an array of headers and the body from that method, and actually remove the fromString method in the Response method, because, as said, this method had no way of reliably knowing whether \r\n or \n was used.