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/16 21:21:23 UTC

svn commit: r1779105 - in /axis/axis2/java/core/trunk/modules/transport: http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/ http/src/org/apache/axis2/transport/http/impl/httpclient4/

Author: veithen
Date: Mon Jan 16 21:21:23 2017
New Revision: 1779105

URL: http://svn.apache.org/viewvc?rev=1779105&view=rev
Log:
Move getHostConfiguration to RequestImpl.

Modified:
    axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java
    axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/RequestImpl.java
    axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java
    axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RequestImpl.java

Modified: axis/axis2/java/core/trunk/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/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java?rev=1779105&r1=1779104&r2=1779105&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/HTTPSenderImpl.java Mon Jan 16 21:21:23 2017
@@ -38,7 +38,6 @@ import org.apache.axis2.transport.http.A
 import org.apache.axis2.transport.http.HTTPAuthenticator;
 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;
@@ -60,7 +59,6 @@ import org.apache.commons.httpclient.met
 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;
 
@@ -279,73 +277,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);
     }

Modified: axis/axis2/java/core/trunk/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/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/RequestImpl.java?rev=1779105&r1=1779104&r2=1779105&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/RequestImpl.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/RequestImpl.java Mon Jan 16 21:21:23 2017
@@ -28,6 +28,7 @@ import org.apache.axis2.context.Operatio
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.http.AxisRequestEntity;
 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;
@@ -39,6 +40,7 @@ import org.apache.commons.httpclient.Htt
 import org.apache.commons.httpclient.HttpVersion;
 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;
 
@@ -106,7 +108,7 @@ final class RequestImpl implements Reque
     }
 
     private void executeMethod() throws IOException {
-        HostConfiguration config = sender.getHostConfiguration(httpClient, msgContext, url);
+        HostConfiguration config = getHostConfiguration();
 
         // add compression headers if needed
         if (msgContext.isPropertyTrue(HTTPConstants.MC_ACCEPT_GZIP)) {
@@ -192,4 +194,64 @@ 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 HostConfiguration getHostConfiguration() throws AxisFault {
+
+        boolean isAuthenticationEnabled = sender.isAuthenticationEnabled(msgContext);
+        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;
+            }
+
+        }
+
+        // to see the host is a proxy and in the proxy list - available in
+        // axis2.xml
+        HostConfiguration config = httpClient.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) 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);
+        }
+
+        if (isAuthenticationEnabled) {
+            // Basic, Digest, NTLM and custom authentications.
+            sender.setAuthenticationInfo(httpClient, msgContext, config);
+        }
+        // proxy configuration
+
+        if (HTTPProxyConfigurator.isProxyEnabled(msgContext, url)) {
+            if (log.isDebugEnabled()) {
+                log.debug("Configuring HTTP proxy.");
+            }
+            HTTPProxyConfigurator.configure(msgContext, httpClient, config);
+        }
+
+        return config;
+    }
 }

Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java?rev=1779105&r1=1779104&r2=1779105&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/HTTPSenderImpl.java Mon Jan 16 21:21:23 2017
@@ -29,7 +29,6 @@ import org.apache.axis2.transport.http.A
 import org.apache.axis2.transport.http.HTTPAuthenticator;
 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,7 +36,6 @@ 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;
@@ -279,52 +277,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 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);
     }

Modified: axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RequestImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RequestImpl.java?rev=1779105&r1=1779104&r2=1779105&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RequestImpl.java (original)
+++ axis/axis2/java/core/trunk/modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RequestImpl.java Mon Jan 16 21:21:23 2017
@@ -28,6 +28,7 @@ import org.apache.axis2.context.Operatio
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.transport.http.AxisRequestEntity;
 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.logging.Log;
@@ -115,7 +116,7 @@ final class RequestImpl implements Reque
     }
 
     private HttpResponse executeMethod() throws IOException {
-        HttpHost httpHost = sender.getHostConfiguration(httpClient, msgContext, url);
+        HttpHost httpHost = getHostConfiguration();
 
         // add compression headers if needed
         if (msgContext.isPropertyTrue(HTTPConstants.MC_ACCEPT_GZIP)) {
@@ -211,4 +212,46 @@ final class RequestImpl implements Reque
             }
         }
     }
+
+    /**
+     * getting host configuration to support standard http/s, proxy and NTLM
+     * support
+     *
+     * @return a HostConfiguration set up with proxy information
+     * @throws org.apache.axis2.AxisFault if problems occur
+     */
+    private HttpHost getHostConfiguration() throws AxisFault {
+
+        boolean isAuthenticationEnabled = sender.isAuthenticationEnabled(msgContext);
+        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;
+            }
+        }
+        // to see the host is a proxy and in the proxy list - available in
+        // axis2.xml
+        HttpHost hostConfig = new HttpHost(url.getHost(), port, url.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.
+            sender.setAuthenticationInfo(httpClient, msgContext);
+        }
+        // proxy configuration
+
+        if (HTTPProxyConfigurator.isProxyEnabled(msgContext, url)) {
+            if (log.isDebugEnabled()) {
+                log.debug("Configuring HTTP proxy.");
+            }
+            HTTPProxyConfigurator.configure(msgContext, httpClient);
+        }
+
+        return hostConfig;
+    }
 }