chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1132921 - /chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java
Date Tue, 07 Jun 2011 09:31:28 GMT
Author: fmui
Date: Tue Jun  7 09:31:28 2011
New Revision: 1132921

URL: http://svn.apache.org/viewvc?rev=1132921&view=rev
Log:
allow XML error pages

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java?rev=1132921&r1=1132920&r2=1132921&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java
Tue Jun  7 09:31:28 2011
@@ -228,33 +228,36 @@ public class HttpUtils {
             // if there is an error page, get it
             if (errorStream != null) {
                 String contentType = getContentTypeHeader();
-                if ((contentType != null) && (contentType.toLowerCase().startsWith("text/")))
{
-                    StringBuilder sb = new StringBuilder();
+                if (contentType != null) {
+                    String contentTypeLower = contentType.toLowerCase().split(";")[0];
+                    if (contentTypeLower.startsWith("text/") || contentTypeLower.endsWith("+xml"))
{
+                        StringBuilder sb = new StringBuilder();
 
-                    try {
-                        String encoding = getContentEncoding();
-                        if (encoding != null) {
-                            if (encoding.toLowerCase().trim().equals("gzip")) {
-                                try {
-                                    errorStream = new GZIPInputStream(errorStream, 4096);
-                                } catch (IOException e) {
+                        try {
+                            String encoding = getContentEncoding();
+                            if (encoding != null) {
+                                if (encoding.toLowerCase().trim().equals("gzip")) {
+                                    try {
+                                        errorStream = new GZIPInputStream(errorStream, 4096);
+                                    } catch (IOException e) {
+                                    }
+                                } else if (encoding.toLowerCase().trim().equals("deflate"))
{
+                                    errorStream = new InflaterInputStream(errorStream, new
Inflater(true), 4096);
                                 }
-                            } else if (encoding.toLowerCase().trim().equals("deflate")) {
-                                errorStream = new InflaterInputStream(errorStream, new Inflater(true),
4096);
                             }
-                        }
 
-                        InputStreamReader reader = new InputStreamReader(errorStream);
-                        char[] buffer = new char[4096];
-                        int b;
-                        while ((b = reader.read(buffer)) > -1) {
-                            sb.append(buffer, 0, b);
-                        }
-                        reader.close();
+                            InputStreamReader reader = new InputStreamReader(errorStream);
+                            char[] buffer = new char[4096];
+                            int b;
+                            while ((b = reader.read(buffer)) > -1) {
+                                sb.append(buffer, 0, b);
+                            }
+                            reader.close();
 
-                        errorContent = sb.toString();
-                    } catch (IOException e) {
-                        errorContent = "Unable to retrieve content: " + e.getMessage();
+                            errorContent = sb.toString();
+                        } catch (IOException e) {
+                            errorContent = "Unable to retrieve content: " + e.getMessage();
+                        }
                     }
                 } else {
                     try {



Mime
View raw message