Mercurial Hosting > nabble
diff src/cachingfilter/BufferInputStream.java @ 0:7ecd1a4ef557
add content
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 21 Mar 2019 19:15:52 -0600 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cachingfilter/BufferInputStream.java Thu Mar 21 19:15:52 2019 -0600 @@ -0,0 +1,41 @@ +package cachingfilter; + +import java.io.InputStream; +import org.eclipse.jetty.io.Buffer; + + +public final class BufferInputStream extends InputStream { + private final Buffer buffer; + + public BufferInputStream(Buffer buffer) { + this.buffer = buffer; + } + + public int read() { + return buffer.length()==0 ? -1 : buffer.get(); + } + + public int read(byte b[], int off, int len) { + return buffer.get(b,off,len); + } + + public long skip(long n) { + return buffer.skip( (int)n ); + } + + public int available() { + return buffer.length(); + } + + public void mark(int readlimit) { + buffer.mark(); + } + + public void reset() { + buffer.reset(); + } + + public boolean markSupported() { + return true; + } +}