Bug #80256 [Ver]: file_get_contents strip first line

From: Date: Tue, 20 Oct 2020 11:12:14 +0000
Subject: Bug #80256 [Ver]: file_get_contents strip first line
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229791@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80256&edit=1

 ID:                 80256
 Updated by:         nikic@php.net
 Reported by:        code at luigifab dot fr
 Summary:            file_get_contents strip first line
 Status:             Verified
 Type:               Bug
 Package:            Streams related
 Operating System:   Debian with Docker
 PHP Version:        8.0.0RC2
 Block user comment: N
 Private report:     N

 New Comment:

Presumably related to the use of chunked transfer encoding in some way.


Previous Comments:
------------------------------------------------------------------------
[2020-10-20 11:02:39] nikic@php.net

Seems to be related to the switch to HTTP 1.1. I get the old result when forcing HTTP 1.0 using

    $ctx = stream_context_create(['http' => ['protocol_version' =>
'1.0']]);

------------------------------------------------------------------------
[2020-10-19 11:16:40] code at luigifab dot fr

Description:
------------
I try to read an export of a Google Sheet with file_get_contents.
With PHP 8, the first line of the export "is removed".

Test script:
---------------
error_reporting(E_ALL);
ini_set('display_errors', 1);

$data = file_get_contents('https://docs.google.com/spreadsheets/d/e/2PACX-1vTqS3j4Wd-Bt7Zb52eJiQed_NilvKo0wGdw8noL4vhFOPsUeV9O6EN8odni6YepDGicYApcJ4Zy5opv/pub?gid=1790927668&single=true&output=tsv');
echo 'version:   ',PHP_VERSION,"\n";
echo 'mb_strlen: ',mb_strlen($data),"\n";
echo substr(print_r($data, true), 0, 50),"\n";


Expected result:
----------------
The truth:

php7.2 /var/www/filegetcontents.php
version:   7.2.34-4+0~20201018.51+debian10~1.gbpc553f7
mb_strlen: 187473
config\ten-US (english/Simple)\t\tfr-FR (français/Fr

php7.3 /var/www/filegetcontents.php
version:   7.3.23-4+0~20201018.71+debian10~1.gbpfc8934
mb_strlen: 187473
config\ten-US (english/Simple)\t\tfr-FR (français/Fr

php7.4 /var/www/filegetcontents.php
version:   7.4.11
mb_strlen: 187473
config\ten-US (english/Simple)\t\tfr-FR (français/Fr

(I have replaced the tabulation character with \t)

Actual result:
--------------
php8.0 /var/www/filegetcontents.php 
version:   8.0.0RC2
mb_strlen: 186973
\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
\t540 cases do

(I have replaced the tabulation character with \t)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80256&edit=1


Thread (8 messages)

« previous php.bugs (#229791) next »