Methods Summary |
---|
public void | acknowledge()
action(ActionCode.ACTION_ACK, this);
|
public void | action(ActionCode actionCode, java.lang.Object param)
if (hook != null) {
if( param==null )
hook.action(actionCode, this);
else
hook.action(actionCode, param);
}
|
public void | addHeader(java.lang.String name, java.lang.String value)
char cc=name.charAt(0);
if( cc=='C" || cc=='c" ) {
if( checkSpecialHeader(name, value) )
return;
}
headers.addValue(name).setString( value );
|
private boolean | checkSpecialHeader(java.lang.String name, java.lang.String value)Set internal fields for special header names.
Called from set/addHeader.
Return true if the header is special, no need to set the header.
// XXX Eliminate redundant fields !!!
// ( both header and in special fields )
if( name.equalsIgnoreCase( "Content-Type" ) ) {
setContentType( value );
return true;
}
if( name.equalsIgnoreCase( "Content-Length" ) ) {
try {
long cL=Long.parseLong( value );
setContentLength( cL );
return true;
} catch( NumberFormatException ex ) {
// Do nothing - the spec doesn't have any "throws"
// and the user might know what he's doing
return false;
}
}
if( name.equalsIgnoreCase( "Content-Language" ) ) {
// XXX XXX Need to construct Locale or something else
}
return false;
|
public boolean | containsHeader(java.lang.String name)Warning: This method always returns false for Content-Type
and Content-Length.
return headers.getHeader(name) != null;
|
public void | doWrite(org.apache.tomcat.util.buf.ByteChunk chunk)Write a chunk of bytes.
outputBuffer.doWrite(chunk, this);
bytesWritten+=chunk.getLength();
|
public void | finish()
action(ActionCode.ACTION_CLOSE, this);
|
public long | getBytesWritten()
return bytesWritten;
|
public java.lang.String | getCharacterEncoding()
return characterEncoding;
|
public java.lang.String | getContentLanguage()Return the content language.
return contentLanguage;
|
public int | getContentLength()
long length = getContentLengthLong();
if (length < Integer.MAX_VALUE) {
return (int) length;
}
return -1;
|
public long | getContentLengthLong()
return contentLength;
|
public java.lang.String | getContentType()
String ret = contentType;
if (ret != null
&& characterEncoding != null
&& charsetSet) {
ret = ret + ";charset=" + characterEncoding;
}
return ret;
|
public java.lang.Exception | getErrorException()Get the Exception that occurred during request
processing.
return errorException;
|
public java.lang.String | getErrorURI()Get the request URI that caused the original error.
return errorURI;
|
public ActionHook | getHook()
return hook;
|
public java.util.Locale | getLocale()
return locale;
|
public java.lang.String | getMessage()Get the status message.
return message;
|
public org.apache.tomcat.util.http.MimeHeaders | getMimeHeaders()
return headers;
|
public final java.lang.Object | getNote(int pos)
return notes[pos];
|
public OutputBuffer | getOutputBuffer()
return outputBuffer;
|
public Request | getRequest()
// ------------------------------------------------------------- Properties
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()
// 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()Signal that we're done with the headers, and body will follow.
Any implementation needs to notify ContextManager, to allow
interceptors to fix headers.
action(ActionCode.ACTION_COMMIT, this);
commited = true;
|
public void | setBytesWritten(long bytesWritten)
this.bytesWritten = bytesWritten;
|
public void | setCharacterEncoding(java.lang.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(java.lang.String type)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().
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();
}
|
public void | setErrorException(java.lang.Exception ex)Set the error Exception that occurred during
request processing.
errorException = ex;
|
public void | setErrorURI(java.lang.String uri)Set request URI that caused an error during
request processing.
errorURI = uri;
|
public void | setHeader(java.lang.String name, java.lang.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(java.util.Locale locale)Called explicitely by user to set the Content-Language and
the default encoding
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();
}
|
public void | setMessage(java.lang.String message)Set the status message.
this.message = message;
|
public final void | setNote(int pos, java.lang.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)Set the response status
this.status = status;
|