1. opensymphony
  2. webwork

Commits

mbogaert  committed 0711094

Fixed WW-696: StreamResult should accept file option. Just added support for the Content-Disposition header, setting a file is outside the scope for this class IMO.

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@636573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits fd05974
  • Branches master

Comments (0)

Files changed (1)

File src/java/com/opensymphony/webwork/dispatcher/StreamResult.java

View file
  • Ignore whitespace
  * </result>
  * <p/>
  * contentType = the stream mime-type as sent to the web browser
+ * contentDispostion = (optional) the content disposition header value (for sending files)
  * inputName = the name of the InputStream property from the chained action (default = "inputStream")
  * bufferSize = the size of the buffer to copy from input to output (defaul = 1024)
  *
  * @author mcrawford
  */
 public class StreamResult extends WebWorkResultSupport {
-
     protected String contentType = "text/plain";
-
+    protected String contentDisposition;
     protected String inputName = "inputStream";
-
     protected int bufferSize = 1024;
 
     /**
     }
 
     /**
+     * @return Returns the Content-Disposition header value.
+     */
+    public String getContentDisposition() {
+        return contentDisposition;
+    }
+
+    /**
+     * @param contentDisposition the Content-Disposition header value to use.
+     */
+    public void setContentDisposition(String contentDisposition) {
+        this.contentDisposition = contentDisposition;
+    }
+
+    /**
      * @return Returns the inputName.
      */
     public String getInputName() {
         // Set the content type
         oResponse.setContentType(contentType);
 
+        // Set the content-disposition
+        if (contentDisposition != null) {
+            oResponse.addHeader("Content-Disposition", contentDisposition);
+        }
+
         // Get the outputstream
         OutputStream oOutput = oResponse.getOutputStream();