Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using Apache server and it is sending Content-Length = 0 value which is preventing file-downloads, see - http://www.youtubedroid.com/download2.php?v=%5F3XcMEKNws0&title=Akhila+%2CMumbai+reloaded%2CSuper+dancer+2&hq=0 , here are my .htaccess content :

SetEnv no-gzip dont-vary

Here are headers sent by the server :

HTTP/1.1 200 OK
Date: Tue, 15 Dec 2009 06:12:11 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
X-Powered-By: PHP/5.2.11
Content-Description: File Transfer
Content-Disposition: attachment; filename="Akhila ,Mumbai reloaded,Super dancer 2.mp3"
Content-Transfer-Encoding: binary
Expires: 0
Cache-Control: must-revalidate, post-check=0, pre-check=0
Pragma: public
X-Sendfile: ./tmp/64eb3b185e38af95c15405ffb0606e76.mp3
Content-Length: 0
Keep-Alive: timeout=5, max=95
Connection: Keep-Alive
Content-Type: application/octet-stream

Pls. tell how to fix this ?

share|improve this question
    
Please phrase your question in the form of a question. –  Michael Graff Dec 15 '09 at 6:09
    
Michael - I hope it's better now :) –  ServerZilla Dec 15 '09 at 6:18
    
My guess is that this is a programming issue. The download2.php script is responsible for setting the length and such. I see you are using sendfile() or its like, which, so long as it can read the file, should "just work." –  Michael Graff Dec 15 '09 at 6:36
    
I would suspect your script is outputting nothing. Triple check your PHP script. –  PP. Dec 15 '09 at 9:56
add comment

2 Answers

X-Sendfile header won't be sent by apache, so probably you haven't enabled xsendfile in that virtual host. When XSendFile is enabled, apache will be remove X-SendFile header and will sent the file.

share|improve this answer
add comment

The RFC says

The Content-Length header field MUST NOT be sent if these two lengths are different (i.e., if a Transfer-Encoding header field is present). If a message is received with both a Transfer-Encoding header field and a Content-Length header field, the latter MUST be ignored.

So it looks like your server is working correctly for this particular request. This implies the fix is to send the correct file length in the header and not send the Content-Transfer-Encoding header if you have that level of control over what the app is sending.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.