Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit a41f3a3

Browse files
committed
Fix chunked transfer encoding problems due to trailing whitespace.
1 parent ba8b5c0 commit a41f3a3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/Doctrine/CouchDB/HTTP/SocketClient.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,13 @@ public function request($method, $path, $data = null, $raw = false, array $heade
288288
// are just footnotes, which are not relevant for us.
289289
$bytesLeft = $bytesToRead;
290290
while ($bytesLeft > 0) {
291-
$body .= $read = fread($this->connection, $bytesLeft + 2);
291+
$read = fread($this->connection, $bytesLeft + 2);
292+
// Chop off \r\n from the end.
293+
$body .= rtrim($read);
292294
$bytesLeft -= strlen($read);
293295
}
294296
}
295297
} while ($bytesToRead > 0);
296-
297-
// Chop off \r\n from the end.
298-
$body = substr($body, 0, -2);
299298
}
300299

301300
// Reset the connection if the server asks for it.

0 commit comments

Comments
 (0)