Skip to content

Commit 5ca11da

Browse files
committed
Fix timeout on empty socket in HTTPClient
feof() sometimes hangs if nothing has beeen written yet see php/php-src#3729
1 parent 4ee6dda commit 5ca11da

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

inc/HTTP/HTTPClient.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,11 @@ protected function sendData($socket, $data, $message) {
577577
$time_used = $this->time() - $this->start;
578578
if($time_used > $this->timeout)
579579
throw new HTTPClientException(sprintf('Timeout while sending %s (%.3fs)',$message, $time_used), -100);
580-
if(feof($socket))
580+
581+
// feof() sometimes hangs until first byte is written
582+
// probably fixed around PHP 7.2 in https://github.com/php/php-src/pull/3729
583+
if ($written > 0 && feof($socket))
584+
if (feof($socket))
581585
throw new HTTPClientException("Socket disconnected while writing $message");
582586

583587
// select parameters

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy