You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/05/28 10:58:14 UTC

svn commit: r779489 - in /camel/trunk/components: camel-http/src/main/java/org/apache/camel/component/http/ camel-http/src/main/java/org/apache/camel/component/http/helper/ camel-http/src/test/java/org/apache/camel/component/http/ camel-jetty/src/test/...

Author: davsclaus
Date: Thu May 28 08:58:14 2009
New Revision: 779489

URL: http://svn.apache.org/viewvc?rev=779489&view=rev
Log:
CAMEL-1651: Fixed gzip content encoding only being applied if really needed. Polished the code as well.

Removed:
    camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/GZIPHelperTest.java
Modified:
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConstants.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/RequestEntityConverter.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/GZIPHelper.java
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/LoadingByteArrayOutputStream.java
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyImageFileTest.java

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java?rev=779489&r1=779488&r2=779489&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java (original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java Thu May 28 08:58:14 2009
@@ -22,16 +22,19 @@
 import java.io.PrintWriter;
 import java.util.Enumeration;
 import java.util.Map;
-
+import java.util.zip.GZIPOutputStream;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.Message;
 import org.apache.camel.component.http.helper.GZIPHelper;
 import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.MessageHelper;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * Binding between {@link HttpMessage} and {@link HttpServletResponse}.
@@ -90,7 +93,6 @@
         headers.put(Exchange.HTTP_PATH, request.getPathInfo());
         headers.put(Exchange.CONTENT_TYPE, request.getContentType());
         headers.put(Exchange.HTTP_CHARACTER_ENCODING, request.getCharacterEncoding());
-        
     }
 
     public void writeResponse(HttpExchange exchange, HttpServletResponse response) throws IOException {
@@ -111,9 +113,9 @@
     }
 
     private void copyProtocolHeaders(Message request, Message response) {
-        if (request.getHeader(GZIPHelper.CONTENT_ENCODING) != null) {            
-            String contentEncoding = request.getHeader(GZIPHelper.CONTENT_ENCODING, String.class);            
-            response.setHeader(GZIPHelper.CONTENT_ENCODING, contentEncoding);
+        if (request.getHeader(HttpConstants.CONTENT_ENCODING) != null) {
+            String contentEncoding = request.getHeader(HttpConstants.CONTENT_ENCODING, String.class);
+            response.setHeader(HttpConstants.CONTENT_ENCODING, contentEncoding);
         }        
     }
 
@@ -155,46 +157,54 @@
 
         // write the body.
         if (message.getBody() != null) {
-            // try to stream the body since that would be the most efficient
-            InputStream is = message.getBody(InputStream.class);
-            if (is != null) {
-                ServletOutputStream os = response.getOutputStream();
-                try {
-                    ByteArrayOutputStream initialArray = new ByteArrayOutputStream();
-                    int c;
-                    // TODO: Use a buffer to write faster instead of looping one char at a time
-                    while ((c = is.read()) >= 0) {
-                        initialArray.write(c);
-                    }
-                    byte[] processedArray = processReponseContent(message, initialArray.toByteArray(), response);
-                    os.write(processedArray);
-                    // set content length before we flush
-                    // Here the processedArray length is used instead of the
-                    // length of the characters in written to the initialArray
-                    // because if the method processReponseContent compresses
-                    // the data, the processedArray may contain a different length 
-                    response.setContentLength(processedArray.length);
-                    os.flush();
-                } finally {
-                    os.close();
-                    is.close();
-                }
+            if (GZIPHelper.isGzip(message)) {
+                doWriteGZIPResponse(message, response, exchange);
             } else {
-                String data = message.getBody(String.class);
-                if (data != null) {
-                    // set content length before we write data
-                    response.setContentLength(data.length());
-                    response.getWriter().print(data);
-                    response.getWriter().flush();
-                }
+                doWriteDirectResponse(message, response, exchange);
             }
+        }
+    }
 
+    protected void doWriteDirectResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
+        InputStream is = message.getBody(InputStream.class);
+        if (is != null) {
+            ServletOutputStream os = response.getOutputStream();
+            try {
+                // copy directly from input stream to output stream
+                IOHelper.copy(is, os);
+            } finally {
+                os.close();
+                is.close();
+            }
+        } else {
+            // not convertable as a stream so try as a String
+            String data = message.getBody(String.class);
+            if (data != null) {
+                // set content length before we write data
+                response.setContentLength(data.length());
+                response.getWriter().print(data);
+                response.getWriter().flush();
+            }
         }
     }
-    
-    protected byte[] processReponseContent(Message message, byte[] array, HttpServletResponse response) throws IOException {
-        String gzipEncoding = message.getHeader(GZIPHelper.CONTENT_ENCODING, String.class);        
-        return GZIPHelper.compressArrayIfGZIPRequested(gzipEncoding, array, response);
+
+    protected void doWriteGZIPResponse(Message message, HttpServletResponse response, Exchange exchange) throws IOException {
+        byte[] bytes;
+        try {
+            bytes = message.getMandatoryBody(byte[].class);
+        } catch (InvalidPayloadException e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
+
+        byte[] data = GZIPHelper.compressGZIP(bytes);
+        ServletOutputStream os = response.getOutputStream();
+        try {
+            response.setContentLength(data.length);
+            os.write(data);
+            os.flush();
+        } finally {
+            os.close();
+        }
     }
 
     public Object parseBody(HttpMessage httpMessage) throws IOException {
@@ -207,7 +217,8 @@
         if (isUseReaderForPayload()) {
             return request.getReader();
         } else {
-            return GZIPHelper.getInputStream(request);
+            // otherwise use input stream
+            return HttpConverter.toInputStream(request);
         }
     }
 

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConstants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConstants.java?rev=779489&r1=779488&r2=779489&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConstants.java (original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConstants.java Thu May 28 08:58:14 2009
@@ -19,9 +19,12 @@
 /**
  * Constants
  */
-public final class HttpConstants {    
+public final class HttpConstants {
+
+    public static final String CONTENT_ENCODING = "Content-Encoding";
 
     private HttpConstants() {
         // utility class
     }
+
 }

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java?rev=779489&r1=779488&r2=779489&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java (original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpConverter.java Thu May 28 08:58:14 2009
@@ -19,7 +19,6 @@
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
-
 import javax.servlet.ServletInputStream;
 import javax.servlet.http.HttpServletRequest;
 
@@ -33,10 +32,13 @@
  * @version $Revision$
  */
 @Converter
-public class HttpConverter {
+public final class HttpConverter {
+
+    private HttpConverter() {
+    }
 
     @Converter
-    public HttpServletRequest toServletRequest(HttpMessage message) {
+    public static HttpServletRequest toServletRequest(HttpMessage message) {
         if (message == null) {
             return null;
         }
@@ -44,7 +46,7 @@
     }
 
     @Converter
-    public ServletInputStream toServletInputStream(HttpMessage message) throws IOException {
+    public static ServletInputStream toServletInputStream(HttpMessage message) throws IOException {
         HttpServletRequest request = toServletRequest(message);
         if (request != null) {
             return request.getInputStream();
@@ -53,16 +55,12 @@
     }
 
     @Converter
-    public InputStream toInputStream(HttpMessage message) throws Exception {
-        HttpServletRequest request = toServletRequest(message);
-        if (request != null) {
-            return GZIPHelper.getInputStream(request);
-        }
-        return null;
+    public static InputStream toInputStream(HttpMessage message) throws Exception {
+        return toInputStream(toServletRequest(message));
     }
 
     @Converter
-    public BufferedReader toReader(HttpMessage message) throws IOException {
+    public static BufferedReader toReader(HttpMessage message) throws IOException {
         HttpServletRequest request = toServletRequest(message);
         if (request != null) {
             return request.getReader();
@@ -70,4 +68,13 @@
         return null;
     }
 
+    @Converter
+    public static InputStream toInputStream(HttpServletRequest request) throws IOException {
+        if (request == null) {
+            return null;
+        }
+        String contentEncoding = request.getHeader(HttpConstants.CONTENT_ENCODING);
+        return GZIPHelper.toGZIPInputStream(contentEncoding, request.getInputStream());
+    }
+
 }

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java?rev=779489&r1=779488&r2=779489&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java (original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java Thu May 28 08:58:14 2009
@@ -19,6 +19,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
+import java.util.zip.GZIPInputStream;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
@@ -28,7 +29,7 @@
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.ExchangeHelper;
-import org.apache.camel.util.MessageHelper;
+import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpClient;
@@ -36,7 +37,6 @@
 import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
 import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -156,16 +156,22 @@
      * @throws IOException can be thrown
      */
     protected static InputStream extractResponseBody(HttpMethod method, Exchange exchange) throws IOException {
-        InputStream is = null;
+        InputStream is = method.getResponseBodyAsStream();
+        if (is == null) {
+            return null;
+        }
+
+        Header header = method.getRequestHeader(HttpConstants.CONTENT_ENCODING);
+        String contentEncoding = header != null ? header.getValue() : null;
+
+        is = GZIPHelper.toGZIPInputStream(contentEncoding, is);
+        return doExtractResponseBody(is, exchange);
+    }
+
+    private static InputStream doExtractResponseBody(InputStream is, Exchange exchange) throws IOException {
         try {
             CachedOutputStream cos = new CachedOutputStream(exchange.getContext().getProperties());
-            is = GZIPHelper.getInputStream(method);            
-            // in case of no response stream
-            if (is == null) {
-                return null;
-            }
-            IOUtils.copy(is, cos);
-            cos.flush();
+            IOHelper.copy(is, cos);
             return cos.getInputStream();
         } finally {
             ObjectHelper.close(is, "Extracting response body", LOG);            
@@ -225,7 +231,7 @@
         }
         if (methodToUse.isEntityEnclosing()) {
             ((EntityEnclosingMethod)method).setRequestEntity(requestEntity);
-            if (requestEntity.getContentType() == null) {
+            if (requestEntity != null && requestEntity.getContentType() == null) {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("No Content-Type provided for URI: " + uri + " with exchange: " + exchange);
                 }

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/RequestEntityConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/RequestEntityConverter.java?rev=779489&r1=779488&r2=779489&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/RequestEntityConverter.java (original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/RequestEntityConverter.java Thu May 28 08:58:14 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.http;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.nio.ByteBuffer;
 
@@ -34,42 +35,44 @@
 
     @Converter
     public RequestEntity toRequestEntity(ByteBuffer buffer, Exchange exchange) throws Exception {
-        return new InputStreamRequestEntity(
-                GZIPHelper.toGZIPInputStreamIfRequested(
-                        exchange.getIn().getHeader(GZIPHelper.CONTENT_ENCODING, String.class),
-                        buffer.array()), ExchangeHelper.getContentType(exchange));
+        return asRequestEntity(buffer.array(), exchange);
     }
 
     @Converter
-    public RequestEntity toRequestEntity(byte[] array, Exchange exchange) throws Exception {
-        return new InputStreamRequestEntity(
-                GZIPHelper.toGZIPInputStreamIfRequested(
-                        exchange.getIn().getHeader(GZIPHelper.CONTENT_ENCODING, String.class),
-                        array), ExchangeHelper.getContentType(exchange));
+    public RequestEntity toRequestEntity(byte[] data, Exchange exchange) throws Exception {
+        return asRequestEntity(data, exchange);
     }
 
     @Converter
     public RequestEntity toRequestEntity(InputStream inStream, Exchange exchange) throws Exception {
-        return new InputStreamRequestEntity(
-                GZIPHelper.getGZIPWrappedInputStream(
-                        exchange.getIn().getHeader(GZIPHelper.CONTENT_ENCODING, String.class),
-                        inStream), ExchangeHelper.getContentType(exchange));
+        return asRequestEntity(inStream, exchange);
     }
 
-
     @Converter
     public RequestEntity toRequestEntity(String str, Exchange exchange) throws Exception {
-        if (GZIPHelper.containsGzip(exchange.getIn().getHeader(GZIPHelper.CONTENT_ENCODING, String.class))) {            
-            return new InputStreamRequestEntity(
-                GZIPHelper.toGZIPInputStreamIfRequested(
-                        exchange.getIn().getHeader(GZIPHelper.CONTENT_ENCODING, String.class),
-                        str.getBytes()), ExchangeHelper.getContentType(exchange));
+        if (GZIPHelper.isGzip(exchange.getIn())) {
+            byte[] data = exchange.getContext().getTypeConverter().convertTo(byte[].class, str);
+            return asRequestEntity(data, exchange);
         } else {
             // will use the default StringRequestEntity
             return null;
         }
     }
 
+    private RequestEntity asRequestEntity(InputStream in, Exchange exchange) throws IOException {
+        return new InputStreamRequestEntity(
+                GZIPHelper.toGZIPInputStream(
+                        exchange.getIn().getHeader(HttpConstants.CONTENT_ENCODING, String.class),
+                        in), ExchangeHelper.getContentType(exchange));
+    }
+
+    private RequestEntity asRequestEntity(byte[] data, Exchange exchange) throws Exception {
+        return new InputStreamRequestEntity(
+            GZIPHelper.toGZIPInputStream(
+                    exchange.getIn().getHeader(HttpConstants.CONTENT_ENCODING, String.class),
+                    data), ExchangeHelper.getContentType(exchange));
+    }
+
 
 }
 

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/GZIPHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/GZIPHelper.java?rev=779489&r1=779488&r2=779489&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/GZIPHelper.java (original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/GZIPHelper.java Thu May 28 08:58:14 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.http.helper;
 
-import java.io.BufferedInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -24,108 +23,64 @@
 import java.util.zip.GZIPInputStream;
 import java.util.zip.GZIPOutputStream;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.camel.Message;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpMethod;
+import org.apache.camel.component.http.HttpConstants;
+import org.apache.camel.util.ObjectHelper;
 
 /**
- * 
- * Helper/Utility class to help wrapping
- * content into GZIP Input/Output Streams.
- * 
- *
+ * Helper class to help wrapping content into GZIP input and output streams.
  */
 public final class GZIPHelper {
 
-    public static final String CONTENT_ENCODING = "Content-Encoding";
-    public static final String GZIP = "gzip";
-    
-
-    // No need for instatiating, so avoid it.
-    private GZIPHelper() { }
-    
-    public static void setGZIPMessageHeader(Message message) {
-        message.setHeader(CONTENT_ENCODING, GZIP);
+    private GZIPHelper() {
     }
     
-    public static void setGZIPContentEncoding(HttpServletResponse response) {
-        response.setHeader(CONTENT_ENCODING, GZIP);
-    }
-
-    // --------- Methods To Decompress ----------
-
-    public static InputStream getInputStream(HttpMethod method)
-        throws IOException {
-
-        Header header = method.getRequestHeader(CONTENT_ENCODING);
-        String contentEncoding =  header != null ? header.getValue() : null;
-        return getGZIPWrappedInputStream(contentEncoding, 
-            method.getResponseBodyAsStream());
-    }
-
-    public static InputStream getInputStream(HttpServletRequest request) throws IOException {
-        InputStream dataStream = request.getInputStream();
-        String contentEncoding = request.getHeader(CONTENT_ENCODING);
-        return getGZIPWrappedInputStream(contentEncoding, dataStream);
-    }
-
-    public static InputStream getGZIPWrappedInputStream(String gzipEncoding,
-        InputStream inStream) throws IOException {
-        if (containsGzip(gzipEncoding)) {
-            return new GZIPInputStream(new BufferedInputStream(inStream));
+    public static InputStream toGZIPInputStream(String contentEncoding, InputStream in) throws IOException {
+        if (isGzip(contentEncoding)) {
+            return new GZIPInputStream(in);
         } else {
-            return inStream;
+            return in;
         }
     }
 
-    public static InputStream toGZIPInputStreamIfRequested(String gzipEncoding, byte[] array)
-        throws Exception {
-        if (containsGzip(gzipEncoding)) {
-            // GZip byte array content
-            ByteArrayOutputStream outputByteArray = new ByteArrayOutputStream();
-            GZIPOutputStream gzipOutputStream = new GZIPOutputStream(
-                outputByteArray);
-            gzipOutputStream.write(array);
-            gzipOutputStream.close();
-            return new ByteArrayInputStream(outputByteArray.toByteArray());
+    public static InputStream toGZIPInputStream(String contentEncoding, byte[] data) throws Exception {
+        if (isGzip(contentEncoding)) {
+            ByteArrayOutputStream os = null;
+            GZIPOutputStream gzip = null;
+            try {
+                os = new ByteArrayOutputStream();
+                gzip = new GZIPOutputStream(os);
+                gzip.write(data);
+                gzip.finish();
+                return new ByteArrayInputStream(os.toByteArray());
+            } finally {
+                ObjectHelper.close(gzip, "gzip", null);
+                ObjectHelper.close(os, "byte array", null);
+            }
         } else {
-            return new ByteArrayInputStream(array);
+            return new ByteArrayInputStream(data);
         }
     }
 
-    // -------------- Methods To Compress --------------
-
-    public static byte[] compressArrayIfGZIPRequested(String gzipEncoding,
-        byte[] array) throws IOException {
-        if (containsGzip(gzipEncoding)) {
-            return getGZIPWrappedOutputStream(array).toByteArray();
-        } else {
-            return array;
-        }
-    }
-    
-    public static byte[] compressArrayIfGZIPRequested(String gzipEncoding,
-            byte[] array, HttpServletResponse response) throws IOException {
-        if (containsGzip(gzipEncoding)) {
-            return getGZIPWrappedOutputStream(array).toByteArray();
-        } else {
-            return array;
+    public static byte[] compressGZIP(byte[] data) throws IOException {
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        GZIPOutputStream gzip = new GZIPOutputStream(os);
+        try {
+            gzip.write(data);
+            gzip.finish();
+            return os.toByteArray();
+        } finally {
+            gzip.close();
+            os.close();
         }
     }
-    
-    public static ByteArrayOutputStream getGZIPWrappedOutputStream(byte[] array) throws IOException {
-        ByteArrayOutputStream compressed = new ByteArrayOutputStream();
-        GZIPOutputStream gzout = new GZIPOutputStream(compressed);
-        gzout.write(array);
-        gzout.close();
-        return compressed;
+
+    public static boolean isGzip(Message message) {
+        return isGzip(message.getHeader(HttpConstants.CONTENT_ENCODING, String.class));
     }
 
-    public static boolean containsGzip(String str) {
-        return str != null && str.toLowerCase().indexOf(GZIP) >= 0;
+    public static boolean isGzip(String header) {
+        return header != null && header.toLowerCase().contains("gzip");
     }
 
 }

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/LoadingByteArrayOutputStream.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/LoadingByteArrayOutputStream.java?rev=779489&r1=779488&r2=779489&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/LoadingByteArrayOutputStream.java (original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/helper/LoadingByteArrayOutputStream.java Thu May 28 08:58:14 2009
@@ -33,11 +33,13 @@
  * is using.
  */
 public class LoadingByteArrayOutputStream extends ByteArrayOutputStream {
+
     public LoadingByteArrayOutputStream() {
         super(1024);
     }
-    public LoadingByteArrayOutputStream(int i) {
-        super(i);
+
+    public LoadingByteArrayOutputStream(int size) {
+        super(size);
     }
 
     public ByteArrayInputStream createInputStream() {

Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java?rev=779489&r1=779488&r2=779489&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java (original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyContentTypeTest.java Thu May 28 08:58:14 2009
@@ -21,7 +21,7 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.helper.GZIPHelper;
+import org.apache.camel.component.http.HttpConstants;
 import org.apache.camel.util.ExchangeHelper;
 import org.apache.camel.util.MessageHelper;
 
@@ -29,6 +29,7 @@
  * Unit test for content-type
  */
 public class JettyContentTypeTest extends ContextTestSupport {
+
     protected void sendMessageWithContentType(boolean usingGZip) {
         Endpoint endpoint = context.getEndpoint("http://localhost:9080/myapp/myservice");
         Exchange exchange = endpoint.createExchange();
@@ -36,12 +37,12 @@
         exchange.getIn().setHeader("user", "Claus");
         exchange.getIn().setHeader("Content-Type", "text/xml");
         if (usingGZip) {
-            GZIPHelper.setGZIPMessageHeader(exchange.getIn());
+            exchange.getIn().setHeader(HttpConstants.CONTENT_ENCODING, "gzip");
         }
         template.send(endpoint, exchange);
 
         String body = exchange.getOut().getBody(String.class);
-        System.out.print("The out message header is " + exchange.getOut().getHeaders());
+        // System.out.print("The out message header is " + exchange.getOut().getHeaders());
         assertEquals("<order>OK</order>", body);
         assertEquals("Get a wrong content-type ", MessageHelper.getContentType(exchange.getOut()), "text/xml");
     }

Modified: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyImageFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyImageFileTest.java?rev=779489&r1=779488&r2=779489&view=diff
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyImageFileTest.java (original)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyImageFileTest.java Thu May 28 08:58:14 2009
@@ -23,7 +23,7 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.http.helper.GZIPHelper;
+import org.apache.camel.component.http.HttpConstants;
 import org.apache.camel.util.MessageHelper;
 
 /**
@@ -35,7 +35,7 @@
         Endpoint endpoint = context.getEndpoint("http://localhost:9080/myapp/myservice");
         Exchange exchange = endpoint.createExchange();        
         if (usingGZip) {
-            GZIPHelper.setGZIPMessageHeader(exchange.getIn());
+            exchange.getIn().setHeader(HttpConstants.CONTENT_ENCODING, "gzip");
         }
         template.send(endpoint, exchange);