Naming file downloads (Content-Disposition??)

Discussion in 'Ruby/Rails' started by jpeduto, Dec 3, 2007.

  1. jpeduto

    jpeduto Member

    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?

  2. jpeduto

    jpeduto Member

    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 :)
  3. mistwang

    mistwang LiteSpeed Staff

    You can try add "Content-Disposition" header in Rails controller.
  4. jpeduto

    jpeduto Member

    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.
  5. mistwang

    mistwang LiteSpeed Staff

    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. jpeduto

    jpeduto Member

    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.
  7. mistwang

    mistwang LiteSpeed Staff

    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.
  8. zellster

    zellster Well-Known Member

    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 ="#{filename}")

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

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

    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
  9. mistwang

    mistwang LiteSpeed Staff

    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.
  10. zellster

    zellster Well-Known Member

    Things look good! Thank you for the quick turnaround.
  11. ffeingol

    ffeingol Well-Known Member

    This is also affecting PHP file downloads. We've reverted back to 3.3.1 until the release of 3.3.3.

  12. mistwang

    mistwang LiteSpeed Staff

    3.3.3 has been released.
  13. ffeingol

    ffeingol Well-Known Member

    Thnx. I just saw the announcement. I'll just give it a bit to hit the auto-download. A nice early xmas present :)

Share This Page