Skip to content

Commit 3ff9c49

Browse files
lyrixxnicolas-grekas
authored andcommitted
[HttpClient] Fix early cleanup of pushed HTTP/2 responses
1 parent f51bca9 commit 3ff9c49

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

HttpClient/Test/Fixtures/web/index.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,27 @@
155155
usleep(500);
156156
}
157157
exit;
158+
159+
case '/json':
160+
header("Content-Type: application/json");
161+
echo json_encode([
162+
'documents' => [
163+
['id' => '/json/1'],
164+
['id' => '/json/2'],
165+
['id' => '/json/3'],
166+
],
167+
]);
168+
exit;
169+
170+
case '/json/1':
171+
case '/json/2':
172+
case '/json/3':
173+
header("Content-Type: application/json");
174+
echo json_encode([
175+
'title' => $vars['REQUEST_URI'],
176+
]);
177+
178+
exit;
158179
}
159180

160181
header('Content-Type: application/json', true);

HttpClient/Test/HttpClientTestCase.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
*/
2525
abstract class HttpClientTestCase extends TestCase
2626
{
27-
private static $server;
28-
2927
public static function setUpBeforeClass(): void
3028
{
3129
TestHttpServer::start();

HttpClient/Test/TestHttpServer.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,22 @@
1919
*/
2020
class TestHttpServer
2121
{
22-
private static $server;
22+
private static $started;
2323

2424
public static function start()
2525
{
26-
if (null !== self::$server) {
26+
if (self::$started) {
2727
return;
2828
}
2929

3030
$finder = new PhpExecutableFinder();
3131
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:8057']));
3232
$process->setWorkingDirectory(__DIR__.'/Fixtures/web');
33-
$process->setTimeout(300);
3433
$process->start();
3534

36-
self::$server = new class() {
37-
public $process;
38-
39-
public function __destruct()
40-
{
41-
$this->process->stop();
42-
}
43-
};
44-
45-
self::$server->process = $process;
46-
35+
register_shutdown_function([$process, 'stop']);
4736
sleep('\\' === \DIRECTORY_SEPARATOR ? 10 : 1);
37+
38+
self::$started = true;
4839
}
4940
}

0 commit comments

Comments
 (0)