Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timeout on empty socket in HTTPClient #3478

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion inc/HTTP/HTTPClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,11 @@ protected function sendData($socket, $data, $message) {
$time_used = $this->time() - $this->start;
if($time_used > $this->timeout)
throw new HTTPClientException(sprintf('Timeout while sending %s (%.3fs)',$message, $time_used), -100);
if(feof($socket))

// feof() sometimes hangs until first byte is written
// probably fixed around PHP 7.2 in https://github.com/php/php-src/pull/3729
if ($written > 0 && feof($socket))
if (feof($socket))
throw new HTTPClientException("Socket disconnected while writing $message");

// select parameters
Expand Down