From 1a785e4031e87a45001f7a7c46193a48873619df Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 24 Oct 2002 12:37:07 +0000 Subject: [PATCH] Implemented res.debug() method that appends debug messages to the response body. --- src/helma/framework/ResponseBean.java | 4 ++++ src/helma/framework/ResponseTrans.java | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/helma/framework/ResponseBean.java b/src/helma/framework/ResponseBean.java index 7b1a1996..ada43865 100644 --- a/src/helma/framework/ResponseBean.java +++ b/src/helma/framework/ResponseBean.java @@ -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]"; } diff --git a/src/helma/framework/ResponseTrans.java b/src/helma/framework/ResponseTrans.java index 6542fad9..b05d66c5 100644 --- a/src/helma/framework/ResponseTrans.java +++ b/src/helma/framework/ResponseTrans.java @@ -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 ("

"+str+"

"); } /** @@ -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) {