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.
master
Peter Marheine 5 years ago
parent 16fb6d6134
commit 5077e0d5e1
  1. 3
      airsonic-main/src/main/java/org/airsonic/player/io/RangeOutputStream.java

@ -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);

Loading…
Cancel
Save