ID:               25863
 Updated by:       [EMAIL PROTECTED]
 Reported By:      salmanarshad2000 at yahoo dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         CGI related
 Operating System: win32 only
 PHP Version:      4CVS, 5CVS, 6CVS..
 New Comment:

It turns out, this is not a bug in PHP after all :)

http://support.microsoft.com/default.aspx?scid=kb;EN-US;884764

Thanks to php at bryans dot net for digging it up in their database.


Previous Comments:
------------------------------------------------------------------------

[2004-11-24 13:59:38] php at bryans dot net

I don't know if this has solved the intermittent problem I was
experiencing with PHP 4.3.9/Server 2003/IIS6 on a dual processor
system, but Microsoft have issued a hotfix for "Errors may occur when
you run CGI applications on a fast multi-processor computer that is
running IIS 5.0 and IIS 6.0". See Microsoft Knowledgebase article
884764.

------------------------------------------------------------------------

[2004-11-09 14:37:30] dan at flowofchi dot nl

Whoops!

Here is the line to add:

print "Content-type: text/html\n\n";

------------------------------------------------------------------------

[2004-11-09 14:36:25] dan at hostway dot nl

Hi all!

Actually, all you need to do is specify a MIME type.  Put this line at
the top of your code, and voila!

http://bugs.php.net/bug.php?id=25863

Pretty simple really...   ;)

------------------------------------------------------------------------

[2004-11-04 04:12:02] mmyer at rightnowtech dot com

We've spent an extensive amount of time investigating this and have
found a work-around for the PHP CGI error in the header("Location:
<url>") redirect case.  In our experience, this was only encountered on
Windows 2003 Server and IIS 6, however it seems others have experienced
similar problems elsehwere.

First some observations:
1. As reported in bug #9852, changing the performance options fixes the
problem on slower hardware.  With faster hardware, this had no effect. 
Hence, it must be some kind of race condition.  (to change this setting
r-click on My Computer -> Advanced -> Performance -> Advanced and select
Background Services)

2. If the php cgi did an odbc connection, the problem occurs.  Without
the odbc connection, no problem.

3. If the php cgi wastes some time in a busy loop prior to issuing the
header() redirect, it works.  For us, doing for($i=0; $i<1000000; $i++)
did the trick.  Issuing a sleep() did not work.  Strange, but again,
seems to indicate a race condition in IIS.

4. One of the previous posts mentioned that re-directing to the IP
address instead of the domain worked.  This was the primary clue to the
solution.

Our solution:
The web browser will use the same TCP connection to send a subsequent
request if it receives a Location: redirect for the same domain.  In
observation #4 above, it works because the re-direct is issued to an IP
address which causes the browser to think the redirect is to a different
system and close the existing TCP connection and make a new connection. 
It seems that IIS has a problem if (a) the initial CGI execution occurs
very quickly and (b) a subsequent HTTP request is received over the
same socket as the first request.  So the work-around is to force the
browser to close the TCP connection and open a new connection when a
redirect occurs.  This can be done by issuing a "Connection: close"
header in addition to the "Location: redirect" header.  The following
has solved the problem for us:

header("Connection: close");
header("Location: $url");

Hopefully some day Microsoft will fix this...

------------------------------------------------------------------------

[2004-10-16 02:04:49] marc at durdin dot net

The situation that I consistently see this bug in is:

  header("Location: http://site/";);

The error does not occur every time.  To me, this does suggest a timing
issue.  One piece of pertinent information is that the error is
occurring on the page redirected to, and not on the page doing the
redirection, as you can see from the following log entries.  Steps
taken to generate this were: Open web browser to default page
(index.php), click on link to home.php - which detects that I am not
logged in and redirects to login.php (which then fails with error
502).

2004-10-15 23:37:39 192.168.20.9 GET /index.php - 80 - 192.168.20.11
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
200 0 0
2004-10-15 23:37:41 192.168.20.9 GET /home.php - 80 - 192.168.20.11
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
302 0 0
2004-10-15 23:37:41 192.168.20.9 GET /login.php - 80 - 192.168.20.11
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322)
502 2 0

It's a real pain - IIS doesn't give any detail in its logs about the
error, there are no eventlog entries, etc., and running it through Zend
Server Debugger shows no issues in the headers that I can see.

This is basically the code I am using to redirect:

    header("Location: http://"; . $_SERVER['HTTP_HOST'] . 
       str_replace("\\", "/", 
       dirname($_SERVER['PHP_SELF'])) . $page);
    exit;

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/25863

-- 
Edit this bug report at http://bugs.php.net/?id=25863&edit=1

Reply via email to