Remote files that are too big (?) do not load correctly

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hstr
Forum Newbie
Posts: 2
Joined: Tue Aug 17, 2004 4:54 am

Remote files that are too big (?) do not load correctly

Post by hstr »

Problem: I want to include HTML generated by another web application inside a PHP page. I do it like this:
<?php
$url = "http://foo.bar?";
$url .= $_SERVER["QUERY_STRING"];
@readfile($url);
?>

Depending on the size of the returned HTML string (i.e. depending on the QUERY_STRING) there are three problems I encounter:

1. The $url is fetched many times (up to 20), looks like an automatic reload.
2. Sometimes the browser tells finally, that the whole PHP page (!) cannot be found (but when I use another QUERY_STRING, i.e. empty) the PHP page is there again)
3. The returned HTML is intermingled with strange characters: ?0M? which definitely don't come from the web application (at foo.bar). They appear each time at different positions.

N.B.: With small results (up to 4K) everything works perfect: no automatic reload, no "page not found", no strange characters.

Has anyone ever encountered this or a similar problem?

Thanks in advance
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

try using [php_man]curl[/php_man].. or [php_man]file_get_contents[/php_man].. [php_man]readfile[/php_man] sends the data directly to the browser..
hstr
Forum Newbie
Posts: 2
Joined: Tue Aug 17, 2004 4:54 am

file_get_contents doesn't work properly neither

Post by hstr »

I have the same problems with file_get_contents.
Does it matter that there is no content-length in the http header of the remote web application?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I've never had a problem loading the data from a remote server that didn't have Content-Length...
Post Reply