MaRiOsGR
asked on
CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers.
U run this simple php script:
<?php
$a = file_get_contents("http://img.microsoft.com/windows/images/homepage/products/winFamLogo_XP.gif");
echo $a;
?>
and I get the error
CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers.
the only way it works is to change the path to gif file to an actual path with a gif or jpg file..
but it cannot work with urls..
any one knows how to fix this ?
<?php
$a = file_get_contents("http://img.microsoft.com/windows/images/homepage/products/winFamLogo_XP.gif");
echo $a;
?>
and I get the error
CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers.
the only way it works is to change the path to gif file to an actual path with a gif or jpg file..
but it cannot work with urls..
any one knows how to fix this ?
ASKER
I have to fix it to work globaly, not just change some code in one file.
Then you should either use the ISAPI version of PHP or if the solution works for one file, you can change the php.ini setting output_buffering to On:
output_buffering = On
output_buffering = On
*shrug*
What other PHP files do it?
Putting an appropriate content type header (header("Content-type: image/gif")) might help.
(And no, there's no "global" way to automate this.. sorry :))
Btw, I'm don't quite understand why ob_start/ob_end_flush will fix it. I know it will buffer the output and flush it anyway, which is the same as not doing it at all. (I don't think doing "echo $a" will flush in the middle of echo'ing $a, so I don't think there's a need for output buffering.)
What other PHP files do it?
Putting an appropriate content type header (header("Content-type: image/gif")) might help.
(And no, there's no "global" way to automate this.. sorry :))
Btw, I'm don't quite understand why ob_start/ob_end_flush will fix it. I know it will buffer the output and flush it anyway, which is the same as not doing it at all. (I don't think doing "echo $a" will flush in the middle of echo'ing $a, so I don't think there's a need for output buffering.)
ASKER
the header header("Content-type: image/gif" is needed only when
I change this ("http://img.microsoft.com/windows/images/homepage/products/winFamLogo_XP.gif");
to a local file like("mypic.gif");
The problem was shown after an upgrade in the php version...
I test the script in a linux server and it works fine, the problem happens only in the windows box...
I change this ("http://img.microsoft.com/windows/images/homepage/products/winFamLogo_XP.gif");
to a local file like("mypic.gif");
The problem was shown after an upgrade in the php version...
I test the script in a linux server and it works fine, the problem happens only in the windows box...
Hmm, file_get_contents() might be producing an error that you're not seeing. try making a php file with `<?php $a = file_get_contents("http://www.google.com"); echo $a; ?>` and see what the output is.
This is just a hunch, but the fopen wrappers might not be enabled on your windows installation of PHP, and thus produces an error. Not sure why it would give that CGI error though.
This is just a hunch, but the fopen wrappers might not be enabled on your windows installation of PHP, and thus produces an error. Not sure why it would give that CGI error though.
ASKER
aescnt that gives me tha same output...
CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers.
I try to use at the vhost options to use ISAPI for php works.
then reaload the page and I get this error:
The connection was reset
The connection to the server was reset while the page was loading.
I turned off the firewall just in case but nothing changed..
CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers.
I try to use at the vhost options to use ISAPI for php works.
then reaload the page and I get this error:
The connection was reset
The connection to the server was reset while the page was loading.
I turned off the firewall just in case but nothing changed..
ASKER
A possible sollution found,
it is a bug of php 4.4.2 and it doenst allow the includ of http://
we will update to 4.4.4 version tonight.
I will reply with the result.
it is a bug of php 4.4.2 and it doenst allow the includ of http://
we will update to 4.4.4 version tonight.
I will reply with the result.
ASKER
The update fixed everything it was a bug of php 4.4.2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<?php
ob_start();
$a = file_get_contents("http://img.microsoft.com/windows/images/homepage/products/winFamLogo_XP.gif");
echo $a;
ob_end_flush();
?>