[PHP] Re: HTTP headers, IE and downloading
Thank you for your reply! AFAIK the headers sent here are: 'Content-Type' = 'application/x-octetstream', (perhaps other) 'Cache-Control' = 'public', 'Accept-Ranges' = 'bytes', 'Connection'= 'close' [snip] Did you try something like this: ?php header(Content-Type: application/pdf); header(Content-Disposition: inline; filename=foo.pdf); header(Accept-Ranges: bytes); header(Content-Length: $len); header(Expires: 0); header(Cache-Control: private); // header(Pragma: no-cache);//don't send this header!! ? What headers are sent at this moment? Could you post them? For a normal file (not through PHP) the headers are: Accept-Ranges: bytes Connection: Close Content-Length: 25600 Content-Type: application/msword Date: Tue, 23 Dec 2003 09:51:19 GMT ETag: 08f72d578c3c31:8d0 Last-Modified: Tue, 16 Dec 2003 02:03:44 GMT Server: Microsoft-IIS/5.0 And through PHP (my script) it is: Accept-Ranges: bytes Cache-Control: private Connection: Close Content-Disposition: inline; filename=testdoc.doc Content-Length: 25600 Content-Type: application/msword; name=testdoc.doc Date: Tue, 23 Dec 2003 10:03:35 GMT Expires: 0 Pragma: public Server: Microsoft-IIS/5.0 X-Powered-By: PHP/4.2.2 It seems whatever I try to set the headers I have control over, it doesn't work... Is there anyway one can stop PHP from sending the Pragma at all? If you send the same headers and the same data - there _can_not_ be any difference. How should your client recognize any difference? There _must_ be a difference! Use a very small file to test it, so you can compare the whole HTTP-Header + Body easily. Yes, there is a difference, I didn't say there wasn't, just that I couldn't see how that (to me) small difference would actually make such a big difference... Thank you very much! /Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HTTP headers, IE and downloading
Hi! Andreas Magnusson wrote: For a normal file (not through PHP) the headers are: Accept-Ranges: bytes Connection: Close Content-Length: 25600 Content-Type: application/msword Date: Tue, 23 Dec 2003 09:51:19 GMT ETag: 08f72d578c3c31:8d0 Last-Modified: Tue, 16 Dec 2003 02:03:44 GMT Server: Microsoft-IIS/5.0 And through PHP (my script) it is: Accept-Ranges: bytes Cache-Control: private Connection: Close Content-Disposition: inline; filename=testdoc.doc Content-Length: 25600 Content-Type: application/msword; name=testdoc.doc is this defined? I have never seen/used this. I only use: Content-Type: application/msword Date: Tue, 23 Dec 2003 10:03:35 GMT Expires: 0 Pragma: public Server: Microsoft-IIS/5.0 X-Powered-By: PHP/4.2.2 It seems whatever I try to set the headers I have control over, it doesn't work... Is there anyway one can stop PHP from sending the Pragma at all? You could look at http://de3.php.net/session_cache_limiter http://de3.php.net/manual/en/ref.session.php#ini.session.cache-limiter Perhaps you should try none? I use private. But at the moment I don't know exactly which headers are effected here, you should try out. You can find more comments about this topic here: http://de3.php.net/header Kind regards, Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: HTTP headers, IE and downloading
Andreas Magnusson wrote: And through PHP (my script) it is: Accept-Ranges: bytes Cache-Control: private I've had the cache-control header cause problems with IE in the past. It's sent by starting a session, not something you manually send. You can change it using the session functions, though. Try setting it to none. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: HTTP headers, IE and downloading
John W. Holmes [EMAIL PROTECTED] skrev i meddelandet news:[EMAIL PROTECTED] Andreas Magnusson wrote: And through PHP (my script) it is: Accept-Ranges: bytes Cache-Control: private I've had the cache-control header cause problems with IE in the past. It's sent by starting a session, not something you manually send. You can change it using the session functions, though. Try setting it to none. Thanks, I tried that and it actually worked!...once...so since the number of bytes that IE downloads from my file seems to vary each time, I guess it was just a flux of luck that it downloaded the whole file this once sigh... It drives me nuts to think about it, it's just so weird... /Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HTTP headers, IE and downloading
Hi! Andreas Magnusson wrote: I'm writing a script to view/download an email-attachment. If the file happens to be an MS Word document and the browser IE (only tried with 6.0), then the download fails. If I choose to download (Content-Disposition: attachment; filename=whatever.doc) then only a part of the file (2/3) is saved to disk. Of course viewing the file doesn't work either. It doesn't seem to matter what I set the Content-Type to since IE seems to ignore that anyway, however I've tried application/msword, application/octet-stream and some others. I've tried all the things said in the comments to the header-function in the online-docs at php.net. I know my Content-Length header is correct and the whole procedure works great with Netscape 7.0 and if the attachment is a zip-file or a jpeg-image it also works in both IE and Netscape. Have a look at: http://pear.php.net/package/HTTP_Download And the first comment of: http://www.php.net/manual/en/function.session-cache-limiter.php Perhaps you should not use ouput-compression, and look at the headers generated by PHP What headers are sent? Do you use sessions? you can see this using Mozilla + Live Headers, Ethereal, http://schroepl.net/cgi-bin/http_trace.pl ... Regards, Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HTTP headers, IE and downloading
Thanks for your reply! Have a look at: http://pear.php.net/package/HTTP_Download I looked at it and it's hard to see what it does differently from what I do... And the first comment of: http://www.php.net/manual/en/function.session-cache-limiter.php Thanks, I've read that and I'm not using output compression. Perhaps you should not use ouput-compression, and look at the headers generated by PHP What headers are sent? Do you use sessions? I use sessions, and I've tried to send the same headers as the webserver sends if I download a file directly (rather than through PHP). It doesn't work... Maybe I should just create a temporary file and relocate the browser to it in case the browser is IE... you can see this using Mozilla + Live Headers, Ethereal, http://schroepl.net/cgi-bin/http_trace.pl ... Thanks, I've written my own HTTP header tracer in C++, but it hasn't been able to help me since the headers looks good to me... /Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: HTTP headers, IE and downloading
Did you try session_cache_limiter('private_no_expire')? Andreas Magnusson wrote: Thanks for your reply! Have a look at: http://pear.php.net/package/HTTP_Download I looked at it and it's hard to see what it does differently from what I do... And the first comment of: http://www.php.net/manual/en/function.session-cache-limiter.php Thanks, I've read that and I'm not using output compression. Perhaps you should not use ouput-compression, and look at the headers generated by PHP What headers are sent? Do you use sessions? I use sessions, and I've tried to send the same headers as the webserver sends if I download a file directly (rather than through PHP). It doesn't work... Maybe I should just create a temporary file and relocate the browser to it in case the browser is IE... you can see this using Mozilla + Live Headers, Ethereal, http://schroepl.net/cgi-bin/http_trace.pl ... Thanks, I've written my own HTTP header tracer in C++, but it hasn't been able to help me since the headers looks good to me... /Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HTTP headers, IE and downloading
Hi! Andreas Magnusson wrote: Have a look at: http://pear.php.net/package/HTTP_Download I looked at it and it's hard to see what it does differently from what I do... Use Ethereal or your own tracer to find out! And compare to a direct request to a real file! AFAIK the headers sent here are: 'Content-Type' = 'application/x-octetstream', (perhaps other) 'Cache-Control' = 'public', 'Accept-Ranges' = 'bytes', 'Connection'= 'close' And the first comment of: http://www.php.net/manual/en/function.session-cache-limiter.php Thanks, I've read that and I'm not using output compression. Did you try something like this: ?php header(Content-Type: application/pdf); header(Content-Disposition: inline; filename=foo.pdf); header(Accept-Ranges: bytes); header(Content-Length: $len); header(Expires: 0); header(Cache-Control: private); // header(Pragma: no-cache);//don't send this header!! ? What headers are sent at this moment? Could you post them? Perhaps you should not use ouput-compression, and look at the headers generated by PHP What headers are sent? Do you use sessions? I use sessions, and I've tried to send the same headers as the webserver sends if I download a file directly (rather than through PHP). It doesn't work... Maybe I should just create a temporary file and relocate the browser to it in case the browser is IE... If you send the same headers and the same data - there _can_not_ be any difference. How should your client recognize any difference? There _must_ be a difference! Use a very small file to test it, so you can compare the whole HTTP-Header + Body easily. you can see this using Mozilla + Live Headers, Ethereal, http://schroepl.net/cgi-bin/http_trace.pl ... Thanks, I've written my own HTTP header tracer in C++, but it hasn't been able to help me since the headers looks good to me... Oh, I could not know ;-) Kind Regards, Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: HTTP headers, IE and downloading
In hopes that this may be of help to you...I had a hell of a time getting IE to download pdfs that I create on the fly and finally with the help of a couple people I got the magic code which was... $len = strlen($buf); //buf was holding the pdf doc. header(Pragma: public); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); header(Content-type: application/pdf); header(Content-Length: $len); header(Content-Disposition: inline; filename=.$filename..pdf); header(Content-Transfer-Encoding: binary); and in addition had to set the link as a href=http://mysite.com/myphpPDFscript.php?pdf=anything.pdf and after all of that it worked. Which ones you may need is beyond me. I do not know enough about how the different browsers handle headers and really only needed to get that one functionality working for me. I hope examining it can help... Larry -Original Message- From: Andreas Magnusson [mailto:[EMAIL PROTECTED] Sent: Monday, December 22, 2003 1:44 PM To: [EMAIL PROTECTED] Subject: [PHP] Re: HTTP headers, IE and downloading Thanks for your reply! Have a look at: http://pear.php.net/package/HTTP_Download I looked at it and it's hard to see what it does differently from what I do... And the first comment of: http://www.php.net/manual/en/function.session-cache-limiter.php Thanks, I've read that and I'm not using output compression. Perhaps you should not use ouput-compression, and look at the headers generated by PHP What headers are sent? Do you use sessions? I use sessions, and I've tried to send the same headers as the webserver sends if I download a file directly (rather than through PHP). It doesn't work... Maybe I should just create a temporary file and relocate the browser to it in case the browser is IE... you can see this using Mozilla + Live Headers, Ethereal, http://schroepl.net/cgi-bin/http_trace.pl ... Thanks, I've written my own HTTP header tracer in C++, but it hasn't been able to help me since the headers looks good to me... /Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: HTTP headers, IE and downloading
Hi! Andreas Magnusson wrote: I'm writing a script to view/download an email-attachment. If the file happens to be an MS Word document and the browser IE (only tried with 6.0), then the download fails. If I choose to download (Content-Disposition: attachment; filename=whatever.doc) then only a part of the file (2/3) is saved to disk. Of course viewing the file doesn't work either. It doesn't seem to matter what I set the Content-Type to since IE seems to ignore that anyway, however I've tried application/msword, application/octet-stream and some others. I've tried all the things said in the comments to the header-function in the online-docs at php.net. I know my Content-Length header is correct and the whole procedure works great with Netscape 7.0 and if the attachment is a zip-file or a jpeg-image it also works in both IE and Netscape. Once a user of the PHP Classes site reported a similar problem when downloading zip versions of the class archives. I report a problem to Winzip support people and sent me the following reply. Notice, in the PHP Classes site, downloads support byte range requests, which are used by download managers to fetch files in many chunks. It looks to me that the problem is due to a bug in IE as reported in the address below. We typically see this behaviour when the temporary internet files folder is full; you might try clearing some files from this location, either manually or via your browser's options. There's also a known issue with the internet explorer program; you might check the information available at the URL: http://support.microsoft.com/default.aspx?scid=kb;en-us;308090 Another possible explanation is that an Anti Virus product is involved; if the 'scan' of the archive is not completed when the browser 'passes' the file to WinZip, the result is a 'blank' WinZip window. I'd suggest temporarily disabling or reconfiguring your Anti virus software to avoid the behaviour. Regards, Andreas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php