You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2014/02/19 18:18:53 UTC
[2/2] git commit: Update StaxInInterceptor to just create a html
error message on the client side as the normal error handling works best on
server side.
Update StaxInInterceptor to just create a html error message on the client side as the normal error handling works best on server side.
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f8ed98e6
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f8ed98e6
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f8ed98e6
Branch: refs/heads/master
Commit: f8ed98e684c1a67a77ae8726db05a04a4978a445
Parents: 3158ccb
Author: Daniel Kulp <dk...@apache.org>
Authored: Wed Feb 19 12:17:50 2014 -0500
Committer: Daniel Kulp <dk...@apache.org>
Committed: Wed Feb 19 12:17:50 2014 -0500
----------------------------------------------------------------------
.../cxf/interceptor/StaxInInterceptor.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/f8ed98e6/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
index 442071f..9bb2a52 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
@@ -21,6 +21,7 @@ package org.apache.cxf.interceptor;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.Reader;
import java.util.HashMap;
import java.util.List;
@@ -36,8 +37,8 @@ import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.HttpHeaderHelper;
-import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
import org.apache.cxf.staxutils.StaxUtils;
@@ -73,10 +74,20 @@ public class StaxInInterceptor extends AbstractPhaseInterceptor<Message> {
}
String contentType = (String)message.get(Message.CONTENT_TYPE);
- if (contentType != null && contentType.contains("text/html")) {
- String htmlMessage = null;
+ if (contentType != null
+ && contentType.contains("text/html")
+ && MessageUtils.isRequestor(message)) {
+ StringBuilder htmlMessage = new StringBuilder(1024);
try {
- htmlMessage = IOUtils.toString(is, 500);
+ if (reader == null) {
+ reader = new InputStreamReader(is, (String)message.get(Message.ENCODING));
+ }
+ char s[] = new char[1024];
+ int i = reader.read(s);
+ while (htmlMessage.length() < 64536 && i > 0) {
+ htmlMessage.append(s, 0, i);
+ i = reader.read(s);
+ }
} catch (IOException e) {
throw new Fault(new org.apache.cxf.common.i18n.Message("INVALID_HTML_RESPONSETYPE",
LOG, "(none)"));