src/main/java/org/apache/sling/scripting/core/servlet/CaptureJakartaResponseWrapper.java [47:116]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        super(response);
    }

    /**
     * Returns true if the response is binary.
     *
     * @return true if the response is binary, false otherwise
     */
    public boolean isBinaryResponse() {
        return isBinaryResponse;
    }

    /*
     * (non-Javadoc)
     * @see javax.servlet.ServletResponseWrapper#flushBuffer()
     */
    @Override
    public void flushBuffer() throws IOException {
        if (isBinaryResponse()) {
            getResponse().getOutputStream().flush();
        } else {
            writer.flush();
        }
    }

    /*
     * (non-Javadoc)
     * @see javax.servlet.ServletResponseWrapper#getOutputStream()
     *
     * @return the output stream from the response
     */
    @Override
    public ServletOutputStream getOutputStream() throws IOException {
        if (writer != null) {
            throw new IOException("'getWriter()' has already been invoked for a character data response.");
        }
        isBinaryResponse = true;
        return getResponse().getOutputStream();
    }

    /*
     * (non-Javadoc)
     * @see javax.servlet.ServletResponseWrapper#getWriter()
     *
     * @return the writer
     */
    @Override
    public PrintWriter getWriter() throws IOException {
        if (writer != null) {
            return writer;
        }
        if (isBinaryResponse) {
            throw new IOException("'getOutputStream()' has already been invoked for a binary data response.");
        }
        stringWriter = new StringWriter();
        writer = new PrintWriter(stringWriter);
        return writer;
    }

    /**
     *
     * @return the captured character response data
     * @throws IOException if no character response data captured
     */
    public String getCapturedCharacterResponse() throws IOException {
        if (stringWriter == null) {
            throw new IOException("no character response data captured");
        }
        writer.flush();
        return stringWriter.toString();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



src/main/java/org/apache/sling/scripting/core/servlet/CaptureResponseWrapper.java [48:117]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        super(response);
    }

    /**
     * Returns true if the response is binary.
     *
     * @return true if the response is binary, false otherwise
     */
    public boolean isBinaryResponse() {
        return isBinaryResponse;
    }

    /*
     * (non-Javadoc)
     * @see javax.servlet.ServletResponseWrapper#flushBuffer()
     */
    @Override
    public void flushBuffer() throws IOException {
        if (isBinaryResponse()) {
            getResponse().getOutputStream().flush();
        } else {
            writer.flush();
        }
    }

    /*
     * (non-Javadoc)
     * @see javax.servlet.ServletResponseWrapper#getOutputStream()
     *
     * @return the output stream from the response
     */
    @Override
    public ServletOutputStream getOutputStream() throws IOException {
        if (writer != null) {
            throw new IOException("'getWriter()' has already been invoked for a character data response.");
        }
        isBinaryResponse = true;
        return getResponse().getOutputStream();
    }

    /*
     * (non-Javadoc)
     * @see javax.servlet.ServletResponseWrapper#getWriter()
     *
     * @return the writer
     */
    @Override
    public PrintWriter getWriter() throws IOException {
        if (writer != null) {
            return writer;
        }
        if (isBinaryResponse) {
            throw new IOException("'getOutputStream()' has already been invoked for a binary data response.");
        }
        stringWriter = new StringWriter();
        writer = new PrintWriter(stringWriter);
        return writer;
    }

    /**
     *
     * @return the captured character response data
     * @throws IOException if no character response data captured
     */
    public String getCapturedCharacterResponse() throws IOException {
        if (stringWriter == null) {
            throw new IOException("no character response data captured");
        }
        writer.flush();
        return stringWriter.toString();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



