Solved

CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers.

Posted on 2006-11-21
11
413 Views
Last Modified: 2013-11-18
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 ?
0
Comment
Question by:MaRiOsGR
  • 5
  • 2
  • 2
  • +1
11 Comments
 
LVL 29

Expert Comment

by:TeRReF
ID: 17987316
Try this:
<?php
ob_start();
$a = file_get_contents("http://img.microsoft.com/windows/images/homepage/products/winFamLogo_XP.gif");
echo $a;
ob_end_flush();
?>
0
 
LVL 2

Author Comment

by:MaRiOsGR
ID: 17987427
I have to fix it to work globaly, not just change some code in one file.

0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17987817
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:aescnt
ID: 17988541
*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.)
0
 
LVL 2

Author Comment

by:MaRiOsGR
ID: 17988768
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...

0
 
LVL 6

Expert Comment

by:aescnt
ID: 17988830
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.
0
 
LVL 2

Author Comment

by:MaRiOsGR
ID: 17994116
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..
0
 
LVL 2

Author Comment

by:MaRiOsGR
ID: 17994260
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.
0
 
LVL 2

Author Comment

by:MaRiOsGR
ID: 18150996
The update fixed everything it was a bug of php 4.4.2
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 18473038
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question