You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2011/04/29 13:27:38 UTC

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

Author: fmui
Date: Fri Apr 29 11:27:38 2011
New Revision: 1097775

URL: http://svn.apache.org/viewvc?rev=1097775&view=rev
Log:
enable handling of compressed AND base64 encoded content

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=1097775&r1=1097774&r2=1097775&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 Fri Apr 29 11:27:38 2011
@@ -208,10 +208,10 @@ public class HttpUtils {
         private BigInteger length;
 
         public Response(int responseCode, String responseMessage, Map<String, List<String>> headers,
-                InputStream stream, InputStream errorStream) {
+                InputStream responseStream, InputStream errorStream) {
             this.responseCode = responseCode;
             this.responseMessage = responseMessage;
-            this.stream = stream;
+            stream = responseStream;
 
             this.headers = new HashMap<String, List<String>>();
             if (headers != null) {
@@ -258,9 +258,9 @@ public class HttpUtils {
                     }
                 }
 
-                if (stream != null) {
+                if (responseStream != null) {
                     try {
-                        stream.close();
+                        responseStream.close();
                     } catch (IOException e) {
                     }
                 }
@@ -284,26 +284,28 @@ public class HttpUtils {
                         // if the stream is gzip encoded, decode it
                         length = null;
                         try {
-                            this.stream = new GZIPInputStream(stream, 4096);
+                            stream = new GZIPInputStream(stream, 4096);
                         } catch (IOException e) {
                             errorContent = e.getMessage();
+                            stream = null;
                             try {
-                                stream.close();
+                                responseStream.close();
                             } catch (IOException ec) {
                             }
                         }
                     } else if (encoding.toLowerCase().trim().equals("deflate")) {
                         // if the stream is deflate encoded, decode it
                         length = null;
-                        this.stream = new InflaterInputStream(stream, new Inflater(true), 4096);
+                        stream = new InflaterInputStream(stream, new Inflater(true), 4096);
                     }
                 }
 
                 String transferEncoding = getContentTransferEncoding();
-                if ((transferEncoding != null) && (transferEncoding.toLowerCase().trim().equals("base64"))) {
+                if ((stream != null) && (transferEncoding != null)
+                        && (transferEncoding.toLowerCase().trim().equals("base64"))) {
                     // if the stream is base64 encoded, decode it
                     length = null;
-                    this.stream = new Base64.InputStream(stream);
+                    stream = new Base64.InputStream(stream);
                 }
             }
         }