Silviu Posted September 13, 2013 Report Posted September 13, 2013 Am un script prin care citesc fisierele cu readfile pentru a le oferi spre descarcare. Problema este ca, serverul nu trimite spre anumite browsere, cum ar fi Google Chrome headerul Content-Length am dezactivat compresia gzip din Apache, in .htaccess am setat SetEnv no-gzip dont-vary si nu stiu ce sa mai fac, pentru ca la Network in Chrome tot apare headerul cum ca ar fi activata compresia gzip (am dat restart la apache). Ma chinui de ore bune si nu ii dau deloc de cap. Problema dubioasa este ca pe Firefox trimite Content-Length-ul si nu intelg de ce. Quote
yo20063 Posted September 13, 2013 Report Posted September 13, 2013 Ai incercat clear cache la chrome? Quote
Silviu Posted September 13, 2013 Author Report Posted September 13, 2013 Ai incercat clear cache la chrome?Da, fara succes. Quote
Nytro Posted September 13, 2013 Report Posted September 13, 2013 TU trebuie sa trimiti asta. header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($file));De aici: PHP: readfile - Manual Quote
Silviu Posted September 13, 2013 Author Report Posted September 13, 2013 TU trebuie sa trimiti asta. header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($file));De aici: PHP: readfile - ManualAm citit mosule peste tot, am testat si aia, am testat-o chiar si acum si nu imi mai arata marimea nici pe Firefox.. Chiar nu mai am idei. Quote
Silviu Posted September 13, 2013 Author Report Posted September 13, 2013 Poti pune codul?Sa nu te sperii ca am ajuns la carnatul asta, dar chiar nu mai stiu ce sa ii fac:ob_end_flush(); // The ob_gzhandler oneheader("Status: 200");header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');header("Pragma: hack");header("Cache-Control: must-revalidate, post-check=0, pre-check=0");header("Cache-Control: private", false);header('X-Pad: avoid browser bug');header("Content-Description: File Transfer");header("Content-Type: application/force-download");header("Content-Type: application/download");header("Content-Type: audio/mpeg");header("Content-Disposition: attachment; filename=\"".$nume."\""); header("Content-Transfer-Encoding: binary");header("Content-Length:".$contentLength); ob_clean(); flush();readfile(str_replace(" ", "%20", $url));ob_end_flush(); // The main oneexit; Quote
eusimplu Posted September 13, 2013 Report Posted September 13, 2013 Celelalte headere le primesti? Cam prea mult output buffer in cod.$contentLength de unde il iei? Daca lipseste din cod am putea pierde chiar esentialul. Quote
Silviu Posted September 13, 2013 Author Report Posted September 13, 2013 Celelalte headere le primesti? Cam prea mult output buffer in cod.$contentLength de unde il iei? Daca lipseste din cod am putea pierde chiar esentialul.Il iau prin curl, nu e problema, l-am afisat si e ok. Si da, celalalte headere le primesc: Quote
eusimplu Posted September 13, 2013 Report Posted September 13, 2013 S-ar putea sa gresesc avand in vedere ca pe firefox functioneaza si nici nu cunosc tot codul, dar incearca asa:ob_end_clean(); // The ob_gzhandler oneheader("Status: 200");header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');header("Pragma: hack");header("Cache-Control: must-revalidate, post-check=0, pre-check=0");header("Cache-Control: private", false);header('X-Pad: avoid browser bug');header("Content-Description: File Transfer");header("Content-Type: application/force-download");header("Content-Type: application/download");header("Content-Type: audio/mpeg");header("Content-Disposition: attachment; filename=\"".$nume."\""); header("Content-Transfer-Encoding: binary");header("Content-Length:".$contentLength); readfile(str_replace(" ", "%20", $url));ob_end_flush(); // The main oneexit; Quote
Silviu Posted September 13, 2013 Author Report Posted September 13, 2013 Nu vrea nici pe Firefox nici pe Chrome. Quote
fedorffixxzz Posted September 13, 2013 Report Posted September 13, 2013 RFC 2616 - Hypertext Transfer Protocol -- HTTP/1.1Content-Length = "Content-Length" ":" 1*DIGIT An example is Content-Length: 3495este posibil ca tu sa omiti acel spatiu intre ":" si numar? Quote
Silviu Posted September 13, 2013 Author Report Posted September 13, 2013 RFC 2616 - Hypertext Transfer Protocol -- HTTP/1.1este posibil ca tu sa omiti acel spatiu intre ":" si numar?Pai dupa cum vezi tu in codul ce l-am postat, nu am omis nimic. Quote
fedorffixxzz Posted September 13, 2013 Report Posted September 13, 2013 Pai dupa cum vezi tu in codul ce l-am postat, nu am omis nimic.esti sigur?eu vad:header("Content-Transfer-Encoding: binary");header("Content-Length:".$contentLength); nu e niciun spatiu dupa ":", este spatiu in valoarea (tratata ca string, ex. " 4321") detinuta de variabila?ai testat?poate asta e motivul pentru care firefox interpreteaza acel spatiu ce lipseste iar celalalte respecta strict rfc Quote
Silviu Posted September 13, 2013 Author Report Posted September 13, 2013 esti sigur?eu vad:nu e niciun spatiu dupa ":", este spatiu in valoarea (tratata ca string, ex. " 4321") detinuta de variabila?ai testat?poate asta e motivul pentru care firefox interpreteaza acel spatiu ce lipseste iar celalalte respecta strict rfcNu merge mosule, am testat acum, oricum ar fi fost culmea sa fie de la aia. Pur si simplu serverul nu trimite headerul ala, parca e futut in cur, nu stiu ce naiba are. Quote
fedorffixxzz Posted September 13, 2013 Report Posted September 13, 2013 Il iau prin curl, nu e problema, l-am afisat si e ok. Si da, celalalte headere le primesc:https://en.wikipedia.org/wiki/Chunked_transfer_encoding Quote
Zatarra Posted September 13, 2013 Report Posted September 13, 2013 @readfile nu-ti poate reda size-ul. Incearca sa setezi size-ul inainte de readfile. Arata-ne unde intializezi variabila de length. Daca preiei content-ul prin read file de pe alt site uita de size deoarece nu pot, mi-am batut si eu capul (explicatia este ca tu nu faci cache la ce trimiti userului prin force download). In cazul in care vei face cache pe server atunci vei avea si length-ul. Quote
Dubfx Posted September 13, 2013 Report Posted September 13, 2013 Simplu bre, inainte de readfile pune astasession_write_close();Gata, ai headerul acolo Quote
Silviu Posted September 13, 2013 Author Report Posted September 13, 2013 (edited) Simplu bre, inainte de readfile pune astasession_write_close();Gata, ai headerul acolo 'Pare rau, dar nu merge nici asta.@Zatarra, m?rimea o preiau dup? cum am zis din headerele request-ului cURL, deci nu e acolo problema. Am s?pat cu Dubfix ?i se pare c? e din configura?ia apache-ului, dar acum s? vedem ce nu e ok, pentru c? nu e primul script pe care îl fac, dar nu am mai avut problema asta pân? acum. Edited September 13, 2013 by Silviu Pentru Zatarra Quote