Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Commit 819a78c

Browse files
author
Stephen Seliuk
committed
Additional way to calculate the request body size.
1 parent 3372704 commit 819a78c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Facebook/HttpClients/FacebookCurlHttpClient.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,11 @@ private function getHeaderSize()
295295
// This corrects a Curl bug where header size does not account
296296
// for additional Proxy headers.
297297
if ( self::needsCurlProxyFix() ) {
298-
if ( stripos($this->rawResponse, self::CONNECTION_ESTABLISHED) !== false ) {
299-
$headerSize += mb_strlen(self::CONNECTION_ESTABLISHED);
298+
// Additional way to calculate the request body size.
299+
if (preg_match('/Content-Length: (\d+)/', $this->rawResponse, $m)) {
300+
$headerSize = mb_strlen($this->rawResponse) - $m[1];
301+
} elseif (stripos($this->rawResponse, self::CONNECTION_ESTABLISHED) !== false) {
302+
$headerSize += mb_strlen(self::CONNECTION_ESTABLISHED);
300303
}
301304
}
302305

0 commit comments

Comments
 (0)