Uploaded image for project: 'TorqueBox'
  1. TorqueBox
  2. TORQUE-1240

X-Sendfile and Rails not working together

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 3.1.1
    • Fix Version/s: 3.1.2
    • Component/s: Rails
    • Labels:
      None
    • Environment:

      Ubuntu 14:04 64 bit
      Java 1.7.0_65
      TB 3.1.1
      JbossNative 2.0.9

      Description

      SETUP:

      Installed jboss native extensions and confirmed through adding debug statements in SendFileFilter that "native" is enabled. Also standalone.xml is configured with native = true

      CODE

      Rails code for serving file using Sendfile

      # Using Rails 4.1.5
      class DownloadsController < ApplicationController
       
        def download
          # ... Populate variables like path, disposition etc here
          
          response.header['X-Sendfile'] = path
          response.header['Content-Type'] = content_type
          response.header['disposition'] = 'inline' if disposition.present?
          render :nothing => true, :status => 200
        end
       
      end
      

      ISSUE

      Getting the following exception:

      16:08:31,832 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/].[torquebox.static]] (http-/172.17.0.3:8080-3) JBWEB000236: Servlet.service() for servlet torquebox.static threw exception: java.lang.IllegalStateException
      	at org.apache.catalina.connector.ResponseFacade.sendFile(ResponseFacade.java:432) [jbossweb-7.2.0.Final.jar:7.2.0.Final]
      	at org.torquebox.web.servlet.SendfileFilter.sendFile(SendfileFilter.java:108) [torquebox-web.jar:3.1.1]
      	at org.torquebox.web.servlet.SendfileFilter.doFilter(SendfileFilter.java:56) [torquebox-web.jar:3.1.1]
      	at org.torquebox.web.servlet.SendfileFilter.doFilter(SendfileFilter.java:33) [torquebox-web.jar:3.1.1]
      
      

      JAVA SOURCE CODE WHERE ABOVE IS FAILING (See isCommitted() is returning true)

       
       /* File: org.apache.catalina.connector.ResponseFacade.java */
       public void sendFile(String path, String absolutePath, long start, long end){
              if (isCommitted())
                  throw new IllegalStateException
                      (/*sm.getString("responseBase.reset.ise")*/);
       
              response.setAppCommitted(true);
       
              response.sendFile(path, absolutePath, start, end);
       
          }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                benbrowning Benjamin Browning
                Reporter:
                mahaswami Mahaswami Software
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: