Author: mgrigorov
Date: Tue May 10 07:52:04 2011
New Revision: 1101354

URL: http://svn.apache.org/viewvc?rev=1101354&view=rev
Log:
WICKET-3693 Enhance ByteArrayResource for dynamic byte arrays

Set Content-Length header.
Chain the constructors.
Drop a unused constructor - the Locale parameter wasn't even stored.


Modified:
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/ByteArrayResource.java

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/ByteArrayResource.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/ByteArrayResource.java?rev=1101354&r1=1101353&r2=1101354&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/ByteArrayResource.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/ByteArrayResource.java
 Tue May 10 07:52:04 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.wicket.request.resource;
 
-import java.util.Locale;
-
 import org.apache.wicket.util.time.Time;
 
 /**
@@ -48,9 +46,7 @@ public class ByteArrayResource extends A
         */
        public ByteArrayResource(final String contentType, final byte[] array)
        {
-               this.contentType = contentType;
-               this.array = array;
-               filename = null;
+               this(contentType, array, null);
        }
 
        /**
@@ -70,24 +66,6 @@ public class ByteArrayResource extends A
                this.filename = filename;
        }
 
-       /**
-        * Creates a Resource from the given byte array with its content type 
and the locale for which
-        * it is valid.
-        * 
-        * @param contentType
-        *            The Content type of the array.
-        * @param array
-        *            The binary content.
-        * @param locale
-        *            The locale of this resource
-        */
-       public ByteArrayResource(final String contentType, final byte[] array, 
final Locale locale)
-       {
-               this.contentType = contentType;
-               this.array = array;
-               filename = null;
-       }
-
        protected void configureResponse(final ResourceResponse response, final 
Attributes attributes)
        {
        }
@@ -102,6 +80,7 @@ public class ByteArrayResource extends A
 
                response.setContentType(contentType);
                response.setLastModified(lastModified);
+               response.setContentLength(array.length);
 
                if (response.dataNeedsToBeWritten(attributes))
                {


Reply via email to