001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.net.http;
020
021import java.io.ByteArrayInputStream;
022import java.io.IOException;
023import java.io.InputStream;
024
025import javax.servlet.ServletInputStream;
026
027/**
028 * implementation of <code>ServletInputStream</code>.
029 */
030public final class ServletInputStreamDummy extends ServletInputStream
031{
032    private InputStream stream;
033    
034    /**
035     * @param data
036     */
037    public ServletInputStreamDummy(byte[] data) {
038        stream = new ByteArrayInputStream(data);
039    }
040    
041    /**
042     * @param barr
043     */
044    public ServletInputStreamDummy(InputStream is) {
045        stream = is;
046    }
047        
048    @Override
049    public int read() throws IOException {
050        return stream.read();
051    }
052
053        @Override
054        public int readLine(byte[] barr, int arg1, int arg2) throws IOException {
055                return stream.read(barr, arg1, arg2);
056        }
057
058        @Override
059        public int available() throws IOException {
060                return stream.available();
061        }
062
063        @Override
064        public void close() throws IOException {
065                stream.close();
066        }
067
068        @Override
069        public synchronized void mark(int readlimit) {
070                stream.mark(readlimit);
071        }
072
073        @Override
074        public boolean markSupported() {
075                return stream.markSupported();
076        }
077
078        @Override
079        public int read(byte[] b, int off, int len) throws IOException {
080                return stream.read(b, off, len);
081        }
082
083        @Override
084        public int read(byte[] b) throws IOException {
085                return stream.read(b);
086        }
087
088        @Override
089        public synchronized void reset() throws IOException {
090                stream.reset();
091        }
092
093        @Override
094        public long skip(long n) throws IOException {
095                return stream.skip(n);
096        }
097}