#38826 [Fbk]: file_get_contents for a URL returns nothing when file > 255 bytes
| From: | tony2001@php.net | Date: | Thu, 14 Sep 2006 12:49:15 +0000 |
| Subject: | #38826 [Fbk]: file_get_contents for a URL returns nothing when file > 255 bytes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-102178@lists.php.net to get a copy of this message | ||
ID: 38826
Updated by: tony2001@php.net
Reported By: mfp@php.net
Status: Feedback
Bug Type: Streams related
Operating System: WinXP
PHP Version: 5.1.6
New Comment:
>I am not sure how seriously to take the response
Well, I'm not sure either how to take a report with "http://localhost"
as a test data.
Previous Comments:
------------------------------------------------------------------------
[2006-09-14 12:48:19] tony2001@php.net
Please upload the file somewhere and put the link here.
Make sure you're looking into the source of the page or even better try
it with CLI.
I cannot reproduce anything like that:
var_dump(file_get_contents("http://tony2001.phpclub.net/dev/tmp/info.xsd"));
works like a charm with any PHP version I have here (and I have a lot
of them).
------------------------------------------------------------------------
[2006-09-14 12:36:15] mfp@php.net
Errr... I am not sure how seriously to take the response "[14 Sep
11:51am UTC] tony2001@php.net", but here goes:
1. The reproduce code is:
<?php
echo
file_get_contents('http://localhost/MyService/AddressBook/info.xsd');
?>
2. I do not know how to supply a test script that does not rely on
external resources since this problem occurs reading a URL and almost
by definition a URL is an external resource.
------------------------------------------------------------------------
[2006-09-14 11:51:33] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2006-09-14 11:47:43] mfp@php.net
Description:
------------
I am using file_get_contents with a URL. If the file I want to get is
255 bytes I get it fine. If it is 256 bytes or more, up to some upper
limit which is somewhere around 3.5K, I get an empty string.
Although I have only illustrated it with file_get_contents(), from the
circumstances in which I first noticed odd behaviour I think it also
applies generally to files opened with fopen().
Incidentally, the right number of bytes are coming from the web server,
as the apache access log shows it is delivering 256 bytes:
127.0.0.1 - - [14/Sep/2006:12:34:37 +0100] "GET
/MyService/AddressBook/info.xsd HTTP/1.0" 200 256
Reproduce code:
---------------
echo
file_get_contents('http://localhost/MyService/AddressBook/info.xsd');
where the target file info.xsd is 256 bytes long
Expected result:
----------------
the contents of the file
Actual result:
--------------
nothing - empty string
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38826&edit=1