Short circuit RangeOutputStream for open ranges
There's no reason to wrap a stream in an output that will do nothing, as when the requested range is 0-; eg the entire stream.
This commit is contained in:
@@ -55,7 +55,8 @@ public class RangeOutputStream extends FilterOutputStream {
|
||||
* @return The possibly wrapped output stream.
|
||||
*/
|
||||
public static OutputStream wrap(OutputStream out, HttpRange range) {
|
||||
if (range == null) {
|
||||
// Skip filtering if there's no range or it represents the entire stream.
|
||||
if (range == null || (range.getFirstBytePos() == 0 && !range.isClosed())) {
|
||||
return out;
|
||||
}
|
||||
return new RangeOutputStream(out, range);
|
||||
|
||||
Reference in New Issue
Block a user