Jump to content

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


Recommended Posts

Hi Folks,

Please help on this error.. I have installed prestashop 1.2.2 on windows hosting. I was able to install successfully and shopping cart is working fine including Admin module. The problem is when customer tried to login authentication.php is throwing an error CGI Error:the specified CGI application misbehaved by not returning a complete set of HTTP headers.

Anyone could assist me on this.. it's an urgent issue


Many thanks in advance

Link to comment
Share on other sites

hi folks

Actually, i have hosted prestashop in windows hosting, Managed to figure out root cause
authentication.php, replaced the following script,
if (!$authentication OR !$customer->id)
$errors[] = Tools::displayError('authentication failed');
else
{
$cookie->id_customer = intval($customer->id);
$cookie->customer_lastname = $customer->lastname;
$cookie->customer_firstname = $customer->firstname;
$cookie->logged = 1;
$cookie->passwd = $customer->passwd;
$cookie->email = $customer->email;
if (Configuration::get('PS_CART_FOLLOWING') AND (empty($cookie->id_cart) OR Cart::getNbProducts($cookie->id_cart) == 0))
$cookie->id_cart = intval(Cart::lastNoneOrderedCart(intval($customer->id)));
$id_address = intval(Address::getFirstCustomerAddressId(intval($customer->id)));
$cookie->id_address_delivery = $id_address;
$cookie->id_address_invoice = $id_address;
Module::hookExec('authentication');
if ($back = Tools::getValue('back'))
{
// Tools::redirect($back);
header("location: $back");
exit;
}
header("location: my-account.php");
exit;
//Tools::redirect('my-account.php');
}

Link to comment
Share on other sites

Hi again,

After some testing, here is what I found out:
1 - I could only replicat the behaviour on windows machines (PHP on IIS)
2 - It seems PHP on IIS does not like incomplete redirect headers
3 - on the Tools.php files under classes I changed the following on the function redirectAdmin arround line 57.


  
//replace this line
header('Location: '.$url);

//by the following
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {
 $pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
 $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
$chars = preg_split('//', $pageURL, -1, PREG_SPLIT_NO_EMPTY);
$slash = 3; // 3rd slash
$i = 0;
foreach ($chars as $key=>$char) {
           if ($char == '/') {
               $j = $i++;
           }

           if ($i == 3) {
               $pos = $key;
               break;
           }
       }
$url_base = substr($pageURL, 0, $pos);

header('Location: '.$url_base.$url);
//end replaced code


For a simple solution you can hardcode the main base address but this will get it running on all cases.
hope it works for other as well.

Link to comment
Share on other sites

  • 8 months later...

Hey, am running ps 1.2.5 and got this "CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers." message sometimes in the ps admin after trying to save some modifications.

Tried to modify tools.php but it was just braking the whole site. Any clue ?

Link to comment
Share on other sites

  • 1 month later...
@kwin

Hello Folks

Issue has been resolved.
We need to change PHP settings to run as ISAPI / Fast CGI in windows hosting

Thanks


If you don't hava access, ask your host to do it.


Sorry, that's impossible. Its not on the list of system requirements for running Prestashop. A lot of hosts don't support ISAPI, so its not as simple as just change settings or getting your host to do it. It would mean changing hosting company, and I'm sure the Prestashop guys wouldn't let people go through the whole setup process, only to find that it doesn't work properly. That's why they give you the system requirements before you download!
Link to comment
Share on other sites

×
×
  • Create New...