public Response(int outputBufferSize) { outputBuffer = new OutputBuffer(outputBufferSize); }
@Override public void close() { // We don't close the PrintWriter - super() is not called, // so the stream can be reused. We close ob. try { ob.close(); } catch (IOException ex ) { // Ignore } error = false; }
@Override public void flush() { if (error) { return; } try { ob.flush(); } catch (IOException e) { error = true; } }
/** * Set the buffer size to be used for this Response. * * @param size The new buffer size * * @exception IllegalStateException if this method is called after * output has been committed for this response */ public void setBufferSize(int size) { if (isCommitted() || !outputBuffer.isNew()) throw new IllegalStateException(rb.getString(LogFacade.CANNOT_CHANGE_BUFFER_SIZE_EXCEPTION)); outputBuffer.setBufferSize(size); }
/* */ public PrintWriter getReporter() /* */ throws IOException /* */ { /* 520 */ if (this.outputBuffer.isNew()) { /* 521 */ this.outputBuffer.checkConverter(); /* 522 */ if (this.writer == null) { /* 523 */ this.writer = new CoyoteWriter(this.outputBuffer); /* */ } /* 525 */ return this.writer; /* */ } /* 527 */ return null; /* */ } /* */
/** * @return the actual buffer size used for this Response. */ @Override public int getBufferSize() { return outputBuffer.getBufferSize(); }
/** * Suspended flag accessor. * * @return <code>true</code> if the response is suspended */ public boolean isSuspended() { return outputBuffer.isSuspended(); }
/** * @return the number of bytes the application has actually written to the * output stream. This excludes chunking, compression, etc. as well as * headers. */ public long getContentWritten() { return outputBuffer.getContentWritten(); }
public void reset() { reset(false); }
/** * Release all object references, and initialize instance variables, in * preparation for reuse of this object. */ public void recycle() { cookies.clear(); outputBuffer.recycle(); usingOutputStream = false; usingWriter = false; appCommitted = false; included = false; isCharacterEncodingSet = false; applicationResponse = null; if (Globals.IS_SECURITY_ENABLED || Connector.RECYCLE_FACADES) { if (facade != null) { facade.clear(); facade = null; } if (outputStream != null) { outputStream.clear(); outputStream = null; } if (writer != null) { writer.clear(); writer = null; } } else if (writer != null) { writer.recycle(); } }
/* */ public PrintWriter getWriter() /* */ throws IOException /* */ { /* 603 */ if (this.usingOutputStream) { /* 604 */ throw new IllegalStateException(sm.getString("coyoteResponse.getWriter.ise")); /* */ } /* */ /* 607 */ if (Globals.STRICT_SERVLET_COMPLIANCE) /* */ { /* 620 */ setCharacterEncoding(getCharacterEncoding()); /* */ } /* */ /* 623 */ this.usingWriter = true; /* 624 */ this.outputBuffer.checkConverter(); /* 625 */ if (this.writer == null) { /* 626 */ this.writer = new CoyoteWriter(this.outputBuffer); /* */ } /* 628 */ return this.writer; /* */ } /* */
/* */ public void setBufferSize(int size) /* */ { /* 684 */ if ((isCommitted()) || (!this.outputBuffer.isNew())) { /* 685 */ throw new IllegalStateException(sm.getString("coyoteResponse.setBufferSize.ise")); /* */ } /* */ /* 688 */ this.outputBuffer.setBufferSize(size); /* */ } /* */
/** * Return a PrintWriter that can be used to render error messages, * regardless of whether a stream or writer has already been acquired. * * @return Writer which can be used for error reports. If the response is * not an error report returned using sendError or triggered by an * unexpected exception thrown during the servlet processing * (and only in that case), null will be returned if the response stream * has already been used. * * @exception IOException if an input/output error occurs */ public PrintWriter getReporter() throws IOException { if (outputBuffer.isNew()) { outputBuffer.checkConverter(); if (writer == null) { writer = new CoyoteWriter(outputBuffer); } return writer; } else { return null; } }
/** * Return the actual buffer size used for this Response. */ public int getBufferSize() { return outputBuffer.getBufferSize(); }
/** * Suspended flag accessor. * * @return <code>true</code> if the response is suspended */ public boolean isSuspended() { return outputBuffer.isSuspended(); }
/** * Return the number of bytes the application has actually written to the * output stream. This excludes chunking, compression, etc. as well as * headers. */ public long getContentWritten() { return outputBuffer.getContentWritten(); }
public void reset() { reset(false); }
outputBuffer.recycle(); usingOutputStream = false; usingWriter = false;
/** * Set the buffer size to be used for this Response. * * @param size The new buffer size * * @exception IllegalStateException if this method is called after * output has been committed for this response */ public void setBufferSize(int size) { if (isCommitted() || !outputBuffer.isNew()) throw MESSAGES.cannotChangeBufferSize(); outputBuffer.setBufferSize(size); }
/** * Return a PrintWriter that can be used to render error messages, * regardless of whether a stream or writer has already been acquired. * * @return Writer which can be used for error reports. If the response is * not an error report returned using sendError or triggered by an * unexpected exception thrown during the servlet processing * (and only in that case), null will be returned if the response stream * has already been used. * * @exception IOException if an input/output error occurs */ public PrintWriter getReporter() throws IOException { if (outputBuffer.isNew()) { outputBuffer.checkConverter(); if (writer == null) { writer = new CoyoteWriter(outputBuffer); } return writer; } else { return null; } }