Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c886540

Browse filesBrowse files
committed
bug #44878 [HttpClient] Turn negative timeout to a very long timeout (fancyweb)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpClient] Turn negative timeout to a very long timeout | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #44477 | License | MIT | Doc PR | - 0 keeps on throwing. Commits ------- 6360c31 [HttpClient] Turn negative timeout to a very long timeout
2 parents 69d4d6d + 6360c31 commit c886540
Copy full SHA for c886540

File tree

2 files changed

+13
-1
lines changed
Filter options

2 files changed

+13
-1
lines changed

‎src/Symfony/Component/HttpClient/HttpClientTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/HttpClientTrait.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ private static function prepareRequest(?string $method, ?string $url, array $opt
147147

148148
// Finalize normalization of options
149149
$options['http_version'] = (string) ($options['http_version'] ?? '') ?: null;
150-
$options['timeout'] = (float) ($options['timeout'] ?? ini_get('default_socket_timeout'));
150+
if (0 > $options['timeout'] = (float) ($options['timeout'] ?? ini_get('default_socket_timeout'))) {
151+
$options['timeout'] = 172800.0; // 2 days
152+
}
153+
151154
$options['max_duration'] = isset($options['max_duration']) ? (float) $options['max_duration'] : 0;
152155

153156
return [$url, $options];

‎src/Symfony/Component/HttpClient/Tests/HttpClientTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Tests/HttpClientTestCase.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,13 @@ public function testDebugInfoOnDestruct()
179179

180180
$this->assertNotEmpty($traceInfo['debug']);
181181
}
182+
183+
public function testNegativeTimeout()
184+
{
185+
$client = $this->getHttpClient(__FUNCTION__);
186+
187+
$this->assertSame(200, $client->request('GET', 'http://localhost:8057', [
188+
'timeout' => -1,
189+
])->getStatusCode());
190+
}
182191
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.