Method from org.apache.coyote.Response Detail: |
public void acknowledge() throws IOException {
action(ActionCode.ACTION_ACK, this);
}
|
public void action(ActionCode actionCode,
Object param) {
if (hook != null) {
if( param==null )
hook.action(actionCode, this);
else
hook.action(actionCode, param);
}
}
|
public void addHeader(String name,
String value) {
char cc=name.charAt(0);
if( cc=='C' || cc=='c' ) {
if( checkSpecialHeader(name, value) )
return;
}
headers.addValue(name).setString( value );
}
|
public boolean containsHeader(String name) {
return headers.getHeader(name) != null;
}
Warning: This method always returns false for Content-Type
and Content-Length. |
public void doWrite(ByteChunk chunk) throws IOException {
outputBuffer.doWrite(chunk, this);
bytesWritten+=chunk.getLength();
}
|
public void finish() throws IOException {
action(ActionCode.ACTION_CLOSE, this);
}
|
public long getBytesWritten() {
return bytesWritten;
}
|
public String getCharacterEncoding() {
return characterEncoding;
}
|
public String getContentLanguage() {
return contentLanguage;
}
Return the content language. |
public int getContentLength() {
long length = getContentLengthLong();
if (length < Integer.MAX_VALUE) {
return (int) length;
}
return -1;
}
|
public long getContentLengthLong() {
return contentLength;
}
|
public String getContentType() {
String ret = contentType;
if (ret != null
&& characterEncoding != null
&& charsetSet) {
ret = ret + ";charset=" + characterEncoding;
}
return ret;
}
|
public Exception getErrorException() {
return errorException;
}
Get the Exception that occurred during request
processing. |
public String getErrorURI() {
return errorURI;
}
Get the request URI that caused the original error. |
public ActionHook getHook() {
return hook;
}
|
public Locale getLocale() {
return locale;
}
|
public String getMessage() {
return message;
}
|
public MimeHeaders getMimeHeaders() {
return headers;
}
|
public final Object getNote(int pos) {
return notes[pos];
}
|
public OutputBuffer getOutputBuffer() {
return outputBuffer;
}
|
public Request getRequest() {
return req;
}
|
public int getStatus() {
return status;
}
|
public boolean isCommitted() {
return commited;
}
|
public boolean isExceptionPresent() {
return ( errorException != null );
}
|
public void recycle() {
contentType = null;
contentLanguage = null;
locale = DEFAULT_LOCALE;
characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING;
charsetSet = false;
contentLength = -1;
status = 200;
message = null;
commited = false;
errorException = null;
errorURI = null;
headers.clear();
// update counters
bytesWritten=0;
}
|
public void reset() throws IllegalStateException {
// Reset the headers only if this is the main request,
// not for included
contentType = null;
locale = DEFAULT_LOCALE;
contentLanguage = null;
characterEncoding = Constants.DEFAULT_CHARACTER_ENCODING;
contentLength = -1;
charsetSet = false;
status = 200;
message = null;
headers.clear();
// Force the PrintWriter to flush its data to the output
// stream before resetting the output stream
//
// Reset the stream
if (commited) {
//String msg = sm.getString("servletOutputStreamImpl.reset.ise");
throw new IllegalStateException();
}
action(ActionCode.ACTION_RESET, this);
}
|
public void sendHeaders() throws IOException {
action(ActionCode.ACTION_COMMIT, this);
commited = true;
}
Signal that we're done with the headers, and body will follow.
Any implementation needs to notify ContextManager, to allow
interceptors to fix headers. |
public void setBytesWritten(long bytesWritten) {
this.bytesWritten = bytesWritten;
}
|
public void setCharacterEncoding(String charset) {
if (isCommitted())
return;
if (charset == null)
return;
characterEncoding = charset;
charsetSet=true;
}
|
public void setCommitted(boolean v) {
this.commited = v;
}
|
public void setContentLength(int contentLength) {
this.contentLength = contentLength;
}
|
public void setContentLength(long contentLength) {
this.contentLength = contentLength;
}
|
public void setContentType(String type) {
int semicolonIndex = -1;
if (type == null) {
this.contentType = null;
return;
}
/*
* Remove the charset param (if any) from the Content-Type, and use it
* to set the response encoding.
* The most recent response encoding setting will be appended to the
* response's Content-Type (as its charset param) by getContentType();
*/
boolean hasCharset = false;
int len = type.length();
int index = type.indexOf(';');
while (index != -1) {
semicolonIndex = index;
index++;
while (index < len && Character.isSpace(type.charAt(index))) {
index++;
}
if (index+8 < len
&& type.charAt(index) == 'c'
&& type.charAt(index+1) == 'h'
&& type.charAt(index+2) == 'a'
&& type.charAt(index+3) == 'r'
&& type.charAt(index+4) == 's'
&& type.charAt(index+5) == 'e'
&& type.charAt(index+6) == 't'
&& type.charAt(index+7) == '=') {
hasCharset = true;
break;
}
index = type.indexOf(';', index);
}
if (!hasCharset) {
this.contentType = type;
return;
}
this.contentType = type.substring(0, semicolonIndex);
String tail = type.substring(index+8);
int nextParam = tail.indexOf(';');
String charsetValue = null;
if (nextParam != -1) {
this.contentType += tail.substring(nextParam);
charsetValue = tail.substring(0, nextParam);
} else {
charsetValue = tail;
}
// The charset value may be quoted, but must not contain any quotes.
if (charsetValue != null && charsetValue.length() > 0) {
charsetSet=true;
charsetValue = charsetValue.replace('"', ' ');
this.characterEncoding = charsetValue.trim();
}
}
Sets the content type.
This method must preserve any response charset that may already have
been set via a call to response.setContentType(), response.setLocale(),
or response.setCharacterEncoding(). |
public void setErrorException(Exception ex) {
errorException = ex;
}
Set the error Exception that occurred during
request processing. |
public void setErrorURI(String uri) {
errorURI = uri;
}
Set request URI that caused an error during
request processing. |
public void setHeader(String name,
String value) {
char cc=name.charAt(0);
if( cc=='C' || cc=='c' ) {
if( checkSpecialHeader(name, value) )
return;
}
headers.setValue(name).setString( value);
}
|
public void setHook(ActionHook hook) {
this.hook = hook;
}
|
public void setLocale(Locale locale) {
if (locale == null) {
return; // throw an exception?
}
// Save the locale for use by getLocale()
this.locale = locale;
// Set the contentLanguage for header output
contentLanguage = locale.getLanguage();
if ((contentLanguage != null) && (contentLanguage.length() > 0)) {
String country = locale.getCountry();
StringBuffer value = new StringBuffer(contentLanguage);
if ((country != null) && (country.length() > 0)) {
value.append('-');
value.append(country);
}
contentLanguage = value.toString();
}
}
Called explicitely by user to set the Content-Language and
the default encoding |
public void setMessage(String message) {
this.message = message;
}
|
public final void setNote(int pos,
Object value) {
notes[pos] = value;
}
|
public void setOutputBuffer(OutputBuffer outputBuffer) {
this.outputBuffer = outputBuffer;
}
|
public void setRequest(Request req) {
this.req=req;
}
|
public void setStatus(int status) {
this.status = status;
}
|