We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP version: x.y.z (hint: php --version) 8.2 Description
php --version
when pass headers request option with list not assoc array,GuzzleHttp\Psr7\Message::toString will throws error How to reproduce
<?php use GuzzleHttp\Handler\CurlHandler; use GuzzleHttp\HandlerStack; use GuzzleHttp\Psr7\Message; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; require __DIR__ .'/vendor/autoload.php'; $middleware = static function (callable $handler) { return static function (Request $request, array $options) use ($handler) { return $handler($request, $options)->then( static function (Response $response) use ($request) { Message::toString($request); Message::toString($response); }, ); }; }; $stack = HandlerStack::create(new CurlHandler()); // Wrap w/ middleware $stack->push($middleware,'log'); $client = new GuzzleHttp\Client(['handler' => $stack]); $response = $client->post('https://www.baidu.com',[ 'headers' => [ 'Content-Type: text/plain' //sure, it's work ], 'body' => 'GuzzleHttp\Client', ]);
shell#php test.php PHP Fatal error: Uncaught TypeError: strtolower(): Argument #1 ($string) must be of type string, int given in /test/vendor/guzzlehttp/psr7/src/Message.php:36 Stack trace: #0 /test/vendor/guzzlehttp/psr7/src/Message.php(36): strtolower() #1 /test/test.php(16): GuzzleHttp\Psr7\Message::toString() #2 /test/vendor/guzzlehttp/promises/src/FulfilledPromise.php(48): {closure}() #3 /test/vendor/guzzlehttp/promises/src/TaskQueue.php(52): GuzzleHttp\Promise\FulfilledPromise::GuzzleHttp\Promise\{closure}() #4 /test/vendor/guzzlehttp/promises/src/Promise.php(251): GuzzleHttp\Promise\TaskQueue->run() #5 /test/vendor/guzzlehttp/promises/src/Promise.php(227): GuzzleHttp\Promise\Promise->invokeWaitFn() #6 /test/vendor/guzzlehttp/promises/src/Promise.php(272): GuzzleHttp\Promise\Promise->waitIfPending() #7 /test/vendor/guzzlehttp/promises/src/Promise.php(229): GuzzleHttp\Promise\Promise->invokeWaitList() #8 /test/vendor/guzzlehttp/promises/src/Promise.php(69): GuzzleHttp\Promise\Promise->waitIfPending() #9 /test/vendor/guzzlehttp/guzzle/src/Client.php(189): GuzzleHttp\Promise\Promise->wait() #10 /test/vendor/guzzlehttp/guzzle/src/ClientTrait.php(95): GuzzleHttp\Client->request() #11 /test/test.php(26): GuzzleHttp\Client->post() #12 {main} thrown in /test/vendor/guzzlehttp/psr7/src/Message.php on line 36
The text was updated successfully, but these errors were encountered:
This is because you are passing an invalid header value. 'Content-Type: text/plain' must be 'Content-Type' => 'text/plain'.
'Content-Type: text/plain'
'Content-Type' => 'text/plain'
Sorry, something went wrong.
No branches or pull requests
PHP version: x.y.z (hint:
php --version
)8.2
Description
when pass headers request option with list not assoc array,GuzzleHttp\Psr7\Message::toString will throws error
How to reproduce
The text was updated successfully, but these errors were encountered: