Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8913D6C68 for ; Tue, 7 Jun 2011 09:31:50 +0000 (UTC) Received: (qmail 73397 invoked by uid 500); 7 Jun 2011 09:31:50 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 73355 invoked by uid 500); 7 Jun 2011 09:31:50 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 73347 invoked by uid 99); 7 Jun 2011 09:31:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Jun 2011 09:31:50 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Jun 2011 09:31:49 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 076BC2388A33; Tue, 7 Jun 2011 09:31:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@chemistry.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110607093129.076BC2388A33@eris.apache.org> 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 {