cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject 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.
Date Thu, 20 Feb 2014 19:21:06 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 0cb9b8831 -> 6dd839afb


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/6dd839af
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/6dd839af
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/6dd839af

Branch: refs/heads/2.7.x-fixes
Commit: 6dd839afbb4d834ed668738bd89e7775c1cf2f9d
Parents: 0cb9b88
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Feb 19 12:17:50 2014 -0500
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Thu Feb 20 14:16:25 2014 -0500

----------------------------------------------------------------------
 .../cxf/interceptor/StaxInInterceptor.java       | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6dd839af/api/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java b/api/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
index 442071f..9bb2a52 100644
--- a/api/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
+++ b/api/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)"));


Mime
View raw message