php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81448 file_get_contents cuts off incoming HTTP data
Submitted: 2021-09-16 15:57 UTC Modified: 2021-09-16 21:18 UTC
From: gajowy at agzeta dot pl Assigned:
Status: Open Package: HTTP related
PHP Version: 8.0.10 OS: Windows 10 64-bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gajowy at agzeta dot pl
New email:
PHP Version: OS:

 

 [2021-09-16 15:57 UTC] gajowy at agzeta dot pl
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-09-16 15:58 UTC] gajowy at agzeta dot pl
The NASA server is nginx.
 [2021-09-16 21:18 UTC] cmb@php.net
I can confirm that there is an issue (PHP-7.4 on Windows).
Increasing default_socket_timeout doesn't help.
 [2023-01-09 09:47 UTC] fariba dot shami326 at gmail dot com
That's great. I was impressed by your writing. I am happy to see such a topic. Please come to my blog and read it.

(https://www.greenskyonline.me/)php.net
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 09:01:30 2024 UTC