All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.soluble.pjb.servlet.VoidInputHttpServletRequest Maven / Gradle / Ivy

There is a newer version: 7.1.3
Show newest version
/**
 *
 */
package io.soluble.pjb.servlet;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

/**
 * A simple HTTP servlet request which is not connected to any input stream.
 *
 * @author jostb
 */
public class VoidInputHttpServletRequest extends HttpServletRequestWrapper {

    public VoidInputHttpServletRequest(HttpServletRequest req) {
        super(req);
    }

    private ServletInputStream in = null;

    public ServletInputStream getInputStream() {
        if (in != null) return in;
        return in = new ServletInputStream() {
            public int read() throws IOException {
                return -1;
            }
        };
    }

    private BufferedReader reader = null;

    public BufferedReader getReaader() {
        if (reader != null) return reader;
        return reader = new BufferedReader(new InputStreamReader(getInputStream()));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy