forked from jooby-project/jooby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNoByteRange.java
More file actions
50 lines (39 loc) · 1.06 KB
/
NoByteRange.java
File metadata and controls
50 lines (39 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Jooby https://jooby.io
* Apache License Version 2.0 https://jooby.io/LICENSE.txt
* Copyright 2014 Edgar Espina
*/
package io.jooby.internal;
import io.jooby.ByteRange;
import io.jooby.Context;
import io.jooby.StatusCode;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.io.InputStream;
public class NoByteRange implements ByteRange {
private long contentLength;
public NoByteRange(long contentLength) {
this.contentLength = contentLength;
}
@Override public long getStart() {
return 0;
}
@Override public long getEnd() {
return contentLength;
}
@Override public long getContentLength() {
return contentLength;
}
@Nonnull @Override public StatusCode getStatusCode() {
return StatusCode.OK;
}
@Nonnull @Override public String getContentRange() {
return "bytes */" + contentLength;
}
@Nonnull @Override public ByteRange apply(@Nonnull Context ctx) {
return this;
}
@Nonnull @Override public InputStream apply(@Nonnull InputStream input) throws IOException {
return input;
}
}