Skip to content

[HttpClient] PHP Fatal error: Uncaught TypeError: Argument 2 passed to Symfony\Component\HttpClient\Chunk\DataChunk::__construct() must be of the type string, null given #37923

Closed
@ghost

Description

Symfony version(s) affected: 5.1.3

Description
Any idea why this happening? This url was in a loop and crashes the entire script.

How to reproduce

<?php

require __DIR__ . '/vendor/autoload.php';

use Symfony\Component\HttpClient\HttpClient;

$client = HttpClient::create();
$response = $client->request('GET', 'http://123c.vn/');

Additional context

PHP Fatal error:  Uncaught TypeError: Argument 2 passed to Symfony\Component\HttpClient\Chunk\DataChunk::__construct() must be of the type string, null given, called in /bug/vendor/symfony/http-client/Response/ResponseTrait.php on line 363 and defined in /bug/vendor/symfony/http-client/Chunk/DataChunk.php:26
Stack trace:
#0 /bug/vendor/symfony/http-client/Response/ResponseTrait.php(363): Symfony\Component\HttpClient\Chunk\DataChunk->__construct(0, NULL)
#1 /bug/vendor/symfony/http-client/Response/ResponseTrait.php(237): Symfony\Component\HttpClient\Response\CurlResponse::stream(Array)
#2 /bug/vendor/symfony/http-client/Response/ResponseTrait.php(300): Symfony\Component\HttpClient\Response\CurlResponse::initialize(Object(Symfony\Component\HttpClient\Response\CurlResponse))
#3 /bug/vendor/symfony/http-client/Response/CurlResponse.php(196): Symfony\Component\HttpClient\Response\CurlResponse->doDestruct()
#4 [internal  in /bug/vendor/symfony/http-client/Chunk/DataChunk.php on line 26

Fatal error: Uncaught TypeError: Argument 2 passed to Symfony\Component\HttpClient\Chunk\DataChunk::__construct() must be of the type string, null given, called in /bug/vendor/symfony/http-client/Response/ResponseTrait.php on line 363 and defined in /bug/vendor/symfony/http-client/Chunk/DataChunk.php:26
Stack trace:
#0 /bug/vendor/symfony/http-client/Response/ResponseTrait.php(363): Symfony\Component\HttpClient\Chunk\DataChunk->__construct(0, NULL)
#1 /bug/vendor/symfony/http-client/Response/ResponseTrait.php(237): Symfony\Component\HttpClient\Response\CurlResponse::stream(Array)
#2 /bug/vendor/symfony/http-client/Response/ResponseTrait.php(300): Symfony\Component\HttpClient\Response\CurlResponse::initialize(Object(Symfony\Component\HttpClient\Response\CurlResponse))
#3 /bug/vendor/symfony/http-client/Response/CurlResponse.php(196): Symfony\Component\HttpClient\Response\CurlResponse->doDestruct()
#4 [internal  in /bug/vendor/symfony/http-client/Chunk/DataChunk.php on line 26

Tried this on the terminal

curl -I http://123c.vn/
curl: (1) Received HTTP/0.9 when not allowed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions