diff --git a/lib/Doctrine/CouchDB/HTTP/SocketClient.php b/lib/Doctrine/CouchDB/HTTP/SocketClient.php index 6cdcecf..f4e01e4 100644 --- a/lib/Doctrine/CouchDB/HTTP/SocketClient.php +++ b/lib/Doctrine/CouchDB/HTTP/SocketClient.php @@ -288,14 +288,13 @@ public function request($method, $path, $data = null, $raw = false, array $heade // are just footnotes, which are not relevant for us. $bytesLeft = $bytesToRead; while ($bytesLeft > 0) { - $body .= $read = fread($this->connection, $bytesLeft + 2); + $read = fread($this->connection, $bytesLeft + 2); + // Chop off \r\n from the end. + $body .= rtrim($read); $bytesLeft -= strlen($read); } } } while ($bytesToRead > 0); - - // Chop off \r\n from the end. - $body = substr($body, 0, -2); } // Reset the connection if the server asks for it.