I have commissioned a new FAMP server (running FreeBSD, otherwise it would have been LAMP).
I have troubles with Internet Explorer receiving something that confuses it.
I do this:
Code: Select all
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
$File = $objDB->query_get_first_row("select [... ...]");
if ($File !== false){
header("Content-Length: ".$File['Size']);
header("Content-type: ".$File['MimeType']);
if ($BrowserIsGecko){
header("Content-Disposition: attachment; filename=\"".(str_replace(Array("Å","å","Ä","ä","Ö","ö"),Array("A","a","A","a","O","o")));
}else{
header("Content-Disposition: attachment; filename=\"".$File['FileName']."\"");
}
if ($ArrContent = $objDB->query_get_rows("select Content from FileContent where FileID={$File['ID']} order by ID")){
foreach ($ArrContent as $Chunk)
echo $Chunk['Content'];
}
}I have tested the very same code and database on two other boxes running gentoo linux and Apache2, php4. The FreeBSD server (the one with the problem) is running apache1 with php4.
Sympthom:
Whenever I , or anyone of our students, use Internet Explorer to download files from the db as described above, Internet explorer fails do find the PHP script. It bails with the error (loosely translated from swedish): "Could not open file-download.php?ID=1280
This URL can not be opened. The location is either unavailable or I cannot find it. Please try again later."
Thing is, of course everything works as expected using firefox or any other normal browser. <insert wild,intense,detailed and extensive rant, deserved from years of intellectual torture
I have isolated the problem to occur only when my app runs on our primary web site. I try to discover the headers sent by apache to see the differences and maybe patch a workaround or change the apache config so the problem disappears, but I can only do that with normal files using an extension to firefox called "web developer", where I click "Information->View response headers".
From a working system I get:
Code: Select all
Date: Wed, 12 Jan 2005 09:01:27 GMT
Server: Apache/2.0.52 (Gentoo/Linux) PHP/4.3.10
X-Powered-By: PHP/4.3.10
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Last-Modified: Wed, 12 Jan 2005 09:01:27 GMT
Content-Length: 344
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Content-Type: text/htmlCode: Select all
Date: Wed, 12 Jan 2005 10:46:39 GMT
Server: Apache/1.3.33 (Unix) PHP/4.3.9
X-Powered-By: PHP/4.3.9
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Last-Modified: Wed, 12 Jan 2005 10:46:39 GMT
Keep-Alive: timeout=15, max=93
Connection: Keep-Alive
Transfer-Encoding: chun ked
Content-Type: text/htmlNow, I didn't explicitly add the "Transfer-Encoding" header, and I don't see it in the httpd.conf file. (It doesn't have includes either). I don't know if this is what causes Internet Explorer to fail, but I would like to be able to catch the headers output from the script above, so I can debug that as well. The firefox extension I used to catch the above info doesn't operate on specific URLs but on the page already loaded, it seems. Thus, cannot read extract the headers sent in the file download case.
I tried with telnet, which was a funny experience:
Code: Select all
jonas@jw jonas $ telnet hostname.com 80
Trying 211.xxx.xxx.xxx...
Connected to hostname.com.
Escape character is '^]'.
GET http://hostname.com/file-download.php?ID=42020
<html><head><link rel="StyleSheet" href="main.css" type="text/css"></head>
<body><table height="100%" align="center"><tr><td valign="middle" align="center">
an error occured. File not found in database.<br><br><a href="overview.php?WhatNow=View">Back</a>
</td></tr></table></body></html>
Connection closed by foreign host.
jonas@jw jonas $So I lack knowledge on how to debug my case. Does anyone know how to easily extract the response HTTP-headers from a GET-request with common linux tools?