Update website

This commit is contained in:
Guilhem Lavaux 2025-02-11 21:30:02 +01:00
parent 0a686aeb9a
commit c4ffa0f6ee
4360 changed files with 1727 additions and 718385 deletions

View file

@ -1,3 +0,0 @@
vendor/
composer.lock
phpunit.xml

View file

@ -48,9 +48,9 @@ interface HttpClientInterface
'buffer' => true, // bool|resource|\Closure - whether the content of the response should be buffered or not,
// or a stream resource where the response body should be written,
// or a closure telling if/where the response should be buffered based on its headers
'on_progress' => null, // callable(int $dlNow, int $dlSize, array $info) - throwing any exceptions MUST abort
// the request; it MUST be called on DNS resolution, on arrival of headers and on
// completion; it SHOULD be called on upload/download of data and at least 1/s
'on_progress' => null, // callable(int $dlNow, int $dlSize, array $info) - throwing any exceptions MUST abort the
// request; it MUST be called on connection, on headers and on completion; it SHOULD be
// called on upload/download of data and at least 1/s
'resolve' => [], // string[] - a map of host to IP address that SHOULD replace DNS resolution
'proxy' => null, // string - by default, the proxy-related env vars handled by curl SHOULD be honored
'no_proxy' => null, // string - a comma separated list of hosts that do not require a proxy to be reached

View file

@ -12,26 +12,32 @@ if (!$_POST) {
$_POST['content-type'] = $_SERVER['HTTP_CONTENT_TYPE'] ?? '?';
}
$headers = [
'SERVER_PROTOCOL',
'SERVER_NAME',
'REQUEST_URI',
'REQUEST_METHOD',
'PHP_AUTH_USER',
'PHP_AUTH_PW',
'REMOTE_ADDR',
'REMOTE_PORT',
];
foreach ($headers as $k) {
if (isset($_SERVER[$k])) {
$vars[$k] = $_SERVER[$k];
}
}
foreach ($_SERVER as $k => $v) {
switch ($k) {
default:
if (0 !== strpos($k, 'HTTP_')) {
continue 2;
}
// no break
case 'SERVER_NAME':
case 'SERVER_PROTOCOL':
case 'REQUEST_URI':
case 'REQUEST_METHOD':
case 'PHP_AUTH_USER':
case 'PHP_AUTH_PW':
$vars[$k] = $v;
if (0 === strpos($k, 'HTTP_')) {
$vars[$k] = $v;
}
}
$json = json_encode($vars, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE);
switch ($vars['REQUEST_URI']) {
switch (parse_url($vars['REQUEST_URI'], \PHP_URL_PATH)) {
default:
exit;
@ -94,7 +100,8 @@ switch ($vars['REQUEST_URI']) {
case '/302':
if (!isset($vars['HTTP_AUTHORIZATION'])) {
header('Location: http://localhost:8057/', true, 302);
$location = $_GET['location'] ?? 'http://localhost:8057/';
header('Location: '.$location, true, 302);
}
break;

View file

@ -25,6 +25,10 @@ abstract class HttpClientTestCase extends TestCase
{
public static function setUpBeforeClass(): void
{
if (!function_exists('ob_gzhandler')) {
static::markTestSkipped('The "ob_gzhandler" function is not available.');
}
TestHttpServer::start();
}
@ -730,6 +734,18 @@ abstract class HttpClientTestCase extends TestCase
$this->assertSame(200, $response->getStatusCode());
}
public function testIPv6Resolve()
{
TestHttpServer::start(-8087);
$client = $this->getHttpClient(__FUNCTION__);
$response = $client->request('GET', 'http://symfony.com:8087/', [
'resolve' => ['symfony.com' => '::1'],
]);
$this->assertSame(200, $response->getStatusCode());
}
public function testNotATimeout()
{
$client = $this->getHttpClient(__FUNCTION__);
@ -1148,4 +1164,33 @@ abstract class HttpClientTestCase extends TestCase
$response = $client2->request('GET', '/');
$this->assertSame(200, $response->getStatusCode());
}
public function testBindToPort()
{
$client = $this->getHttpClient(__FUNCTION__);
$response = $client->request('GET', 'http://localhost:8057', ['bindto' => '127.0.0.1:9876']);
$response->getStatusCode();
$vars = $response->toArray();
self::assertSame('127.0.0.1', $vars['REMOTE_ADDR']);
self::assertSame('9876', $vars['REMOTE_PORT']);
}
public function testBindToPortV6()
{
TestHttpServer::start(-8087);
$client = $this->getHttpClient(__FUNCTION__);
$response = $client->request('GET', 'http://[::1]:8087', ['bindto' => '[::1]:9876']);
$response->getStatusCode();
$vars = $response->toArray();
self::assertSame('::1', $vars['REMOTE_ADDR']);
if ('\\' !== \DIRECTORY_SEPARATOR) {
self::assertSame('9876', $vars['REMOTE_PORT']);
}
}
}

View file

@ -23,6 +23,13 @@ class TestHttpServer
*/
public static function start(int $port = 8057)
{
if (0 > $port) {
$port = -$port;
$ip = '[::1]';
} else {
$ip = '127.0.0.1';
}
if (isset(self::$process[$port])) {
self::$process[$port]->stop();
} else {
@ -32,14 +39,14 @@ class TestHttpServer
}
$finder = new PhpExecutableFinder();
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', '127.0.0.1:'.$port]));
$process = new Process(array_merge([$finder->find(false)], $finder->findArguments(), ['-dopcache.enable=0', '-dvariables_order=EGPCS', '-S', $ip.':'.$port]));
$process->setWorkingDirectory(__DIR__.'/Fixtures/web');
$process->start();
self::$process[$port] = $process;
do {
usleep(50000);
} while (!@fopen('http://127.0.0.1:'.$port, 'r'));
} while (!@fopen('http://'.$ip.':'.$port, 'r'));
return $process;
}