/**
* Hidden constructor.
@@ -338,14 +338,14 @@ public class PackageResource extends
AbstractResource implements IStaticCacheabl
byte[] bytes = null;
// send Content-Length header
- if (readPartially)
+ if (readBuffered)
{
-
resourceResponse.setContentLength(resourceStream.length().bytes());
+ bytes =
IOUtils.toByteArray(inputStream);
+
resourceResponse.setContentLength(new Long(bytes.length));
}
else
{
- bytes =
IOUtils.toByteArray(inputStream);
-
resourceResponse.setContentLength(new Long(bytes.length));
+
resourceResponse.setContentLength(resourceStream.length().bytes());
}
// get content range information
@@ -372,7 +372,7 @@ public class PackageResource extends AbstractResource
implements IStaticCacheabl
try
{
- if (!readPartially)
+ if (readBuffered)
{
IOUtils.close(resourceStream);
}
@@ -528,7 +528,7 @@ public class PackageResource extends AbstractResource
implements IStaticCacheabl
byte[] bytes = null;
InputStream inputStream = super.getInputStream();
- if (!readPartially)
+ if (readBuffered)
{
try
{
@@ -755,21 +755,21 @@ public class PackageResource extends
AbstractResource implements IStaticCacheabl
}
/**
- * If the packaage resource should be read partially.<br>
+ * If the package resource should be read buffered.<br>
* <br>
- * WARNING - if the stream is read partially compressors will not
work, because they require the
- * whole content to be read <br>
+ * WARNING - if the stream is not read buffered compressors will
not work, because they require the
+ * whole content to be read into memory.<br>
* ({@link org.apache.wicket.javascript.IJavaScriptCompressor},
<br>
* {@link org.apache.wicket.css.ICssCompressor}, <br>
* {@link
org.apache.wicket.resource.IScopeAwareTextResourceProcessor})
*
- * @param readPartially
- * if the package resource should be read partially
+ * @param readBuffered
+ * if the package resource should be read buffered
* @return the current package resource
*/
- public PackageResource readPartially(boolean readPartially)
+ public PackageResource readBuffered(boolean readBuffered)
{
- this.readPartially = readPartially;
+ this.readBuffered = readBuffered;
return this;
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/7a837f60/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java
----------------------------------------------------------------------
diff --git
a/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java
b/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java
index c4aa6be..22aaaed 100644
---
a/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java
+++
b/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResourceReference.java
@@ -47,9 +47,9 @@ public class PackageResourceReference extends
ResourceReference
private transient ConcurrentMap<UrlAttributes, UrlAttributes>
urlAttributesCacheMap;
/**
- * Reads the resource partially - the content is not copied into
memory
+ * Reads the resource buffered - the content is not copied into
memory
*/
- private boolean readPartially = false;
+ private boolean readBuffered = true;
/**
* Cache for existence of minified version of the resource to
avoid repetitive calls to
@@ -123,17 +123,17 @@ public class PackageResourceReference extends
ResourceReference
if (CSS_EXTENSION.equals(extension))
{
resource = new CssPackageResource(getScope(),
getName(), getLocale(), getStyle(),
-
getVariation()).readPartially(readPartially);
+ getVariation()).readBuffered(readBuffered);
}
else if (JAVASCRIPT_EXTENSION.equals(extension))
{
resource = new
JavaScriptPackageResource(getScope(), getName(), getLocale(),
- getStyle(),
getVariation()).readPartially(readPartially);
+ getStyle(),
getVariation()).readBuffered(readBuffered);
}
else
{
resource = new PackageResource(getScope(),
getName(), getLocale(), getStyle(),
-
getVariation()).readPartially(readPartially);
+ getVariation()).readBuffered(readBuffered);
}
removeCompressFlagIfUnnecessary(resource);
@@ -287,21 +287,21 @@ public class PackageResourceReference extends
ResourceReference
}
/**
- * If the packaage resource should be read partially.<br>
+ * If the package resource should be read buffered.<br>
* <br>
- * WARNING - if the stream is read partially compressors will not
work, because they require the
- * whole content to be read <br>
+ * WARNING - if the stream is not read buffered compressors will
not work, because they require the
+ * whole content to be read into memory.<br>
* ({@link org.apache.wicket.javascript.IJavaScriptCompressor},
<br>
* {@link org.apache.wicket.css.ICssCompressor}, <br>
* {@link
org.apache.wicket.resource.IScopeAwareTextResourceProcessor})
*
- * @param readPartially
- * if the package resource should be read partially
+ * @param readBuffered
+ * if the package resource should be read buffered
* @return the current package resource
*/
- public PackageResourceReference readPartially(boolean
readPartially)
+ public PackageResourceReference readBuffered(boolean readBuffered)
{
- this.readPartially = readPartially;
+ this.readBuffered = readBuffered;
return this;
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/7a837f60/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.java
----------------------------------------------------------------------
diff --git
a/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.java
b/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.java
index c1de448..d9892f6 100644
---
a/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.java
+++
b/wicket-examples/src/main/java/org/apache/wicket/examples/media/Home.java
@@ -50,7 +50,7 @@ public final class Home extends WicketExamplePage
// Internal video with several options
Video video1 = new Video("video1", new
PackageResourceReference(Home.class,
- "video1.mp4").readPartially(true));
+ "video1.mp4").readBuffered(false));
video1.setAutoplay(false);
video1.setControls(true);
video1.setLooping(false);
http://git-wip-us.apache.org/repos/asf/wicket/blob/7a837f60/wicket-user-guide/src/docs/guide/resources/resources_3.gdoc
----------------------------------------------------------------------
diff --git a/wicket-user-guide/src/docs/guide/resources/resources_3.gdoc
b/wicket-user-guide/src/docs/guide/resources/resources_3.gdoc
index 3344a08..7315892 100644
--- a/wicket-user-guide/src/docs/guide/resources/resources_3.gdoc
+++ b/wicket-user-guide/src/docs/guide/resources/resources_3.gdoc
@@ -129,7 +129,7 @@ h3. Media tags - resource references with content
range support
Since Wicket 7.0.0 the PackageResource and the PackageResourceReference
support "Range" HTTP header for the request and "Content-Range" /
"Accept-Range" HTTP headers for the response, which are used for videos /
audio tags. The "Range" header allows the client to only request a specific
byte range of the resource. The server provides the "Content-Range" and
tells the client which bytes are going to be send.
-If you want the resource not to be load into memory apply
readPartially(true). By using this flag the stream is written directly to
the response - @org.apache.wicket.resource.ITextResourceCompressor@ will
not be applied if the readPartially is set to true.
+If you want the resource not to be load into memory apply
readBuffered(false) - this way the stream is written directly to the
response. (@org.apache.wicket.resource.ITextResourceCompressor@ will not
be applied if readBuffered is set to false)
*HTML:*
{code:html}
@@ -141,7 +141,7 @@ If you want the resource not to be load into memory
apply readPartially(true). B
*Java Code:*
{code}
...
- Video video = new Video("video", new
PackageResourceReference(getClass(),"video.mp4").readPartially(true));
+ Video video = new Video("video", new
PackageResourceReference(getClass(),"video.mp4").readBuffered(false));
...
{code}