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

Commit 4a4bfc7

Browse files
committed
Merge branch 'mlocati-fix-curl-timeout-detection'
2 parents a00cc26 + 8f7a5c7 commit 4a4bfc7

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Client/Adapter/Curl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body =
424424
$request = curl_getinfo($this->curl, CURLINFO_HEADER_OUT);
425425
$request .= $body;
426426

427-
if (empty($this->response)) {
427+
if ($response === false || empty($this->response)) {
428428
throw new AdapterException\RuntimeException("Error in cURL request: " . curl_error($this->curl));
429429
}
430430

test/Client/CurlTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,4 +433,25 @@ public function testNoCaseSensitiveHeaderName()
433433
$this->assertFalse($headers->has('Transfer-Encoding'));
434434
$this->assertFalse($headers->has('Content-Encoding'));
435435
}
436+
437+
public function testTimeoutDetection()
438+
{
439+
$this->client
440+
->setOptions([
441+
'timeout' => 1,
442+
])
443+
->setStream(true)
444+
->setMethod('GET')
445+
->setUri(
446+
getenv('TESTS_ZEND_HTTP_CLIENT_BIGRESOURCE_URI') ?:
447+
'http://de.releases.ubuntu.com/16.04.1/ubuntu-16.04.1-server-i386.iso'
448+
);
449+
$error = null;
450+
try {
451+
$this->client->send();
452+
} catch (\Exception $x) {
453+
$error = $x;
454+
}
455+
$this->assertNotNull($error, 'Failed to detect timeout in cURL adapter');
456+
}
436457
}

0 commit comments

Comments
 (0)