changed contentLength() from int to long
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3550 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
1e389ddcc7
commit
385b21fc27
|
|
@ -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()
|
||||
*/
|
||||
public int contentLength() throws IOException {
|
||||
return (int) getFile().length();
|
||||
public long contentLength() throws IOException {
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue