Skip to content
Permalink
Browse files
Update StaxInInterceptor to just create a html error message on the c…
…lient side as the normal error handling works best on server side.
  • Loading branch information
dkulp committed Feb 19, 2014
1 parent 3158ccb commit f8ed98e684c1a67a77ae8726db05a04a4978a445
Showing 1 changed file with 15 additions and 4 deletions.
@@ -21,6 +21,7 @@

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.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 void handleMessage(Message 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)"));

0 comments on commit f8ed98e

Please sign in to comment.