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 22:10:04 UTC
svn commit: r1779117 - in /axis/axis2/java/core/trunk/modules/transport:
http-hc3/src/main/java/org/apache/axis2/transport/http/impl/httpclient3/RequestImpl.java
http/src/org/apache/axis2/transport/http/impl/httpclient4/RequestImpl.java
Author: veithen
Date: Mon Jan 16 22:10:04 2017
New Revision: 1779117
URL: http://svn.apache.org/viewvc?rev=1779117&view=rev
Log:
Initialize HostConfiguration/HttpHost early.
Modified:
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/RequestImpl.java
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=1779117&r1=1779116&r2=1779117&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 22:10:04 2017
@@ -52,6 +52,7 @@ 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 {
this.sender = sender;
@@ -67,6 +68,12 @@ final class RequestImpl implements Reque
((EntityEnclosingMethod)method).setContentChunked(true);
}
}
+ // 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
@@ -108,7 +115,7 @@ final class RequestImpl implements Reque
}
private void executeMethod() throws IOException {
- HostConfiguration config = getHostConfiguration();
+ populateHostConfiguration();
// add compression headers if needed
if (msgContext.isPropertyTrue(HTTPConstants.MC_ACCEPT_GZIP)) {
@@ -203,7 +210,7 @@ final class RequestImpl implements Reque
* @throws AxisFault
* if problems occur
*/
- protected HostConfiguration getHostConfiguration() throws AxisFault {
+ protected void populateHostConfiguration() throws AxisFault {
boolean isAuthenticationEnabled = sender.isAuthenticationEnabled(msgContext);
int port = url.getPort();
@@ -218,13 +225,6 @@ final class RequestImpl implements Reque
}
- // 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(
@@ -251,7 +251,5 @@ final class RequestImpl implements Reque
}
HTTPProxyConfigurator.configure(msgContext, httpClient, config);
}
-
- return config;
}
}
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=1779117&r1=1779116&r2=1779117&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 22:10:04 2017
@@ -57,6 +57,7 @@ final class RequestImpl implements Reque
protected final URL url;
protected final HttpRequestBase method;
protected final AbstractHttpClient httpClient;
+ private final HttpHost httpHost;
RequestImpl(HTTPSenderImpl sender, MessageContext msgContext, URL url, AxisRequestEntity requestEntity, HttpRequestBase method) throws AxisFault {
this.sender = sender;
@@ -73,6 +74,16 @@ final class RequestImpl implements Reque
requestEntity.setChunked(sender.isChunked());
}
}
+ 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;
+ }
+ }
+ httpHost = new HttpHost(url.getHost(), port, url.getProtocol());
}
@Override
@@ -116,7 +127,7 @@ final class RequestImpl implements Reque
}
private HttpResponse executeMethod() throws IOException {
- HttpHost httpHost = getHostConfiguration();
+ populateHostConfiguration();
// add compression headers if needed
if (msgContext.isPropertyTrue(HTTPConstants.MC_ACCEPT_GZIP)) {
@@ -220,22 +231,9 @@ final class RequestImpl implements Reque
* @return a HostConfiguration set up with proxy information
* @throws org.apache.axis2.AxisFault if problems occur
*/
- private HttpHost getHostConfiguration() throws AxisFault {
+ private void populateHostConfiguration() 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.
@@ -251,7 +249,5 @@ final class RequestImpl implements Reque
}
HTTPProxyConfigurator.configure(msgContext, httpClient);
}
-
- return hostConfig;
}
}