You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2017/01/22 13:47:49 UTC

svn commit: r1779815 [1/2] - in /axis/axis2/java/core/branches/hermetic-tests: ./ modules/kernel/src/org/apache/axis2/transport/http/ modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/ modules/transport/http/src/...

Author: veithen
Date: Sun Jan 22 13:47:49 2017
New Revision: 1779815

URL: http://svn.apache.org/viewvc?rev=1779815&view=rev
Log:
Merge latest changes from trunk.

Removed:
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPTransportHeaders.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/RESTRequestEntity2Impl.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/RESTRequestEntityImpl.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/RESTRequestEntity2.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPTransportHeaders.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntity2Impl.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RESTRequestEntityImpl.java
Modified:
    axis/axis2/java/core/branches/hermetic-tests/   (props changed)
    axis/axis2/java/core/branches/hermetic-tests/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/AxisRequestEntityImpl.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/RequestImpl.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPTransportSender.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/CommonsTransportHeaders.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/Request.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RequestImpl.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/test/org/apache/axis2/transport/http/HTTPClient4SenderTest.java
    axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/test/org/apache/axis2/transport/http/HTTPSenderTest.java

Propchange: axis/axis2/java/core/branches/hermetic-tests/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Jan 22 13:47:49 2017
@@ -1,4 +1,4 @@
 /axis/axis2/java/core/branches/1_6:1295540
 /axis/axis2/java/core/branches/AXIOM-420:1334386-1336397
 /axis/axis2/java/core/branches/AXIS2-4318:1230452,1295542,1324772,1327468,1329571,1332141,1335355,1335357,1340985
-/axis/axis2/java/core/trunk:1779063-1779074
+/axis/axis2/java/core/trunk:1779063-1779814

Modified: axis/axis2/java/core/branches/hermetic-tests/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java Sun Jan 22 13:47:49 2017
@@ -512,11 +512,6 @@ public class HTTPConstants {
     public static final String AUTO_RELEASE_CONNECTION = "AutoReleaseConnection" ;
 
     /**
-     * Cleanup response
-     */
-    public static final String CLEANUP_RESPONSE = "CleanupResponse";
-
-    /**
      * Method getBytes.
      *
      * @param data

Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/AxisRequestEntityImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/AxisRequestEntityImpl.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/AxisRequestEntityImpl.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/AxisRequestEntityImpl.java Sun Jan 22 13:47:49 2017
@@ -54,6 +54,6 @@ public class AxisRequestEntityImpl imple
 
     @Override
     public String getContentType() {
-        return entity.getContentTypeAsString();
+        return entity.getContentType();
     }
 }

Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java Sun Jan 22 13:47:49 2017
@@ -22,9 +22,7 @@ package org.apache.axis2.transport.http.
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.zip.GZIPInputStream;
 
@@ -35,32 +33,19 @@ import org.apache.axis2.context.MessageC
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.http.AxisRequestEntity;
-import org.apache.axis2.transport.http.HTTPAuthenticator;
+import org.apache.axis2.transport.http.CommonsTransportHeaders;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HTTPSender;
-import org.apache.axis2.transport.http.HTTPTransportConstants;
 import org.apache.axis2.transport.http.Request;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.Credentials;
 import org.apache.commons.httpclient.HeaderElement;
-import org.apache.commons.httpclient.HostConfiguration;
 import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.HttpState;
 import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.NTCredentials;
 import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthPolicy;
-import org.apache.commons.httpclient.auth.AuthScope;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.protocol.Protocol;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -76,68 +61,10 @@ public class HTTPSenderImpl extends HTTP
         return httpVersion;
     }
 
-    /**
-     * Used to send a request via HTTP Get method
-     * 
-     * @param msgContext
-     *            - The MessageContext of the message
-     * @param url
-     *            - The target URL
-     * @throws AxisFault
-     *             - Thrown in case an exception occurs
-     */
-    @Override
-    protected Request prepareGet(final MessageContext msgContext, final URL url)
-            throws AxisFault {
-        return new RequestImpl(this, msgContext, url, null, new GetMethod());
-    }
-
-    /**
-     * Used to send a request via HTTP Delete Method
-     * 
-     * @param msgContext
-     *            - The MessageContext of the message
-     * @param url
-     *            - The target URL
-     * @throws AxisFault
-     *             - Thrown in case an exception occurs
-     */
-    @Override
-    protected Request prepareDelete(final MessageContext msgContext, final URL url)
-            throws AxisFault {
-        return new RequestImpl(this, msgContext, url, null, new DeleteMethod());
-    }
-
-    /**
-     * Used to send a request via HTTP Post Method
-     * 
-     * @param msgContext
-     *            - The MessageContext of the message
-     * @param url
-     *            - The target URL
-     * @throws AxisFault
-     *             - Thrown in case an exception occurs
-     */
     @Override
-    protected Request preparePost(final MessageContext msgContext, final URL url, AxisRequestEntity requestEntity)
-            throws AxisFault {
-        return new RequestImpl(this, msgContext, url, requestEntity, new PostMethod());
-    }
-
-    /**
-     * Used to send a request via HTTP Put Method
-     * 
-     * @param msgContext
-     *            - The MessageContext of the message
-     * @param url
-     *            - The target URL
-     * @throws AxisFault
-     *             - Thrown in case an exception occurs
-     */
-    @Override
-    protected Request preparePut(final MessageContext msgContext, final URL url, AxisRequestEntity requestEntity)
-            throws AxisFault {
-        return new RequestImpl(this, msgContext, url, requestEntity, new PutMethod());
+    protected Request createRequest(MessageContext msgContext, String methodName, URL url,
+            AxisRequestEntity requestEntity) throws AxisFault {
+        return new RequestImpl(this, msgContext, methodName, url, requestEntity);
     }
 
     /**
@@ -151,22 +78,16 @@ public class HTTPSenderImpl extends HTTP
      * @throws AxisFault
      *             if problems occur
      */
-    protected void obtainHTTPHeaderInformation(Object httpMethodBase, MessageContext msgContext)
+    protected void obtainHTTPHeaderInformation(Request request, HttpMethod method, MessageContext msgContext)
             throws AxisFault {
-        HttpMethod method;
-        if (httpMethodBase instanceof HttpMethodBase) {
-            method = (HttpMethod) httpMethodBase;
-        } else {
-            return;
-        }
         // Set RESPONSE properties onto the REQUEST message context. They will
         // need to be copied off the request context onto
         // the response context elsewhere, for example in the
         // OutInOperationClient.
-        Map transportHeaders = new HTTPTransportHeaders(method.getResponseHeaders());
+        Map transportHeaders = new CommonsTransportHeaders(request.getResponseHeaders());
         msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, transportHeaders);
         msgContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE,
-                new Integer(method.getStatusCode()));
+                new Integer(request.getStatusCode()));
         Header header = method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
 
         if (header != null) {
@@ -252,9 +173,9 @@ public class HTTPSenderImpl extends HTTP
         return cookie;
     }
 
-    protected void processResponse(HttpMethodBase httpMethod, MessageContext msgContext)
+    protected void processResponse(Request request, HttpMethodBase httpMethod, MessageContext msgContext)
             throws IOException {
-        obtainHTTPHeaderInformation(httpMethod, msgContext);
+        obtainHTTPHeaderInformation(request, httpMethod, msgContext);
 
         InputStream in = httpMethod.getResponseBodyAsStream();
         if (in == null) {
@@ -280,193 +201,6 @@ public class HTTPSenderImpl extends HTTP
     }
 
     /**
-     * getting host configuration to support standard http/s, proxy and NTLM
-     * support
-     * 
-     * @param client
-     *            active HttpClient
-     * @param msgCtx
-     *            active MessageContext
-     * @param targetURL
-     *            the target URL
-     * @return a HostConfiguration set up with proxy information
-     * @throws AxisFault
-     *             if problems occur
-     */
-    protected HostConfiguration getHostConfiguration(HttpClient client, MessageContext msgCtx,
-            URL targetURL) throws AxisFault {
-
-        boolean isAuthenticationEnabled = isAuthenticationEnabled(msgCtx);
-        int port = targetURL.getPort();
-
-        String protocol = targetURL.getProtocol();
-        if (port == -1) {
-            if (HTTPTransportConstants.PROTOCOL_HTTP.equals(protocol)) {
-                port = 80;
-            } else if (HTTPTransportConstants.PROTOCOL_HTTPS.equals(protocol)) {
-                port = 443;
-            }
-
-        }
-
-        // to see the host is a proxy and in the proxy list - available in
-        // axis2.xml
-        HostConfiguration config = client.getHostConfiguration();
-        if (config == null) {
-            config = new HostConfiguration();
-        }
-
-        // one might need to set his own socket factory. Let's allow that case
-        // as well.
-        Protocol protocolHandler = (Protocol) msgCtx.getOptions().getProperty(
-                HTTPConstants.CUSTOM_PROTOCOL_HANDLER);
-
-        // setting the real host configuration
-        // I assume the 90% case, or even 99% case will be no protocol handler
-        // case.
-        if (protocolHandler == null) {
-            config.setHost(targetURL.getHost(), port, targetURL.getProtocol());
-        } else {
-            config.setHost(targetURL.getHost(), port, protocolHandler);
-        }
-
-        if (isAuthenticationEnabled) {
-            // Basic, Digest, NTLM and custom authentications.
-            this.setAuthenticationInfo(client, msgCtx, config);
-        }
-        // proxy configuration
-
-        if (HTTPProxyConfigurator.isProxyEnabled(msgCtx, targetURL)) {
-            if (log.isDebugEnabled()) {
-                log.debug("Configuring HTTP proxy.");
-            }
-            HTTPProxyConfigurator.configure(msgCtx, client, config);
-        }
-
-        return config;
-    }
-
-    protected boolean isAuthenticationEnabled(MessageContext msgCtx) {
-        return (msgCtx.getProperty(HTTPConstants.AUTHENTICATE) != null);
-    }
-
-    /*
-     * This will handle server Authentication, It could be either NTLM, Digest
-     * or Basic Authentication. Apart from that user can change the priory or
-     * add a custom authentication scheme.
-     */
-    protected void setAuthenticationInfo(HttpClient agent, MessageContext msgCtx,
-            HostConfiguration config) throws AxisFault {
-        HTTPAuthenticator authenticator;
-        Object obj = msgCtx.getProperty(HTTPConstants.AUTHENTICATE);
-        if (obj != null) {
-            if (obj instanceof HTTPAuthenticator) {
-                authenticator = (HTTPAuthenticator) obj;
-
-                String username = authenticator.getUsername();
-                String password = authenticator.getPassword();
-                String host = authenticator.getHost();
-                String domain = authenticator.getDomain();
-
-                int port = authenticator.getPort();
-                String realm = authenticator.getRealm();
-
-                /* If retrying is available set it first */
-                isAllowedRetry = authenticator.isAllowedRetry();
-
-                Credentials creds;
-
-                HttpState tmpHttpState = null;
-                HttpState httpState = (HttpState) msgCtx
-                        .getProperty(HTTPConstants.CACHED_HTTP_STATE);
-                if (httpState != null) {
-                    tmpHttpState = httpState;
-                } else {
-                    tmpHttpState = agent.getState();
-                }
-
-                agent.getParams().setAuthenticationPreemptive(
-                        authenticator.getPreemptiveAuthentication());
-
-                if (host != null) {
-                    if (domain != null) {
-                        /* Credentials for NTLM Authentication */
-                        creds = new NTCredentials(username, password, host, domain);
-                    } else {
-                        /* Credentials for Digest and Basic Authentication */
-                        creds = new UsernamePasswordCredentials(username, password);
-                    }
-                    tmpHttpState.setCredentials(new AuthScope(host, port, realm), creds);
-                } else {
-                    if (domain != null) {
-                        /*
-                         * Credentials for NTLM Authentication when host is
-                         * ANY_HOST
-                         */
-                        creds = new NTCredentials(username, password, AuthScope.ANY_HOST, domain);
-                        tmpHttpState.setCredentials(new AuthScope(AuthScope.ANY_HOST, port, realm),
-                                creds);
-                    } else {
-                        /* Credentials only for Digest and Basic Authentication */
-                        creds = new UsernamePasswordCredentials(username, password);
-                        tmpHttpState.setCredentials(new AuthScope(AuthScope.ANY), creds);
-                    }
-                }
-                /* Customizing the priority Order */
-                List schemes = authenticator.getAuthSchemes();
-                if (schemes != null && schemes.size() > 0) {
-                    List authPrefs = new ArrayList(3);
-                    for (int i = 0; i < schemes.size(); i++) {
-                        if (schemes.get(i) instanceof AuthPolicy) {
-                            authPrefs.add(schemes.get(i));
-                            continue;
-                        }
-                        String scheme = (String) schemes.get(i);
-                        authPrefs.add(authenticator.getAuthPolicyPref(scheme));
-
-                    }
-                    agent.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
-                }
-
-            } else {
-                throw new AxisFault("HttpTransportProperties.Authenticator class cast exception");
-            }
-        }
-
-    }
-
-    /**
-     * Method used to copy all the common properties
-     * 
-     * @param msgContext
-     *            - The messageContext of the request message
-     * @param url
-     *            - The target URL
-     * @param httpMethod
-     *            - The http method used to send the request
-     * @param httpClient
-     *            - The httpclient used to send the request
-     * @param soapActionString
-     *            - The soap action atring of the request message
-     * @return MessageFormatter - The messageFormatter for the relavent request
-     *         message
-     * @throws AxisFault
-     *             - Thrown in case an exception occurs
-     */
-    protected void populateCommonProperties(MessageContext msgContext, URL url,
-            HttpMethodBase httpMethod, HttpClient httpClient)
-            throws AxisFault {
-
-        if (isAuthenticationEnabled(msgContext)) {
-            httpMethod.setDoAuthentication(true);
-        }
-
-        httpMethod.setPath(url.getPath());
-
-        httpMethod.setQueryString(url.getQuery());
-    }
-
-    /**
      * This is used to get the dynamically set time out values from the message
      * context. If the values are not available or invalid then the default
      * values or the values set by the configuration will be used

Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/RequestImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/RequestImpl.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/RequestImpl.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/RequestImpl.java Sun Jan 22 13:47:49 2017
@@ -20,25 +20,34 @@ package org.apache.axis2.transport.http.
 
 import java.io.IOException;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
 
+import org.apache.axiom.mime.Header;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.NamedValue;
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.http.AxisRequestEntity;
+import org.apache.axis2.transport.http.HTTPAuthenticator;
 import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.transport.http.HTTPTransportConstants;
 import org.apache.axis2.transport.http.Request;
 import org.apache.axis2.wsdl.WSDLConstants;
-import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.Credentials;
 import org.apache.commons.httpclient.HostConfiguration;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpMethodBase;
 import org.apache.commons.httpclient.HttpState;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.HttpVersion;
+import org.apache.commons.httpclient.NTCredentials;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthPolicy;
+import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
 import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.commons.httpclient.protocol.Protocol;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -50,21 +59,46 @@ final class RequestImpl implements Reque
     protected final URL url;
     protected final HttpMethodBase method;
     protected final HttpClient httpClient;
+    private final HostConfiguration config;
 
-    RequestImpl(HTTPSenderImpl sender, MessageContext msgContext, URL url, AxisRequestEntity requestEntity, HttpMethodBase method) throws AxisFault {
+    RequestImpl(HTTPSenderImpl sender, MessageContext msgContext, final String methodName, URL url,
+            AxisRequestEntity requestEntity) throws AxisFault {
         this.sender = sender;
         this.msgContext = msgContext;
         this.url = url;
-        this.method = method;
         httpClient = sender.getHttpClient(msgContext);
-        sender.populateCommonProperties(msgContext, url, method, httpClient);
-        if (requestEntity != null) {
-            ((EntityEnclosingMethod)method).setRequestEntity(new AxisRequestEntityImpl(requestEntity));
-    
+        if (requestEntity == null) {
+            method = new HttpMethodBase() {
+                @Override
+                public String getName() {
+                    return methodName;
+                }
+            };
+            // This mimicks GetMethod
+            if (methodName.equals(HTTPConstants.HTTP_METHOD_GET)) {
+                method.setFollowRedirects(true);
+            }
+        } else {
+            EntityEnclosingMethod entityEnclosingMethod = new EntityEnclosingMethod() {
+                @Override
+                public String getName() {
+                    return methodName;
+                }
+            };
+            entityEnclosingMethod.setRequestEntity(new AxisRequestEntityImpl(requestEntity));
             if (!sender.getHttpVersion().equals(HTTPConstants.HEADER_PROTOCOL_10) && sender.isChunked()) {
-                ((EntityEnclosingMethod)method).setContentChunked(true);
+                entityEnclosingMethod.setContentChunked(true);
             }
+            method = entityEnclosingMethod;
         }
+        method.setPath(url.getPath());
+        method.setQueryString(url.getQuery());
+        // TODO: this is fishy; it means that we may end up modifying a HostConfiguration from a cached HTTP client
+        HostConfiguration config = httpClient.getHostConfiguration();
+        if (config == null) {
+            config = new HostConfiguration();
+        }
+        this.config = config;
     }
 
     @Override
@@ -82,17 +116,35 @@ final class RequestImpl implements Reque
         method.addRequestHeader(name, value);
     }
 
-    @Override
-    public NamedValue[] getRequestHeaders() {
-        Header[] headers = method.getRequestHeaders();
-        NamedValue[] result = new NamedValue[headers.length];
+    private static Header[] convertHeaders(org.apache.commons.httpclient.Header[] headers) {
+        Header[] result = new Header[headers.length];
         for (int i=0; i<headers.length; i++) {
-            result[i] = new NamedValue(headers[i].getName(), headers[i].getValue());
+            result[i] = new Header(headers[i].getName(), headers[i].getValue());
         }
         return result;
     }
 
     @Override
+    public Header[] getRequestHeaders() {
+        return convertHeaders(method.getRequestHeaders());
+    }
+
+    @Override
+    public int getStatusCode() {
+        return method.getStatusCode();
+    }
+
+    @Override
+    public String getStatusText() {
+        return method.getStatusText();
+    }
+
+    @Override
+    public Header[] getResponseHeaders() {
+        return convertHeaders(method.getResponseHeaders());
+    }
+
+    @Override
     public void execute() throws AxisFault {
         try {
             executeMethod();
@@ -106,7 +158,7 @@ final class RequestImpl implements Reque
     }
 
     private void executeMethod() throws IOException {
-        HostConfiguration config = sender.getHostConfiguration(httpClient, msgContext, url);
+        populateHostConfiguration();
 
         // add compression headers if needed
         if (msgContext.isPropertyTrue(HTTPConstants.MC_ACCEPT_GZIP)) {
@@ -114,11 +166,6 @@ final class RequestImpl implements Reque
                     HTTPConstants.COMPRESSION_GZIP);
         }
 
-        if (msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST)) {
-            method.addRequestHeader(HTTPConstants.HEADER_CONTENT_ENCODING,
-                    HTTPConstants.COMPRESSION_GZIP);
-        }
-
         if (msgContext.getProperty(HTTPConstants.HTTP_METHOD_PARAMS) != null) {
             HttpMethodParams params = (HttpMethodParams) msgContext
                     .getProperty(HTTPConstants.HTTP_METHOD_PARAMS);
@@ -137,25 +184,25 @@ final class RequestImpl implements Reque
     }
 
     private void handleResponse() throws IOException {
-        int statusCode = method.getStatusCode();
+        int statusCode = getStatusCode();
         log.trace("Handling response - " + statusCode);
         if (statusCode == HttpStatus.SC_ACCEPTED) {
             /* When an HTTP 202 Accepted code has been received, this will be the case of an execution 
              * of an in-only operation. In such a scenario, the HTTP response headers should be returned,
              * i.e. session cookies. */
-            sender.obtainHTTPHeaderInformation(method, msgContext);
+            sender.obtainHTTPHeaderInformation(this, method, msgContext);
             // Since we don't expect any content with a 202 response, we must release the connection
             method.releaseConnection();            
         } else if (statusCode >= 200 && statusCode < 300) {
             // Save the HttpMethod so that we can release the connection when cleaning up
             msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
-            sender.processResponse(method, msgContext);
+            sender.processResponse(this, method, msgContext);
         } else if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR
                 || statusCode == HttpStatus.SC_BAD_REQUEST) {
             // Save the HttpMethod so that we can release the connection when
             // cleaning up
             msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
-            Header contenttypeHeader = method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
+            org.apache.commons.httpclient.Header contenttypeHeader = method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
             String value = null;
             if (contenttypeHeader != null) {
                 value = contenttypeHeader.getValue();
@@ -170,19 +217,19 @@ final class RequestImpl implements Reque
             }
             if (value != null) {
 
-                sender.processResponse(method, msgContext);
+                sender.processResponse(this, method, msgContext);
             }
 
             if (org.apache.axis2.util.Utils.isClientThreadNonBlockingPropertySet(msgContext)) {
                 throw new AxisFault(Messages.getMessage("transportError",
-                        String.valueOf(statusCode), method.getStatusText()));
+                        String.valueOf(statusCode), getStatusText()));
             }
         } else {
             // Since we don't process the response, we must release the
             // connection immediately
             method.releaseConnection();
             throw new AxisFault(Messages.getMessage("transportError", String.valueOf(statusCode),
-                    method.getStatusText()));
+                    getStatusText()));
         }
     }
 
@@ -192,4 +239,122 @@ final class RequestImpl implements Reque
             method.releaseConnection();
         }
     }
+
+    /**
+     * getting host configuration to support standard http/s, proxy and NTLM
+     * support
+     * 
+     * @return a HostConfiguration set up with proxy information
+     * @throws AxisFault
+     *             if problems occur
+     */
+    protected void populateHostConfiguration() throws AxisFault {
+
+        int port = url.getPort();
+
+        String protocol = url.getProtocol();
+        if (port == -1) {
+            if (HTTPTransportConstants.PROTOCOL_HTTP.equals(protocol)) {
+                port = 80;
+            } else if (HTTPTransportConstants.PROTOCOL_HTTPS.equals(protocol)) {
+                port = 443;
+            }
+
+        }
+
+        // one might need to set his own socket factory. Let's allow that case
+        // as well.
+        Protocol protocolHandler = (Protocol) msgContext.getOptions().getProperty(
+                HTTPConstants.CUSTOM_PROTOCOL_HANDLER);
+
+        // setting the real host configuration
+        // I assume the 90% case, or even 99% case will be no protocol handler
+        // case.
+        if (protocolHandler == null) {
+            config.setHost(url.getHost(), port, url.getProtocol());
+        } else {
+            config.setHost(url.getHost(), port, protocolHandler);
+        }
+
+        // proxy configuration
+
+        if (HTTPProxyConfigurator.isProxyEnabled(msgContext, url)) {
+            if (log.isDebugEnabled()) {
+                log.debug("Configuring HTTP proxy.");
+            }
+            HTTPProxyConfigurator.configure(msgContext, httpClient, config);
+        }
+    }
+
+    /*
+     * This will handle server Authentication, It could be either NTLM, Digest
+     * or Basic Authentication. Apart from that user can change the priory or
+     * add a custom authentication scheme.
+     */
+    @Override
+    public void enableAuthentication(HTTPAuthenticator authenticator) {
+        method.setDoAuthentication(true);
+
+        String username = authenticator.getUsername();
+        String password = authenticator.getPassword();
+        String host = authenticator.getHost();
+        String domain = authenticator.getDomain();
+
+        int port = authenticator.getPort();
+        String realm = authenticator.getRealm();
+
+        Credentials creds;
+
+        HttpState tmpHttpState = null;
+        HttpState httpState = (HttpState) msgContext
+                .getProperty(HTTPConstants.CACHED_HTTP_STATE);
+        if (httpState != null) {
+            tmpHttpState = httpState;
+        } else {
+            tmpHttpState = httpClient.getState();
+        }
+
+        httpClient.getParams().setAuthenticationPreemptive(
+                authenticator.getPreemptiveAuthentication());
+
+        if (host != null) {
+            if (domain != null) {
+                /* Credentials for NTLM Authentication */
+                creds = new NTCredentials(username, password, host, domain);
+            } else {
+                /* Credentials for Digest and Basic Authentication */
+                creds = new UsernamePasswordCredentials(username, password);
+            }
+            tmpHttpState.setCredentials(new AuthScope(host, port, realm), creds);
+        } else {
+            if (domain != null) {
+                /*
+                 * Credentials for NTLM Authentication when host is
+                 * ANY_HOST
+                 */
+                creds = new NTCredentials(username, password, AuthScope.ANY_HOST, domain);
+                tmpHttpState.setCredentials(new AuthScope(AuthScope.ANY_HOST, port, realm),
+                        creds);
+            } else {
+                /* Credentials only for Digest and Basic Authentication */
+                creds = new UsernamePasswordCredentials(username, password);
+                tmpHttpState.setCredentials(new AuthScope(AuthScope.ANY), creds);
+            }
+        }
+        /* Customizing the priority Order */
+        List schemes = authenticator.getAuthSchemes();
+        if (schemes != null && schemes.size() > 0) {
+            List authPrefs = new ArrayList(3);
+            for (int i = 0; i < schemes.size(); i++) {
+                if (schemes.get(i) instanceof AuthPolicy) {
+                    authPrefs.add(schemes.get(i));
+                    continue;
+                }
+                String scheme = (String) schemes.get(i);
+                authPrefs.add(authenticator.getAuthPolicyPref(scheme));
+
+            }
+            httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
+        }
+    }
 }

Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPSender.java Sun Jan 22 13:47:49 2017
@@ -44,12 +44,6 @@ public abstract class AbstractHTTPSender
     protected TransportOutDescription proxyOutSetting = null;
     protected OMOutputFormat format = new OMOutputFormat();
 
-    /**
-     * isAllowedRetry will be using to check where the
-     * retry should be allowed or not.
-     */
-    protected boolean isAllowedRetry = false;
-
     public void setChunked(boolean chunked) {
         this.chunked = chunked;
     }

Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPTransportSender.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPTransportSender.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPTransportSender.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AbstractHTTPTransportSender.java Sun Jan 22 13:47:49 2017
@@ -358,14 +358,6 @@ public abstract class AbstractHTTPTransp
             // select the Message Sender depending on the REST status
             AbstractHTTPSender sender = createHTTPSender();
 
-            boolean chunked;
-            if (messageContext.getProperty(HTTPConstants.CHUNKED) != null) {
-                chunked = JavaUtils.isTrueExplicitly(messageContext
-                        .getProperty(HTTPConstants.CHUNKED));
-            } else {
-                chunked = defaultChunked;
-            }
-
             String httpVersion;
             if (messageContext.getProperty(HTTPConstants.HTTP_PROTOCOL_VERSION) != null) {
                 httpVersion = (String) messageContext
@@ -373,6 +365,17 @@ public abstract class AbstractHTTPTransp
             } else {
                 httpVersion = defaultHttpVersion;
             }
+            
+            boolean chunked;
+            if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)) {
+                chunked = false;
+            } else if (messageContext.getProperty(HTTPConstants.CHUNKED) != null) {
+                chunked = JavaUtils.isTrueExplicitly(messageContext
+                        .getProperty(HTTPConstants.CHUNKED));
+            } else {
+                chunked = defaultChunked;
+            }
+
             // Following order needed to be preserved because,
             // HTTP/1.0 does not support chunk encoding
             sender.setChunked(chunked);

Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/AxisRequestEntity.java Sun Jan 22 13:47:49 2017
@@ -19,16 +19,14 @@
 
 package org.apache.axis2.transport.http;
 
+import org.apache.axiom.blob.Blobs;
+import org.apache.axiom.blob.MemoryBlob;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.transport.MessageFormatter;
-import org.apache.axis2.util.JavaUtils;
 
-import javax.xml.stream.FactoryConfigurationError;
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.zip.GZIPOutputStream;
 
@@ -40,61 +38,76 @@ public final class AxisRequestEntity  {
 
     private MessageFormatter messageFormatter;
 
-    private boolean chunked = false;
+    private final boolean chunked;
+    
+    private final boolean gzip;
 
     private MessageContext messageContext;
 
-    private byte[] bytes;
+    private final MemoryBlob content;
 
-    private boolean isAllowedRetry;
+    private final boolean preserve;
 
     private OMOutputFormat format;
 
-    private String soapAction;
+    private final String contentType;
 
     /**
      * Method calls to this request entity are delegated to the following Axis2
      * message formatter object.
      *
      * @param messageFormatter
+     * @throws AxisFault 
      */
     AxisRequestEntity(MessageFormatter messageFormatter,
-                      MessageContext msgContext, OMOutputFormat format, String soapAction,
-                      boolean chunked, boolean isAllowedRetry) {
+                      MessageContext msgContext, OMOutputFormat format, String contentType,
+                      boolean chunked, boolean gzip, boolean preserve) throws AxisFault {
         this.messageFormatter = messageFormatter;
         this.messageContext = msgContext;
         this.chunked = chunked;
-        this.isAllowedRetry = isAllowedRetry;
+        this.gzip = gzip;
+        this.preserve = preserve;
         this.format = format;
-        this.soapAction = soapAction;
+        this.contentType = contentType;
+        if (chunked) {
+            content = null;
+        } else {
+            content = Blobs.createMemoryBlob();
+            OutputStream out = content.getOutputStream();
+            try {
+                internalWriteRequest(out);
+                out.close();
+            } catch (IOException ex) {
+                throw AxisFault.makeFault(ex);
+            }
+        }
     }
 
     public boolean isRepeatable() {
-        // All Axis2 request entity implementations were returning this true
-        // So we return true as defualt
-        return true;
+        // If chunking is disabled, we don't preserve the original SOAPEnvelope, but we store the
+        // serialized SOAPEnvelope in a byte array, which means that the entity can be written
+        // repeatedly.
+        return preserve || !chunked;
     }
 
     public void writeRequest(OutputStream outStream) throws IOException {
-        Object gzip = messageContext.getOptions().getProperty(HTTPConstants.MC_GZIP_REQUEST);
-        if (gzip != null && JavaUtils.isTrueExplicitly(gzip) && chunked) {
+        if (chunked) {
+            internalWriteRequest(outStream);
+        } else {
+            content.writeTo(outStream);
+        }
+    }
+    
+    private void internalWriteRequest(OutputStream outStream) throws IOException {
+        if (gzip) {
             outStream = new GZIPOutputStream(outStream);
         }
         try {
-            if (chunked) {
-                messageFormatter.writeTo(messageContext, format, outStream, isAllowedRetry);
-            } else {
-                if (bytes == null) {
-                    bytes = messageFormatter.getBytes(messageContext, format);
-                }
-                outStream.write(bytes);
-            }
-            if (outStream instanceof GZIPOutputStream) {
+            messageFormatter.writeTo(messageContext, format, outStream, preserve);
+            if (gzip) {
                 ((GZIPOutputStream) outStream).finish();
             }
             outStream.flush();
-        } catch (FactoryConfigurationError e) {
-            throw AxisFault.makeFault(e);
         } catch (IOException e) {
             throw AxisFault.makeFault(e);
         }
@@ -104,32 +117,16 @@ public final class AxisRequestEntity  {
     public long getContentLength() {
         if (chunked) {
             return -1;
+        } else {
+            return content.getSize();
         }
-        if (bytes == null) {
-            try {
-                bytes = messageFormatter.getBytes(messageContext, format);
-            } catch (AxisFault e) {
-                return -1;
-            }
-        }
-        return bytes.length;
     }
 
-    public String getContentTypeAsString() {
-        return messageFormatter.getContentType(messageContext, format, soapAction);
+    public String getContentType() {
+        return contentType;
     }
 
     public boolean isChunked() {
         return chunked;
     }
-
-    public void setChunked(boolean chunked) {
-        this.chunked = chunked;
-    }
-
-    public InputStream getRequestEntityContent() throws IOException {
-        return new ByteArrayInputStream(messageFormatter.getBytes(messageContext, format));
-    }
-    
-    
 }

Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/CommonsTransportHeaders.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/CommonsTransportHeaders.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/CommonsTransportHeaders.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/CommonsTransportHeaders.java Sun Jan 22 13:47:49 2017
@@ -25,11 +25,22 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
-public abstract class CommonsTransportHeaders implements Map {  
+import org.apache.axiom.mime.Header;
 
-    HashMap headerMap = null;
-   
-    protected abstract void init();
+public final class CommonsTransportHeaders implements Map<String,String> {  
+    private final Header[] headers;
+    private Map<String,String> headerMap;
+    
+    public CommonsTransportHeaders(Header[] headers) {
+        this.headers = headers;
+    }
+
+    private void init() {
+        headerMap = new HashMap<String,String>();
+        for (int i = 0; i < headers.length; i++) {
+            headerMap.put(headers[i].getName(), headers[i].getValue());
+        }
+    }
     
     public int size() {
         if (headerMap == null) {
@@ -65,62 +76,52 @@ public abstract class CommonsTransportHe
         return headerMap.containsValue(value);
     }
 
-    public Collection values() {
+    public Collection<String> values() {
         if (headerMap == null) {
             init();
         }
         return headerMap.values();
     }
 
-    public void putAll(Map t) {
+    public void putAll(Map<? extends String,? extends String> t) {
         if (headerMap == null) {
             init();
         }
         headerMap.putAll(t);
     }
 
-    public Set entrySet() {
+    public Set<Map.Entry<String,String>> entrySet() {
         if (headerMap == null) {
             init();
         }
         return headerMap.entrySet();
     }
 
-    public Set keySet() {
+    public Set<String> keySet() {
         if (headerMap == null) {
             init();
         }
         return headerMap.keySet();
     }
 
-    public Object get(Object key) {
+    public String get(Object key) {
         if (headerMap == null) {
             init();
         }
         return headerMap.get(key);
     }
 
-    public Object remove(Object key) {
+    public String remove(Object key) {
         if (headerMap == null) {
             init();
         }
         return headerMap.remove(key);
     }
 
-    public Object put(Object key, Object value) {
+    public String put(String key, String value) {
         if (headerMap == null) {
             init();
         }
         return headerMap.put(key, value);
     }
-
-    public HashMap getHeaderMap() {
-        return headerMap;
-    }
-
-    public void setHeaderMap(HashMap headerMap) {
-        this.headerMap = headerMap;
-    }
-    
-    
 }

Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/HTTPSender.java Sun Jan 22 13:47:49 2017
@@ -20,6 +20,7 @@
 package org.apache.axis2.transport.http;
 
 
+import org.apache.axiom.mime.Header;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
@@ -45,46 +46,25 @@ import javax.xml.namespace.QName;
 public abstract class HTTPSender extends AbstractHTTPSender {
 
     private static final Log log = LogFactory.getLog(HTTPSender.class);
-    /**
-     * Used to send a request via HTTP Get method
-     *
-     * @param msgContext        - The MessageContext of the message
-     * @param url               - The target URL
-     * @throws AxisFault - Thrown in case an exception occurs
-     */
-    protected abstract Request prepareGet(MessageContext msgContext, URL url)
-            throws AxisFault;
     
     /**
-     * Used to send a request via HTTP Delete Method
-     *
-     * @param msgContext        - The MessageContext of the message
-     * @param url               - The target URL
-     * @throws AxisFault - Thrown in case an exception occurs
-     */
-    protected abstract Request prepareDelete(MessageContext msgContext, URL url)
-            throws AxisFault; 
-    /**
-     * Used to send a request via HTTP Post Method
-     *
-     * @param msgContext       - The MessageContext of the message
-     * @param url              - The target URL
-     * @throws AxisFault - Thrown in case an exception occurs
-     */
-    protected abstract Request preparePost(MessageContext msgContext, URL url,
-                             AxisRequestEntity requestEntity) throws AxisFault;
-
-
-    /**
-     * Used to send a request via HTTP Put Method
+     * Start a new HTTP request.
      *
-     * @param msgContext       - The MessageContext of the message
-     * @param url              - The target URL
-     * @throws AxisFault - Thrown in case an exception occurs
+     * @param msgContext
+     *            The MessageContext of the request message
+     * @param methodName
+     *            The HTTP method name
+     * @param url
+     *            The target URL
+     * @param requestEntity
+     *            The content of the request or {@code null} if the HTTP request shouldn't have any
+     *            content (e.g. for {@code GET} requests)
+     * @throws AxisFault
+     *            Thrown in case an exception occurs
      */
-    protected abstract Request preparePut(MessageContext msgContext, URL url,
-                            AxisRequestEntity requestEntity) throws AxisFault;
-
+    protected abstract Request createRequest(MessageContext msgContext, String methodName, URL url,
+            AxisRequestEntity requestEntity) throws AxisFault;
+    
     public void send(MessageContext msgContext, URL url, String soapActionString)
             throws IOException {
 
@@ -93,28 +73,43 @@ public abstract class HTTPSender extends
 
         String httpMethod =
                 (String) msgContext.getProperty(Constants.Configuration.HTTP_METHOD);
+        if (httpMethod == null) {
+            httpMethod = Constants.Configuration.HTTP_METHOD_POST;
+        }
 
         MessageFormatter messageFormatter = MessageProcessorSelector
                 .getMessageFormatter(msgContext);
         url = messageFormatter.getTargetAddress(msgContext, format, url);
-        
-        Request request = null;
-        if ((httpMethod != null)) {
+        String contentType = messageFormatter.getContentType(msgContext, format, soapActionString);
 
-            if (Constants.Configuration.HTTP_METHOD_GET.equalsIgnoreCase(httpMethod)) {
-                request = prepareGet(msgContext, url);
-            } else if (Constants.Configuration.HTTP_METHOD_DELETE.equalsIgnoreCase(httpMethod)) {
-                request = prepareDelete(msgContext, url);
-            } else if (Constants.Configuration.HTTP_METHOD_PUT.equalsIgnoreCase(httpMethod)) {
-                request = preparePut(msgContext, url, buildRequestEntity(messageFormatter, msgContext, soapActionString));
+        HTTPAuthenticator authenticator;
+        Object obj = msgContext.getProperty(HTTPConstants.AUTHENTICATE);
+        if (obj == null) {
+            authenticator = null;
+        } else {
+            if (obj instanceof HTTPAuthenticator) {
+                authenticator = (HTTPAuthenticator) obj;
+            } else {
+                throw new AxisFault("HttpTransportProperties.Authenticator class cast exception");
             }
         }
 
-        if (request == null) {
-            request = preparePost(msgContext, url, buildRequestEntity(messageFormatter, msgContext, soapActionString));
+        AxisRequestEntity requestEntity;
+        boolean gzip;
+        if (Constants.Configuration.HTTP_METHOD_GET.equalsIgnoreCase(httpMethod)
+                || Constants.Configuration.HTTP_METHOD_DELETE.equalsIgnoreCase(httpMethod)) {
+            requestEntity = null;
+            gzip = false;
+        } else if (Constants.Configuration.HTTP_METHOD_POST.equalsIgnoreCase(httpMethod)
+                || Constants.Configuration.HTTP_METHOD_PUT.equalsIgnoreCase(httpMethod)) {
+            gzip = msgContext.isPropertyTrue(HTTPConstants.MC_GZIP_REQUEST);
+            requestEntity = new AxisRequestEntity(messageFormatter, msgContext, format,
+                    contentType, chunked, gzip, authenticator != null && authenticator.isAllowedRetry());
+        } else {
+            throw new AxisFault("Unsupported HTTP method " + httpMethod);
         }
 
-        request.setHeader(HTTPConstants.HEADER_HOST, url.getHost());
+        Request request = createRequest(msgContext, httpMethod, url, requestEntity);
 
         if (msgContext.getOptions() != null && msgContext.getOptions().isManageSession()) {
             // setting the cookie in the out path
@@ -131,8 +126,7 @@ public abstract class HTTPSender extends
             request.enableHTTP10();
         }
         
-        request.setHeader(HTTPConstants.HEADER_CONTENT_TYPE,
-                messageFormatter.getContentType(msgContext, format, soapActionString));
+        request.setHeader(HTTPConstants.HEADER_CONTENT_TYPE, contentType);
 
         String soapAction = messageFormatter.formatSOAPAction(msgContext, format, soapActionString);
 
@@ -140,18 +134,21 @@ public abstract class HTTPSender extends
             request.setHeader(HTTPConstants.HEADER_SOAP_ACTION, soapAction);
         }
 
+        if (gzip) {
+            request.setHeader(HTTPConstants.HEADER_CONTENT_ENCODING,
+                    HTTPConstants.COMPRESSION_GZIP);
+        }
+        
         // set the custom headers, if available
         addCustomHeaders(msgContext, request);
         
+        if (authenticator != null) {
+            request.enableAuthentication(authenticator);
+        }
+
         request.execute();
     }   
 
-    private AxisRequestEntity buildRequestEntity(MessageFormatter messageFormatter, MessageContext msgContext,
-            String soapActionString) {
-        return new AxisRequestEntity(messageFormatter, msgContext, format,
-                soapActionString, chunked, isAllowedRetry);
-    }
-
     private void addCustomHeaders(MessageContext msgContext, Request request) {
     
         boolean isCustomUserAgentSet = false;
@@ -194,10 +191,10 @@ public abstract class HTTPSender extends
     
             for (Object headerEntry : headerEntries) {
                 if (headerEntry instanceof Map.Entry) {
-                    NamedValue[] headers = request.getRequestHeaders();
+                    Header[] headers = request.getRequestHeaders();
     
                     boolean headerAdded = false;
-                    for (NamedValue header : headers) {
+                    for (Header header : headers) {
                         if (header.getName() != null
                                 && header.getName().equals(((Map.Entry) headerEntry).getKey())) {
                             headerAdded = true;

Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/Request.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/Request.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/Request.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/Request.java Sun Jan 22 13:47:49 2017
@@ -18,8 +18,8 @@
  */
 package org.apache.axis2.transport.http;
 
+import org.apache.axiom.mime.Header;
 import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.NamedValue;
 
 /**
  * Interface to prepare and execute an HTTP request.
@@ -28,6 +28,10 @@ public interface Request {
     void enableHTTP10();
     void setHeader(String name, String value);
     void addHeader(String name, String value);
-    NamedValue[] getRequestHeaders();
+    Header[] getRequestHeaders();
+    void enableAuthentication(HTTPAuthenticator authenticator);
     void execute() throws AxisFault;
+    int getStatusCode();
+    String getStatusText();
+    Header[] getResponseHeaders();
 }

Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/AxisRequestEntityImpl.java Sun Jan 22 13:47:49 2017
@@ -42,7 +42,7 @@ public class AxisRequestEntityImpl imple
 
     @Override
     public Header getContentType() {
-        return new BasicHeader(HTTPConstants.HEADER_CONTENT_TYPE, entity.getContentTypeAsString());
+        return new BasicHeader(HTTPConstants.HEADER_CONTENT_TYPE, entity.getContentType());
     }
 
     @Override
@@ -52,7 +52,9 @@ public class AxisRequestEntityImpl imple
 
     @Override
     public InputStream getContent() throws IOException {
-        return entity.getRequestEntityContent();
+        // Implementations are allowed to throw UnsupportedOperationException and this method is
+        // never called for outgoing requests anyway.
+        throw new UnsupportedOperationException();
     }
 
     @Override
@@ -67,7 +69,7 @@ public class AxisRequestEntityImpl imple
 
     @Override
     public void consumeContent() {
-        // TODO: Handle this correctly
+        // We don't need to do anything here.
     }
 
     @Override

Modified: axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java?rev=1779815&r1=1779814&r2=1779815&view=diff
==============================================================================
--- axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java (original)
+++ axis/axis2/java/core/branches/hermetic-tests/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java Sun Jan 22 13:47:49 2017
@@ -26,10 +26,9 @@ import org.apache.axis2.context.MessageC
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.http.AxisRequestEntity;
-import org.apache.axis2.transport.http.HTTPAuthenticator;
+import org.apache.axis2.transport.http.CommonsTransportHeaders;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HTTPSender;
-import org.apache.axis2.transport.http.HTTPTransportConstants;
 import org.apache.axis2.transport.http.Request;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
@@ -37,18 +36,8 @@ import org.apache.commons.logging.LogFac
 import org.apache.http.Header;
 import org.apache.http.HeaderElement;
 import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
 import org.apache.http.HttpResponse;
 import org.apache.http.NameValuePair;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.NTCredentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.auth.params.AuthPNames;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
 import org.apache.http.client.methods.HttpRequestBase;
 import org.apache.http.client.params.AuthPolicy;
 import org.apache.http.client.params.ClientPNames;
@@ -57,7 +46,6 @@ import org.apache.http.conn.scheme.Plain
 import org.apache.http.conn.scheme.Scheme;
 import org.apache.http.conn.scheme.SchemeRegistry;
 import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.impl.auth.NTLMSchemeFactory;
 import org.apache.http.impl.client.AbstractHttpClient;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
@@ -69,11 +57,8 @@ import org.apache.http.params.HttpParams
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URISyntaxException;
 import java.net.URL;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.zip.GZIPInputStream;
 
@@ -89,58 +74,10 @@ public class HTTPSenderImpl extends HTTP
         return httpVersion;
     }
 
-    /**
-     * Used to send a request via HTTP Get method
-     *
-     * @param msgContext        - The MessageContext of the message
-     * @param url               - The target URL
-     * @param soapActionString - The soapAction string of the request
-     * @throws org.apache.axis2.AxisFault - Thrown in case an exception occurs
-     */
-    @Override
-    protected Request prepareGet(final MessageContext msgContext, final URL url)
-            throws AxisFault {
-        return new RequestImpl(this, msgContext, url, null, new HttpGet());
-    }
-
-    /**
-     * Used to send a request via HTTP Delete Method
-     *
-     * @param msgContext        - The MessageContext of the message
-     * @param url               - The target URL
-     * @param soapActionString - The soapAction string of the request
-     * @throws org.apache.axis2.AxisFault - Thrown in case an exception occurs
-     */
-    @Override
-    protected Request prepareDelete(final MessageContext msgContext, final URL url)
-            throws AxisFault {
-        return new RequestImpl(this, msgContext, url, null, new HttpDelete());
-    }
-
-    /**
-     * Used to send a request via HTTP Post Method
-     *
-     * @param msgContext       - The MessageContext of the message
-     * @param url              - The target URL
-     * @throws org.apache.axis2.AxisFault - Thrown in case an exception occurs
-     */
-    @Override
-    protected Request preparePost(final MessageContext msgContext, final URL url, AxisRequestEntity requestEntity)
-            throws AxisFault {
-        return new RequestImpl(this, msgContext, url, requestEntity, new HttpPost());
-    }
-
-    /**
-     * Used to send a request via HTTP Put Method
-     *
-     * @param msgContext       - The MessageContext of the message
-     * @param url              - The target URL
-     * @throws org.apache.axis2.AxisFault - Thrown in case an exception occurs
-     */
     @Override
-    protected Request preparePut(final MessageContext msgContext, final URL url, AxisRequestEntity requestEntity)
-            throws AxisFault {
-        return new RequestImpl(this, msgContext, url, requestEntity, new HttpPut());
+    protected Request createRequest(MessageContext msgContext, String methodName, URL url,
+            AxisRequestEntity requestEntity) throws AxisFault {
+        return new RequestImpl(this, msgContext, methodName, url, requestEntity);
     }
 
     /**
@@ -151,22 +88,16 @@ public class HTTPSenderImpl extends HTTP
      *                   NOT!
      * @throws AxisFault if problems occur
      */
-    protected void obtainHTTPHeaderInformation(Object httpResponse, MessageContext msgContext)
+    protected void obtainHTTPHeaderInformation(Request request, HttpResponse response, MessageContext msgContext)
             throws AxisFault {
-        HttpResponse response;
-        if (httpResponse instanceof HttpResponse) {
-            response = (HttpResponse) httpResponse;
-        } else {
-            return;
-        }
         // Set RESPONSE properties onto the REQUEST message context. They will
         // need to be copied off the request context onto
         // the response context elsewhere, for example in the
         // OutInOperationClient.
-        Map transportHeaders = new HTTPTransportHeaders(response.getAllHeaders());
+        Map transportHeaders = new CommonsTransportHeaders(request.getResponseHeaders());
         msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, transportHeaders);
         msgContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE,
-                               new Integer(response.getStatusLine().getStatusCode()));
+                               new Integer(request.getStatusCode()));
         Header header = response.getFirstHeader(HTTPConstants.HEADER_CONTENT_TYPE);
 
         if (header != null) {
@@ -252,191 +183,6 @@ public class HTTPSenderImpl extends HTTP
         return cookie;
     }
 
-    protected void processResponse(HttpResponse response, MessageContext msgContext)
-            throws IOException {
-        obtainHTTPHeaderInformation(response, msgContext);
-
-        HttpEntity httpEntity = response.getEntity();
-        InputStream in = httpEntity.getContent();
-        if (in == null) {
-            throw new AxisFault(Messages.getMessage("canNotBeNull", "InputStream"));
-        }
-        Header contentEncoding = httpEntity.getContentEncoding();
-        if (contentEncoding != null) {
-            if (contentEncoding.getValue().equalsIgnoreCase(HTTPConstants.COMPRESSION_GZIP)) {
-                in = new GZIPInputStream(in);
-                // If the content-encoding is identity we can basically ignore
-                // it.
-            } else if (!"identity".equalsIgnoreCase(contentEncoding.getValue())) {
-                throw new AxisFault("HTTP :" + "unsupported content-encoding of '"
-                                    + contentEncoding.getValue() + "' found");
-            }
-        }
-
-        OperationContext opContext = msgContext.getOperationContext();
-        if (opContext != null) {
-            opContext.setProperty(MessageContext.TRANSPORT_IN, in);
-        }
-    }
-
-    /**
-     * getting host configuration to support standard http/s, proxy and NTLM
-     * support
-     *
-     * @param client    active HttpClient
-     * @param msgCtx    active MessageContext
-     * @param targetURL the target URL
-     * @return a HostConfiguration set up with proxy information
-     * @throws org.apache.axis2.AxisFault if problems occur
-     */
-    protected HttpHost getHostConfiguration(AbstractHttpClient client, MessageContext msgCtx,
-                                            URL targetURL) throws AxisFault {
-
-        boolean isAuthenticationEnabled = isAuthenticationEnabled(msgCtx);
-        int port = targetURL.getPort();
-
-        String protocol = targetURL.getProtocol();
-        if (port == -1) {
-            if (HTTPTransportConstants.PROTOCOL_HTTP.equals(protocol)) {
-                port = 80;
-            } else if (HTTPTransportConstants.PROTOCOL_HTTPS.equals(protocol)) {
-                port = 443;
-            }
-        }
-        // to see the host is a proxy and in the proxy list - available in
-        // axis2.xml
-        HttpHost hostConfig = new HttpHost(targetURL.getHost(), port, targetURL.getProtocol());
-
-        // TODO : one might need to set his own socket factory. We have to allow that case as well.
-
-        if (isAuthenticationEnabled) {
-            // Basic, Digest, NTLM and custom authentications.
-            this.setAuthenticationInfo(client, msgCtx);
-        }
-        // proxy configuration
-
-        if (HTTPProxyConfigurator.isProxyEnabled(msgCtx, targetURL)) {
-            if (log.isDebugEnabled()) {
-                log.debug("Configuring HTTP proxy.");
-            }
-            HTTPProxyConfigurator.configure(msgCtx, client);
-        }
-
-        return hostConfig;
-    }
-
-    protected boolean isAuthenticationEnabled(MessageContext msgCtx) {
-        return (msgCtx.getProperty(HTTPConstants.AUTHENTICATE) != null);
-    }
-
-    /*
-     * This will handle server Authentication, It could be either NTLM, Digest
-     * or Basic Authentication. Apart from that user can change the priory or
-     * add a custom authentication scheme.
-     */
-    protected void setAuthenticationInfo(AbstractHttpClient agent, MessageContext msgCtx)
-            throws AxisFault {
-        HTTPAuthenticator authenticator;
-        Object obj = msgCtx.getProperty(HTTPConstants.AUTHENTICATE);
-        if (obj != null) {
-            if (obj instanceof HTTPAuthenticator) {
-                authenticator = (HTTPAuthenticator) obj;
-
-                String username = authenticator.getUsername();
-                String password = authenticator.getPassword();
-                String host = authenticator.getHost();
-                String domain = authenticator.getDomain();
-
-                int port = authenticator.getPort();
-                String realm = authenticator.getRealm();
-
-                /* If retrying is available set it first */
-                isAllowedRetry = authenticator.isAllowedRetry();
-
-                Credentials creds;
-
-                // TODO : Set preemptive authentication, but its not recommended in HC 4
-
-                if (host != null) {
-                    if (domain != null) {
-                        /* Credentials for NTLM Authentication */
-                        agent.getAuthSchemes().register("ntlm",new NTLMSchemeFactory());
-                        creds = new NTCredentials(username, password, host, domain);
-                    } else {
-                        /* Credentials for Digest and Basic Authentication */
-                        creds = new UsernamePasswordCredentials(username, password);
-                    }
-                    agent.getCredentialsProvider().
-                            setCredentials(new AuthScope(host, port, realm), creds);
-                } else {
-                    if (domain != null) {
-                        /*
-                         * Credentials for NTLM Authentication when host is
-                         * ANY_HOST
-                         */
-                        agent.getAuthSchemes().register("ntlm",new NTLMSchemeFactory());
-                        creds = new NTCredentials(username, password, AuthScope.ANY_HOST, domain);
-                        agent.getCredentialsProvider().
-                                setCredentials(new AuthScope(AuthScope.ANY_HOST, port, realm),
-                                               creds);
-                    } else {
-                        /* Credentials only for Digest and Basic Authentication */
-                        creds = new UsernamePasswordCredentials(username, password);
-                        agent.getCredentialsProvider().
-                                setCredentials(new AuthScope(AuthScope.ANY), creds);
-                    }
-                }
-                /* Customizing the priority Order */
-                List schemes = authenticator.getAuthSchemes();
-                if (schemes != null && schemes.size() > 0) {
-                    List authPrefs = new ArrayList(3);
-                    for (int i = 0; i < schemes.size(); i++) {
-                        if (schemes.get(i) instanceof AuthPolicy) {
-                            authPrefs.add(schemes.get(i));
-                            continue;
-                        }
-                        String scheme = (String) schemes.get(i);
-                        authPrefs.add(authenticator.getAuthPolicyPref(scheme));
-
-                    }
-                    agent.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, authPrefs);
-                }
-
-            } else {
-                throw new AxisFault("HttpTransportProperties.Authenticator class cast exception");
-            }
-        }
-
-    }
-
-    /**
-     * Method used to copy all the common properties
-     *
-     * @param msgContext       - The messageContext of the request message
-     * @param url              - The target URL
-     * @param httpMethod       - The http method used to send the request
-     * @param httpClient       - The httpclient used to send the request
-     * @param soapActionString - The soap action atring of the request message
-     * @return MessageFormatter - The messageFormatter for the relavent request
-     *         message
-     * @throws org.apache.axis2.AxisFault - Thrown in case an exception occurs
-     */
-    protected void populateCommonProperties(MessageContext msgContext, URL url,
-                                                        HttpRequestBase httpMethod,
-                                                        AbstractHttpClient httpClient)
-            throws AxisFault {
-
-        if (isAuthenticationEnabled(msgContext)) {
-            httpMethod.getParams().setBooleanParameter(ClientPNames.HANDLE_AUTHENTICATION, true);
-        }
-
-        try {
-            httpMethod.setURI(url.toURI());
-        } catch (URISyntaxException e) {
-            log.error("Error in URI : " + url, e);
-        }
-    }
-
     /**
      * This is used to get the dynamically set time out values from the message
      * context. If the values are not available or invalid then the default