Naming file downloads (Content-Disposition??)

#1
Greetings... I am attempting to name a file that is to be downloaded from my webserver but the downloaded file name always ends up being the name of the page "downloads" that called the action.

I have researched how this is done on most webservers and found that the Content-Disposition header lets you state that the file is infact an attachment and then lets you pass a filename= parameter... I have used Content-Disposition to no avail... and am not even sure this is a header that LSWS uses.

How is this achieved in litespeed?

Thanks!
 
#2
I see that a few people have viewed this post... Please let me know if I need to be more clear about my original post. I need to resolve this issue.

I am trying to download a file using the X-LiteSpeed-Location header, so that litespeed will serve a static file on my machine. It effectively finds the file serves the file. But downloads the file as the name of the page that made the initial request 'downloads' and additionally returns a 500.

Please if anyone has any information about this issue... or can give me a lead to chase. I really need to get this taken care of.

Thanks so much :)
 
#4
Thanks for your reply...

I have done this to no avail... The Content-Disposition header simply seems to not work. In addition, how can the 500 error showing up in firebug be explained.
 

mistwang

LiteSpeed Staff
#5
Please create a test application in order for us to reproduce it in our lab easily. We will make it work properly in our next bug fix release.
 
#6
I appreciate the response. I'm afraid I don't have the time (or know how for that matter) to build a test app for you to replicate the error. I can however tell you that the code I am using works fine when testing on mongrel on my development box.

It really seems like Litespeed is ignoring the Content-Disposition header all together when dealing with an internal redirect.

I have a very limited time-frame to get this application deployed. Is there anything else I can try to do to get my beloved Litespeed working... or do I have to undergo the transition to an uglier more complex server configuration.

Please if there is anything else I can try.. .anything I may have overlooked ( a config setting or anything) Please let me know... I really want to go with litespeed.
 

mistwang

LiteSpeed Staff
#7
Please try our 3.3.2 build package, see if everything works properly.
Just change the version number to "3.3.2" in the download URL to get the package.
 

zellster

Well-Known Member
#8
Please try our 3.3.2 build package, see if everything works properly.
Just change the version number to "3.3.2" in the download URL to get the package.
LSWS standard edition 3.3.2 and LSAPI 2.8 do not allow a Content-Disposition header response from Rails. Note that the Rails code is not using an internal redirect. Snippet is something like:

def open_file
filename = "#{RAILS_ROOT}/test.pdf"
output = File.read("#{filename}")

if @request.env['HTTP_USER_AGENT'] =~ /msie/i
@headers['Pragma'] = ''
@headers['Cache-Control'] = ''
else
@headers['Pragma'] = 'no-cache'
@headers['Cache-Control'] = 'no-cache, must-revalidate'
end

send_data(output, :filename => "test.pdf", :type => "application/pdf", :disposition => "attachment")
end

Response headers:

Content-Type: application/pdf
Set-Cookie: _session_id=7004a775cce4fb03fd3939b1452bbdd4; path=/
Content-Transfer-Encoding: binary
Pragma: no-cache
Cache-Control: no-cache, must-revalidate
Content-Length: 149287
Date: Fri, 14 Dec 2007 08:12:28 GMT
Server: LiteSpeed
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
 

mistwang

LiteSpeed Staff
#9
Have been fixed in 3.3.3 release, please download the new release by changing the version number, only linux packages are avaiable at this moment though.
 
Top