Bug #80931 [Com]: FILE_GET_CONTENTS HANGS ON PHP 8
From: carusogabriel@php.net Date: Wed, 07 Apr 2021 02:27:09 +0000 Subject: Bug #80931 [Com]: FILE_GET_CONTENTS HANGS ON PHP 8 References: 1 Groups: php.bugs Request: Send a blank email to php-bugs+get-233277@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80931&edit=1
ID: 80931
Comment by: carusogabriel@php.net
Reported by: gilperon at gmail dot com
Summary: FILE_GET_CONTENTS HANGS ON PHP 8
Status: Open
Type: Bug
Package: *General Issues
Operating System: any
PHP Version: 8.0.3
Block user comment: N
Private report: N
New Comment:
This bug is reproducible in macOS (v10.15.7) as well. And we can test it with a smaller script:
```
<?php
$context = stream_context_create(['http' => ['timeout' => 2]]);
echo file_get_contents("http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx?StrRetorno=xml",
0, $context);
```
Previous Comments:
------------------------------------------------------------------------
[2021-04-03 14:08:26] gilperon at gmail dot com
Description:
------------
In any version of PHP (previous to 8) this bug didnt happen (I've been using it since 2010) but
on PHP 8, the code below hangs indefinately. Tested on Windows 7, Windows 10, Centos 8 and Centos 7.
The code below just tries to access an external API and, so far, I just managed to get this bug to
happen on this specific URL below (from the API).
<?php
$response = file_get_contents("http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx?nCdEmpresa=&sDsSenha=&sCepOrigem=11661690&sCepDestino=88070-480&nVlPeso=1&nCdFormato=1&nVlComprimento=25&nVlAltura=3&nVlLargura=25&sCdMaoPropria=N&nVlValorDeclarado=0&sCdAvisoRecebimento=N&nCdServico=04014&nVlDiametro=0&StrRetorno=xml");
echo $response;
?>
BUT if I add a timeout, the code above works just fine:
<?php
$context = stream_context_create(array(
"http" => array(
"timeout" => 2
)
));
$response = file_get_contents("http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx?nCdEmpresa=&sDsSenha=&sCepOrigem=11661690&sCepDestino=88070-480&nVlPeso=1&nCdFormato=1&nVlComprimento=25&nVlAltura=3&nVlLargura=25&sCdMaoPropria=N&nVlValorDeclarado=0&sCdAvisoRecebimento=N&nCdServico=04014&nVlDiametro=0&StrRetorno=xml",0,$context);
echo $response;
?>
I must say that using CURL works just fine, without any timeout, on any version of PHP. So this is a
file_get_contents problem and the only way I am finding to solve this problem in the
short term is using CURL.
Test script:
---------------
<?php
$response = file_get_contents("http://ws.correios.com.br/calculador/CalcPrecoPrazo.aspx?nCdEmpresa=&sDsSenha=&sCepOrigem=11661690&sCepDestino=88070-480&nVlPeso=1&nCdFormato=1&nVlComprimento=25&nVlAltura=3&nVlLargura=25&sCdMaoPropria=N&nVlValorDeclarado=0&sCdAvisoRecebimento=N&nCdServico=04014&nVlDiametro=0&StrRetorno=xml");
echo $response;
?>
Expected result:
----------------
Response should be printed.
Actual result:
--------------
The code hangs.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80931&edit=1
Thread (35 messages)
- Bug #80931 [Com]: FILE_GET_CONTENTS HANGS ON PHP 8
- Bug #80931 [Opn]: file_get_contents() hangs on PHP 8
- Bug #80931 [Opn]: file_get_contents() hangs on PHP 8
- Bug #80931 [Opn->Ver]: file_get_contents() hangs on PHP 8
- Bug #80931 [Com]: file_get_contents() hangs on PHP 8
- Bug #80931 [Ver]: file_get_contents() hangs on PHP 8
- Bug #80931 [Com]: file_get_contents() hangs on PHP 8
- Bug #80931 [Ver]: file_get_contents() hangs on PHP 8
- Bug #80931 [Com]: file_get_contents() hangs on PHP 8
- Bug #80931 [Ver]: file_get_contents() hangs on PHP 8
- Bug #80931 [Ver]: file_get_contents() hangs on PHP 8
- Bug #80931 [Com]: file_get_contents() hangs on PHP 8
- Bug #80931 [Com]: file_get_contents() hangs on PHP 8
- Bug #80931 [Com]: file_get_contents() hangs on PHP 8
- Bug #80931 [Com]: file_get_contents() hangs on PHP 8
- Bug #80931 [Ver]: file_get_contents() hangs on PHP 8
- Bug #80931 [Com]: file_get_contents() hangs on PHP 8
- Bug #80931 [Com]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Ver]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Ver]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Ver]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Ver]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [PATCH]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Com]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Com]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Com]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Com]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Com]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Com]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Com]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Com]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Com]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Com]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
- Bug #80931 [Com]: file_get_contents() hangs with HTTP/1.1 if server doesn't close connection
| « previous | php.bugs (#233277) | next » |
|---|