File tree 2 files changed +8
-4
lines changed
spring-web/src/main/java/org/springframework/http/converter
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2015 the original author or authors.
2
+ * Copyright 2002-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -217,7 +217,7 @@ else if (MediaType.APPLICATION_OCTET_STREAM.equals(contentType)) {
217
217
headers .setContentType (contentTypeToUse );
218
218
}
219
219
}
220
- if (headers .getContentLength () == - 1 ) {
220
+ if (headers .getContentLength () < 0 ) {
221
221
Long contentLength = getContentLength (t , headers .getContentType ());
222
222
if (contentLength != null ) {
223
223
headers .setContentLength (contentLength );
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2015 the original author or authors.
2
+ * Copyright 2002-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -90,7 +90,11 @@ protected MediaType getDefaultContentType(Resource resource) {
90
90
protected Long getContentLength (Resource resource , MediaType contentType ) throws IOException {
91
91
// Don't try to determine contentLength on InputStreamResource - cannot be read afterwards...
92
92
// Note: custom InputStreamResource subclasses could provide a pre-calculated content length!
93
- return (InputStreamResource .class == resource .getClass () ? null : resource .contentLength ());
93
+ if (InputStreamResource .class == resource .getClass ()) {
94
+ return null ;
95
+ }
96
+ long contentLength = resource .contentLength ();
97
+ return (contentLength < 0 ? null : contentLength );
94
98
}
95
99
96
100
@ Override
You can’t perform that action at this time.
0 commit comments