Bug #81448 [NEW]: file_get_contents cuts off incoming HTTP data
| From: | gajowy at agzeta dot pl | Date: | Thu, 16 Sep 2021 15:57:17 +0000 |
| Subject: | Bug #81448 [NEW]: file_get_contents cuts off incoming HTTP data | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-236650@lists.php.net to get a copy of this message | ||
From: gajowy at agzeta dot pl
Operating system: Windows 10 64-bit
PHP version: 8.0.10
Package: HTTP related
Bug Type: Bug
Bug description:file_get_contents cuts off incoming HTTP data
Description:
------------
file_get_contents function can't get data from NASA servers. The server
returns code 200 OK and data starts to be transmitted, however are cut
off after some time (~120 seconds). It happens that data are transmitted
correctly and the whole transmission takes app. 2 seconds in this case.
The same request is working without any problem if curl is used.
It was tested on PHP 8.0.10 and 7.4.20 on 3 various (independend)
networks.
Test script:
---------------
<?php
// ensure, that openssl extension is loaded
if( !extension_loaded('openssl') )
exit("Please enable openssl extension in PHP.ini!\n");
$url="https://ssd.jpl.nasa.gov/api/horizons.api?format=text&COMMAND='00004%3B'&MAKE_EPHEM=YES&TABLE_TYPE=OBSERVER&CENTER='K80'&START_TIME=%272021-09-15+10%3A48%3A24+UT%27&STOP_TIME=%272021-09-16+10%3A48%3A24%27&STEP_SIZE=1m&REF_SYSTEM=J2000&QUANTITIES='1,3,4,19,20,21,23,25,8,9,33,38,43'&ANG_FORMAT=DEG&RANGE_UNITS=AU&APPARENT=REFRACTED&TIME_DIGITS=FRACSEC&EXTRA_PREC=YES&CSV_FORMAT=YES";
print("Running...\n");
$m0=microtime(TRUE);
$ret=file_get_contents($url);
printf("%d bytes downloaded in %.3f
seconds\n",strlen($ret),microtime(TRUE)-$m0);
file_put_contents('query.txt',$url);
file_put_contents('header.txt',print_r($http_response_header,TRUE));
file_put_contents('document.txt',$ret);
?>
Expected result:
----------------
app. 480.000 bytes response is get. The output should end with a line
with asterisks.
Actual result:
--------------
The output is cut of in various places, usually between 10k-200k of
data.
--
Edit bug report at https://bugs.php.net/bug.php?id=81448&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81448&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81448&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81448&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81448&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81448&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81448&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81448&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81448&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81448&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81448&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81448&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81448&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81448&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81448&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81448&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81448&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81448&r=mysqlcfg