@ -129,7 +129,7 @@ public abstract class AbstractFileResolvingResource extends AbstractResource {
}
@Override
public int contentLength() throws IOException {
public long contentLength() throws IOException {
URL url = getURL();
if (ResourceUtils.isFileURL(url)) {
// Proceed with file system resolution...
@ -112,8 +112,8 @@ public abstract class AbstractResource implements Resource {
* if available.
* @see #getFile()
*/
return (int) getFile().length();
return getFile().length();
/**
@ -96,7 +96,7 @@ public interface Resource extends InputStreamSource {
* @throws IOException if the resource cannot be resolved
* (in the file system or as some other known physical resource type)
int contentLength() throws IOException;
long contentLength() throws IOException;
* Determine the last-modified timestamp for this resource.
@ -148,7 +148,11 @@ public class ResourceHttpRequestHandler extends WebContentGenerator implements H
if (mediaType != null) {
response.setContentType(mediaType.toString());
response.setContentLength(resource.contentLength());
long length = resource.contentLength();
if (length > Integer.MAX_VALUE) {
throw new IOException("Resource content too long (beyond Integer.MAX_VALUE): " + resource);
response.setContentLength((int) length);
FileCopyUtils.copy(resource.getInputStream(), response.getOutputStream());