Implemented res.debug() method that appends debug messages to the response body.
This commit is contained in:
parent
afbdf485ba
commit
1a785e4031
2 changed files with 13 additions and 3 deletions
|
@ -62,6 +62,10 @@ public class ResponseBean implements Serializable {
|
|||
res.writeBinary (what);
|
||||
}
|
||||
|
||||
public void debug (String message) {
|
||||
res.debug (message);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "[Response]";
|
||||
}
|
||||
|
|
|
@ -71,6 +71,9 @@ public final class ResponseTrans implements Externalizable {
|
|||
private transient Object[] skinpath = null;
|
||||
// hashmap for skin caching
|
||||
private transient HashMap skincache;
|
||||
|
||||
// buffer for debug messages - will be automatically appended to response
|
||||
private transient StringBuffer debugBuffer;
|
||||
|
||||
static final long serialVersionUID = -8627370766119740844L;
|
||||
|
||||
|
@ -208,9 +211,10 @@ public final class ResponseTrans implements Externalizable {
|
|||
* that buffer exists and its length is larger than offset. str may be null, in which
|
||||
* case nothing happens.
|
||||
*/
|
||||
public void insert (int offset, String str) {
|
||||
if (str != null)
|
||||
buffer.insert (offset, str);
|
||||
public void debug (String str) {
|
||||
if (debugBuffer == null)
|
||||
debugBuffer = new StringBuffer ();
|
||||
debugBuffer.append ("<p><span style=\"background: yellow; color: black\">"+str+"</span></p>");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,6 +312,8 @@ public final class ResponseTrans implements Externalizable {
|
|||
boolean error = false;
|
||||
if (response == null) {
|
||||
if (buffer != null) {
|
||||
if (debugBuffer != null)
|
||||
buffer.append (debugBuffer);
|
||||
try {
|
||||
response = buffer.toString ().getBytes (charset);
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
|
|
Loading…
Add table
Reference in a new issue