Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

Commit 6e27132

Browse files
dependabot[bot]Rid
andauthored
chore(deps-dev): allow guzzlehttp/guzzle ^8.0
* ci: update guzzlehttp/guzzle requirement from ^7.9 to ^7.9 || ^8.0 Updates the requirements on [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) to permit the latest version. - [Release notes](https://github.com/guzzle/guzzle/releases) - [Changelog](https://github.com/guzzle/guzzle/blob/8.2/CHANGELOG.md) - [Commits](guzzle/guzzle@7.9.0...8.2.0) --- updated-dependencies: - dependency-name: guzzlehttp/guzzle dependency-version: 8.2.0 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> * test(guzzle): support Guzzle 8 in transport tests Guzzle 8 removed getHandlerContext() from transfer exceptions. Read the cURL error from on_stats instead, which reports it in Guzzle 7 and 8. Guzzle 8 also rejects cURL-only options on the PHP stream handler, where Guzzle 7 ignored them. Test incremental reads on that handler separately, and check the curl option is ignored on 7 and rejected on 8. Note the difference in the HTTP client guide and list Guzzle 8 as supported. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Rid <rid@cylo.io>
1 parent 4e56ee9 commit 6e27132

3 files changed

Lines changed: 52 additions & 11 deletions

File tree

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"ext-curl": "*",
2626
"ergebnis/composer-normalize": "^2.42",
2727
"friendsofphp/php-cs-fixer": "^3.8",
28-
"guzzlehttp/guzzle": "^7.9",
28+
"guzzlehttp/guzzle": "^7.9 || ^8.0",
2929
"php-parallel-lint/php-parallel-lint": "^1.2",
3030
"phpstan/phpstan": "^1.10 || ^2.0",
3131
"phpunit/phpunit": "^10.5.46",

‎docs/guides/guzzle.mdx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: "Compare the bundled socket client and Guzzle, with connection exam
44
---
55

66
Docker PHP uses its bundled socket client by default. You can also pass a
7-
configured Guzzle 7 client to `Docker::create()`. Both support connection
7+
configured Guzzle 7 or 8 client to `Docker::create()`. Both support connection
88
settings directly in PHP; environment variables are optional.
99

1010
## Choosing a client
@@ -165,8 +165,9 @@ adjust it for builds, transfers or other long-running operations.
165165
The cURL handler buffers response bodies even with `stream => true`. Completed
166166
logs can still be decoded, but following logs or subscribing to events can
167167
wait indefinitely or hit the timeout before returning output. Guzzle's PHP
168-
stream handler can read incrementally, but does not use
169-
`CURLOPT_UNIX_SOCKET_PATH`; changing handlers changes which options work.
168+
stream handler can read incrementally, but cannot connect to a Unix socket:
169+
Guzzle 7 ignores the `curl` option on that handler and Guzzle 8 rejects it.
170+
Changing handlers changes which options work.
170171

171172
`StreamingDecoderPlugin` handles decoding after the transport returns a
172173
response. It cannot remove buffering inside Guzzle's cURL handler. If you

‎tests/GuzzleClientTest.php‎

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
use Docker\Docker;
1010
use Docker\Stream\DockerRawStream;
1111
use GuzzleHttp\Client as GuzzleClient;
12+
use GuzzleHttp\ClientInterface;
1213
use GuzzleHttp\Exception\GuzzleException;
14+
use GuzzleHttp\Exception\InvalidArgumentException as GuzzleInvalidArgumentException;
1315
use GuzzleHttp\Handler\CurlHandler;
1416
use GuzzleHttp\HandlerStack;
17+
use GuzzleHttp\TransferStats;
1518
use Http\Client\Common\PluginClient;
1619
use Nyholm\Psr7\Request;
1720
use PHPUnit\Framework\Attributes\DataProvider;
@@ -68,15 +71,15 @@ public function testHttpsRejectsUntrustedCertificate(): void
6871
$this->createCertificates();
6972
$address = $this->startServer(['ssl' => $this->serverTlsOptions()]);
7073

71-
$this->assertCertificateRejected($this->guzzle('https://'.$address));
74+
$this->assertCertificateRejected('https://'.$address);
7275
}
7376

7477
public function testHttpsRejectsWrongHostname(): void
7578
{
7679
$this->createCertificates('DNS:not-docker.test');
7780
$address = $this->startServer(['ssl' => $this->serverTlsOptions()]);
7881

79-
$this->assertCertificateRejected($this->guzzle('https://'.$address, ['verify' => $this->directory.'/ca.pem']));
82+
$this->assertCertificateRejected('https://'.$address, ['verify' => $this->directory.'/ca.pem']);
8083
}
8184

8285
public function testMutualTlsRejectsMissingClientCertificate(): void
@@ -161,7 +164,7 @@ public function testExplicitCurlHandlerBuffersDespiteStreamOption(): void
161164
$this->assertStringStartsWith('GET /_ping HTTP/1.1', $this->serverResult()['request']);
162165
}
163166

164-
public function testDefaultStreamingHandlerDoesNotUseCurlSocketOption(): void
167+
public function testDefaultStreamingHandlerReadsIncrementally(): void
165168
{
166169
if (!\ini_get('allow_url_fopen')) {
167170
$this->markTestSkipped('The default PHP stream handler requires allow_url_fopen.');
@@ -170,7 +173,6 @@ public function testDefaultStreamingHandlerDoesNotUseCurlSocketOption(): void
170173
$client = new PluginClient(new GuzzleClient([
171174
'base_uri' => 'http://'.$address,
172175
'stream' => true,
173-
'curl' => [\CURLOPT_UNIX_SOCKET_PATH => $this->directory.'/does-not-exist.sock'],
174176
'proxy' => '',
175177
'timeout' => 3,
176178
]));
@@ -182,6 +184,36 @@ public function testDefaultStreamingHandlerDoesNotUseCurlSocketOption(): void
182184
$this->assertStringContainsString('Host: '.$address."\r\n", $this->serverResult()['request']);
183185
}
184186

187+
public function testDefaultStreamingHandlerDoesNotUseCurlSocketOption(): void
188+
{
189+
if (!\ini_get('allow_url_fopen')) {
190+
$this->markTestSkipped('The default PHP stream handler requires allow_url_fopen.');
191+
}
192+
$options = [
193+
'stream' => true,
194+
'curl' => [\CURLOPT_UNIX_SOCKET_PATH => $this->directory.'/does-not-exist.sock'],
195+
'proxy' => '',
196+
'timeout' => 3,
197+
];
198+
199+
if (ClientInterface::MAJOR_VERSION >= 8) {
200+
// Guzzle 8 rejects cURL-only options on the stream handler.
201+
$client = new PluginClient(new GuzzleClient($options + ['base_uri' => 'http://localhost']));
202+
$this->expectException(GuzzleInvalidArgumentException::class);
203+
$client->sendRequest(new Request('GET', '/_ping'));
204+
205+
return;
206+
}
207+
208+
// Guzzle 7 ignores them and connects to base_uri instead of the socket.
209+
$address = $this->startServer();
210+
$client = new PluginClient(new GuzzleClient($options + ['base_uri' => 'http://'.$address]));
211+
$response = $client->sendRequest(new Request('GET', '/_ping'));
212+
213+
$this->assertSame('OK', $response->getBody()->getContents());
214+
$this->assertStringContainsString('Host: '.$address."\r\n", $this->serverResult()['request']);
215+
}
216+
185217
private function guzzle(string $url, array $options = []): GuzzleClient
186218
{
187219
return new GuzzleClient($options + [
@@ -197,13 +229,21 @@ private function jsonResponse(string $body, int $status = 200): array
197229
return ['status' => $status, 'body' => $body, 'headers' => ['Content-Type' => 'application/json']];
198230
}
199231

200-
private function assertCertificateRejected(GuzzleClient $client): void
232+
private function assertCertificateRejected(string $url, array $options = []): void
201233
{
234+
// Guzzle 8 removed the exception handler context; transfer stats report the cURL errno in both majors.
235+
$errno = null;
236+
$client = $this->guzzle($url, $options + [
237+
'on_stats' => static function (TransferStats $stats) use (&$errno): void {
238+
$errno = $stats->getHandlerErrorData();
239+
},
240+
]);
241+
202242
try {
203243
Docker::create($client);
204244
$this->fail('The server certificate should have been rejected.');
205-
} catch (GuzzleException $exception) {
206-
$this->assertSame(\CURLE_SSL_CACERT, $exception->getHandlerContext()['errno']);
245+
} catch (GuzzleException) {
246+
$this->assertSame(\CURLE_SSL_CACERT, $errno);
207247
}
208248
}
209249

0 commit comments

Comments
 (0)