[HttpClient] PHP Fatal error: Uncaught TypeError: Argument 2 passed to Symfony\Component\HttpClient\Chunk\DataChunk::__construct() must be of the type string, null given · Issue #37923 · symfony/symfony · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[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
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
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
The text was updated successfully, but these errors were encountered:
The server header data are never sent or at least after the first content chunk. Therefore, the CURLOPT_HEADERFUNCTION callback is never called and the FirstChunk is never yield. That means we have to handle the first string chunk before the response write buffer is set. We do not support that. WDYT of throwing @nicolas-grekas?
curl --http0.9 -v http://123c.vn/
* Trying 120.138.69.92:80...
* TCP_NODELAY set
* Connected to 123c.vn (120.138.69.92) port 80 (#0)
> GET / HTTP/1.1
> Host: 123c.vn
> User-Agent: curl/7.68.0
> Accept: */*
>
<html xmlns="http://www.w3.org/1999/xhtml"><head>[...]
This is HTTP/0.9, and the code is not prepared for this.
This should throw a TransportException, no need to add support for this IMHO.
@anaggh works for you?
Anyone up for a PR?
…TP/0.9 (nicolas-grekas)
This PR was merged into the 4.4 branch.
Discussion
----------
[HttpClient] fail properly when the server replies with HTTP/0.9
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | no
| New feature? | no
| Deprecations? | no
| Tickets | Fix#37923
| License | MIT
| Doc PR | -
Commits
-------
96759af [HttpClient] fail properly when the server replies with HTTP/0.9
Uh oh!
There was an error while loading. Please reload this page.
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
Additional context
Tried this on the terminal
The text was updated successfully, but these errors were encountered: