Hi,

A bit off-topic but it has been bugging me for so long I could not withhold
it from you.

I had a strange problem with this simple page called "bijlage" serving
attachments:

<?php
 $attachment = mgd_get_attachment ($argv[0]);
 if ($attachment)
 {
   //header("Content-disposition: attachment;
filename=".$attachment->title);
   //header("filename=".$attachment->title);
   mgd_serve_attachment($argv[0]);
 }
 else
 {
      $redirect = "Location: http://www.mysite.com";;
      header($redirect);

 }
 exit();
?>

The problem was that a link such as
http://www.mysite.com/bijlage/2160/tips.pdf (you notice the "tips.pdf" is
only for decoration - and for making IE display the right file name in a
"save target as" dialog) did work fine with Internet Explorer (IE6) as long
as I tried to reach them clicking the link in the browser (so let's say on
the page http://www.mysite.com refering to it).

When copy-pasting the link directly in the IE address barr, or clicking
http://www.mysite.com/bijlage/2160/tips.pdf in a mail message, the browser
tried to download the file, but gave a message it couldn't find it.  I had
no such problem with Opera nor Mozilla.  Another thing I noticed and I
thought might be related was that Google, although nicely indexing all html
on my site, did not bother to index the pdfs (did any of you notice this
with midgard attachments?)

Problems with IE have been mentioned a few times on the list, such as this
discussion:
http://marc.theaimsgroup.com/?t=98525147100004&r=1&w=2

Although apparently (according to the postings) it should have been solved
in IE5 and 6, I kept having the problem, so I was left to believe there was
an inevitable incompatibility between mgd_serve_attachment() and IE6.  This
until I experimented a bit with the curl -i option, that lets you look at
the headers sent to the client.

This is a header sent by the server while simply serving a pdf file from the
file system (causing no problem for IE whatsoever off course):

HTTP/1.1 200 OK
Date: Tue, 20 Aug 2002 11:29:45 GMT
Server: Apache-AdvancedExtranetServer/1.3.22 (Envida Linux/2mdk)
Midgard/1.4.2-cvs-20020125/SG mod_ssl/2.8.5 OpenSSL/0.9.6 PHP/4.1.1
Last-Modified: Tue, 20 Aug 2002 09:24:21 GMT
ETag: "11423c-f6b2-3d620ac5"
Accept-Ranges: bytes
Content-Length: 63154
Content-Type: application/pdf

This was the header sent by my original "bijlage" page mentioned above:

HTTP/1.1 200 OK
Date: Tue, 20 Aug 2002 09:10:41 GMT
Server: Apache-AdvancedExtranetServer/1.3.22 (Envida Linux/2mdk)
Midgard/1.4.2-cvs-20020125/SG mod_ssl/2.8.5 OpenSSL/0.9.6 PHP/4.1.1
X-Powered-By: PHP/4.1.1
Set-Cookie: ENVIDA=3899ac04ee1df1c93d4d496185e751e5; expires=Thu, 19-Sep-02
09:10:41 GMT; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: application/pdf

It appeared I was sending a cookie along with the file, and indeed, this had
to do with a visitors tracking class (Justin Koivisto's phpTracker at
http://www.phpclasses.org/browse.html/package/414.html) I used in the style
connected to the page starting a session, and thus sending the sessionid
("ENVIDA") as a cookie.

I first thought the cookie was the problem, so I used the function
ini_set("session.use_cookies", 0); in this style in order to avoid cookies
and got this header:

HTTP/1.1 200 OK
Date: Tue, 20 Aug 2002 10:51:03 GMT
Server: Apache-AdvancedExtranetServer/1.3.22 (Envida Linux/2mdk)
Midgard/1.4.2-cvs-20020125/SG mod_ssl/2.8.5 OpenSSL/0.9.6 PHP/4.1.1
X-Powered-By: PHP/4.1.1
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: application/pdf

Still didn't work, and I decided to ditch the session as a whole by
disabling the function session_start() in the classes' code, which got me
rid of some extra headers, and finally satisfied IE6, now working flawlessly
in all circumstances:

HTTP/1.1 200 OK
Date: Tue, 20 Aug 2002 10:53:54 GMT
Server: Apache-AdvancedExtranetServer/1.3.22 (Envida Linux/2mdk)
Midgard/1.4.2-cvs-20020125/SG mod_ssl/2.8.5 OpenSSL/0.9.6 PHP/4.1.1
X-Powered-By: PHP/4.1.1
Transfer-Encoding: chunked
Content-Type: application/pdf

The only problem I now left with is that I can log the requests for my pdf
files served from midgard, but I cannot connect them to registered user
sessions - all due to IE's strange reaction to the extra header information.
It's off course to early to see whether Google will now index the pdf's, but
I guess also that might have been solved.

Anyway, thx for making it to the end of this dreadfully long posting :-)

pascal


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to