You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2006/03/30 00:39:03 UTC

svn commit: r389915 - in /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http: HTTPTransportUtils.java SOAPOverHTTPSender.java

Author: dims
Date: Wed Mar 29 14:39:01 2006
New Revision: 389915

URL: http://svn.apache.org/viewcvs?rev=389915&view=rev
Log:
enable gzip on send as well - needs MC_GZIP_REQUEST and CHUNKED flags on

Modified:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java?rev=389915&r1=389914&r2=389915&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportUtils.java Wed Mar 29 14:39:01 2006
@@ -49,8 +49,10 @@
 import javax.xml.stream.XMLStreamReader;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.IOException;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.zip.GZIPInputStream;
 
 public class HTTPTransportUtils {
 
@@ -167,6 +169,14 @@
 
         try {
 
+            Map headers = (Map) msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
+            if(headers != null) {
+                if(HTTPConstants.COMPRESSION_GZIP.equals(headers.get(HTTPConstants.HEADER_CONTENT_ENCODING))||
+                   HTTPConstants.COMPRESSION_GZIP.equals(headers.get(HTTPConstants.HEADER_CONTENT_ENCODING.toLowerCase()))){
+                    in = new GZIPInputStream(in);
+                }
+            }
+
             // remove the starting and trailing " from the SOAP Action
             if ((soapActionHeader != null) && soapActionHeader.startsWith("\"")
                     && soapActionHeader.endsWith("\"")) {
@@ -291,6 +301,8 @@
             throw new AxisFault(e);
         } catch (AxisFault e) {
             throw e;
+        } catch (IOException e) {
+            throw new AxisFault(e);
         } catch (OMException e) {
             throw new AxisFault(e);
         } catch (XMLStreamException e) {

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java?rev=389915&r1=389914&r2=389915&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/SOAPOverHTTPSender.java Wed Mar 29 14:39:01 2006
@@ -20,8 +20,10 @@
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.zip.GZIPOutputStream;
 
 public class SOAPOverHTTPSender extends AbstractHTTPSender {
 
@@ -169,6 +171,10 @@
         }
 
         public void writeRequest(OutputStream out) throws IOException {
+            Boolean gzip = (Boolean) msgCtxt.getOptions().getProperty(HTTPConstants.MC_GZIP_REQUEST);
+            if(gzip != null && gzip.booleanValue() && chunked) {
+                out = new GZIPOutputStream(out);
+            }
             try {
                 if (chunked) {
                     this.handleOMOutput(out, doingMTOM);
@@ -180,6 +186,9 @@
                     out.write(bytes);
                 }
 
+                if(out instanceof GZIPOutputStream){
+                    ((GZIPOutputStream)out).finish();
+                }
                 out.flush();
             } catch (XMLStreamException e) {
                 throw new AxisFault(e);