diff --git a/fine-httpcomponents/http-client/httpclient-win/src/main/java/com/fr/third/org/apache/http/impl/auth/win/WindowsCredentialsProvider.java b/fine-httpcomponents/http-client/httpclient-win/src/main/java/com/fr/third/org/apache/http/impl/auth/win/WindowsCredentialsProvider.java
index f3db59e81..1023d8fa8 100644
--- a/fine-httpcomponents/http-client/httpclient-win/src/main/java/com/fr/third/org/apache/http/impl/auth/win/WindowsCredentialsProvider.java
+++ b/fine-httpcomponents/http-client/httpclient-win/src/main/java/com/fr/third/org/apache/http/impl/auth/win/WindowsCredentialsProvider.java
@@ -35,8 +35,8 @@ import com.fr.third.org.apache.http.client.config.AuthSchemes;
import com.fr.third.org.apache.http.util.Args;
/**
- * {@link CredentialsProvider} implementation that always returns
- * {@link CurrentWindowsCredentials} instance to NTLM
+ * {@link com.fr.third.org.apache.http.client.CredentialsProvider} implementation that always returns
+ * {@link com.fr.third.org.apache.http.impl.auth.win.CurrentWindowsCredentials} instance to NTLM
* and SPNego authentication challenges.
*
* EXPERIMENTAL
diff --git a/fine-httpcomponents/http-client/httpclient-win/src/main/java/com/fr/third/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java b/fine-httpcomponents/http-client/httpclient-win/src/main/java/com/fr/third/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java
index 18aad9731..6c02aab7f 100644
--- a/fine-httpcomponents/http-client/httpclient-win/src/main/java/com/fr/third/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java
+++ b/fine-httpcomponents/http-client/httpclient-win/src/main/java/com/fr/third/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java
@@ -26,6 +26,15 @@
*/
package com.fr.third.org.apache.http.impl.auth.win;
+import com.sun.jna.platform.win32.Secur32;
+import com.sun.jna.platform.win32.Sspi;
+import com.sun.jna.platform.win32.Sspi.CredHandle;
+import com.sun.jna.platform.win32.Sspi.CtxtHandle;
+import com.sun.jna.platform.win32.Sspi.SecBufferDesc;
+import com.sun.jna.platform.win32.Sspi.TimeStamp;
+import com.sun.jna.platform.win32.Win32Exception;
+import com.sun.jna.platform.win32.WinError;
+import com.sun.jna.ptr.IntByReference;
import com.fr.third.org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -45,16 +54,6 @@ import com.fr.third.org.apache.http.message.BufferedHeader;
import com.fr.third.org.apache.http.protocol.HttpContext;
import com.fr.third.org.apache.http.util.CharArrayBuffer;
-import com.sun.jna.platform.win32.Secur32;
-import com.sun.jna.platform.win32.Sspi;
-import com.sun.jna.platform.win32.Sspi.CredHandle;
-import com.sun.jna.platform.win32.Sspi.CtxtHandle;
-import com.sun.jna.platform.win32.Sspi.SecBufferDesc;
-import com.sun.jna.platform.win32.Sspi.TimeStamp;
-import com.sun.jna.platform.win32.Win32Exception;
-import com.sun.jna.platform.win32.WinError;
-import com.sun.jna.ptr.IntByReference;
-
/**
* Auth scheme that makes use of JNA to implement Negotiate and NTLM on Windows Platforms.
*
@@ -241,6 +240,15 @@ public class WindowsNegotiateScheme extends AuthSchemeBase {
final String spn;
if (this.servicePrincipalName != null) {
spn = this.servicePrincipalName;
+ } else if(isProxy()){
+ final HttpClientContext clientContext = HttpClientContext.adapt(context);
+ final RouteInfo route = clientContext.getHttpRoute();
+ if (route != null) {
+ spn = "HTTP/" + route.getProxyHost().getHostName();
+ } else {
+ // Should not happen
+ spn = null;
+ }
} else {
final HttpClientContext clientContext = HttpClientContext.adapt(context);
final HttpHost target = clientContext.getTargetHost();
@@ -296,6 +304,9 @@ public class WindowsNegotiateScheme extends AuthSchemeBase {
return !continueNeeded;
}
+ /**
+ * @deprecated Use {@link #authenticate(Credentials, HttpRequest, HttpContext)}
+ */
@Override
@Deprecated
public Header authenticate(
diff --git a/fine-httpcomponents/http-client/httpclient-win/src/main/java/com/fr/third/org/apache/http/impl/client/WinHttpClients.java b/fine-httpcomponents/http-client/httpclient-win/src/main/java/com/fr/third/org/apache/http/impl/client/WinHttpClients.java
index 383d367b2..d299f732d 100644
--- a/fine-httpcomponents/http-client/httpclient-win/src/main/java/com/fr/third/org/apache/http/impl/client/WinHttpClients.java
+++ b/fine-httpcomponents/http-client/httpclient-win/src/main/java/com/fr/third/org/apache/http/impl/client/WinHttpClients.java
@@ -28,6 +28,7 @@ package com.fr.third.org.apache.http.impl.client;
import java.util.Locale;
+import com.sun.jna.platform.win32.Sspi;
import com.fr.third.org.apache.http.auth.AuthSchemeProvider;
import com.fr.third.org.apache.http.client.CredentialsProvider;
import com.fr.third.org.apache.http.client.config.AuthSchemes;
@@ -35,15 +36,10 @@ import com.fr.third.org.apache.http.config.Registry;
import com.fr.third.org.apache.http.config.RegistryBuilder;
import com.fr.third.org.apache.http.impl.auth.BasicSchemeFactory;
import com.fr.third.org.apache.http.impl.auth.DigestSchemeFactory;
-import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
-import com.fr.third.org.apache.http.impl.client.HttpClientBuilder;
-import com.fr.third.org.apache.http.impl.client.SystemDefaultCredentialsProvider;
import com.fr.third.org.apache.http.impl.auth.win.WindowsCredentialsProvider;
import com.fr.third.org.apache.http.impl.auth.win.WindowsNTLMSchemeFactory;
import com.fr.third.org.apache.http.impl.auth.win.WindowsNegotiateSchemeFactory;
-import com.sun.jna.platform.win32.Sspi;
-
/**
* Factory methods for {@link CloseableHttpClient} instances configured to use integrated
* Windows authentication by default.
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/auth/params/AuthParamBean.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/auth/params/AuthParamBean.java
index f84af3caf..fb2254eb5 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/auth/params/AuthParamBean.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/auth/params/AuthParamBean.java
@@ -27,8 +27,6 @@
package com.fr.third.org.apache.http.auth.params;
-import com.fr.third.org.apache.http.auth.AuthSchemeProvider;
-import com.fr.third.org.apache.http.client.config.RequestConfig;
import com.fr.third.org.apache.http.params.HttpAbstractParamBean;
import com.fr.third.org.apache.http.params.HttpParams;
@@ -39,9 +37,9 @@ import com.fr.third.org.apache.http.params.HttpParams;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig}
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.client.config.RequestConfig}
* and constructor parameters of
- * {@link AuthSchemeProvider}s.
+ * {@link com.fr.third.org.apache.http.auth.AuthSchemeProvider}s.
*/
@Deprecated
public class AuthParamBean extends HttpAbstractParamBean {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/auth/params/AuthParams.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/auth/params/AuthParams.java
index c9c3bc519..ca59c0d9e 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/auth/params/AuthParams.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/auth/params/AuthParams.java
@@ -29,10 +29,6 @@ package com.fr.third.org.apache.http.auth.params;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.auth.AuthSchemeProvider;
-import com.fr.third.org.apache.http.auth.Credentials;
-import com.fr.third.org.apache.http.auth.params.AuthPNames;
-import com.fr.third.org.apache.http.client.config.RequestConfig;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.protocol.HTTP;
import com.fr.third.org.apache.http.util.Args;
@@ -43,9 +39,9 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig}
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.client.config.RequestConfig}
* and constructor parameters of
- * {@link AuthSchemeProvider}s.
+ * {@link com.fr.third.org.apache.http.auth.AuthSchemeProvider}s.
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE)
@Deprecated
@@ -57,7 +53,7 @@ public final class AuthParams {
/**
* Obtains the charset for encoding
- * {@link Credentials}.If not configured,
+ * {@link com.fr.third.org.apache.http.auth.Credentials}.If not configured,
* {@link HTTP#DEFAULT_PROTOCOL_CHARSET}is used instead.
*
* @return The charset
@@ -75,7 +71,7 @@ public final class AuthParams {
/**
* Sets the charset to be used when encoding
- * {@link Credentials}.
+ * {@link com.fr.third.org.apache.http.auth.Credentials}.
*
* @param charset The charset
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/AuthenticationHandler.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/AuthenticationHandler.java
index c4e73fa5a..c58b42575 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/AuthenticationHandler.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/AuthenticationHandler.java
@@ -34,7 +34,6 @@ import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.auth.AuthScheme;
import com.fr.third.org.apache.http.auth.AuthenticationException;
import com.fr.third.org.apache.http.auth.MalformedChallengeException;
-import com.fr.third.org.apache.http.client.AuthenticationStrategy;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/RedirectHandler.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/RedirectHandler.java
index ab51e9ad5..fcfca7d4f 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/RedirectHandler.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/RedirectHandler.java
@@ -31,7 +31,6 @@ import java.net.URI;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.ProtocolException;
-import com.fr.third.org.apache.http.client.RedirectStrategy;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/AuthPolicy.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/AuthPolicy.java
index 3b1a85ba6..102c1cb48 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/AuthPolicy.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/AuthPolicy.java
@@ -27,14 +27,12 @@
package com.fr.third.org.apache.http.client.params;
-import com.fr.third.org.apache.http.client.config.AuthSchemes;
-
/**
* Standard authentication schemes supported by HttpClient.
*
* @since 4.0
*
- * @deprecated (4.3) use {@link AuthSchemes}.
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.client.config.AuthSchemes}.
*/
@Deprecated
public final class AuthPolicy {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/ClientParamBean.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/ClientParamBean.java
index d75b438cf..e9c2e139e 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/ClientParamBean.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/ClientParamBean.java
@@ -31,8 +31,6 @@ import java.util.Collection;
import com.fr.third.org.apache.http.Header;
import com.fr.third.org.apache.http.HttpHost;
-import com.fr.third.org.apache.http.client.config.RequestConfig;
-import com.fr.third.org.apache.http.client.params.ClientPNames;
import com.fr.third.org.apache.http.params.HttpAbstractParamBean;
import com.fr.third.org.apache.http.params.HttpParams;
@@ -43,7 +41,7 @@ import com.fr.third.org.apache.http.params.HttpParams;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig}.
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.client.config.RequestConfig}.
*/
@Deprecated
public class ClientParamBean extends HttpAbstractParamBean {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/CookiePolicy.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/CookiePolicy.java
index a1b7dba48..3ee7d1cea 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/CookiePolicy.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/CookiePolicy.java
@@ -27,14 +27,12 @@
package com.fr.third.org.apache.http.client.params;
-import com.fr.third.org.apache.http.client.config.CookieSpecs;
-
/**
* Standard cookie specifications supported by HttpClient.
*
* @since 4.0
*
- * @deprecated (4.3) use {@link CookieSpecs}.
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.client.config.CookieSpecs}.
*/
@Deprecated
public final class CookiePolicy {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/HttpClientParams.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/HttpClientParams.java
index a1aa5ea65..b6b98cf88 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/HttpClientParams.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/params/HttpClientParams.java
@@ -26,7 +26,6 @@
*/
package com.fr.third.org.apache.http.client.params;
-import com.fr.third.org.apache.http.client.config.RequestConfig;
import com.fr.third.org.apache.http.params.HttpConnectionParams;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
@@ -36,7 +35,7 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig}
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.client.config.RequestConfig}
*/
@Deprecated
public class HttpClientParams {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/ClientContext.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/ClientContext.java
index 631b5abba..5f0b072eb 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/ClientContext.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/ClientContext.java
@@ -27,23 +27,8 @@
package com.fr.third.org.apache.http.client.protocol;
-import com.fr.third.org.apache.http.auth.AuthSchemeRegistry;
-import com.fr.third.org.apache.http.auth.AuthState;
-import com.fr.third.org.apache.http.client.AuthCache;
-import com.fr.third.org.apache.http.client.CookieStore;
-import com.fr.third.org.apache.http.client.CredentialsProvider;
-import com.fr.third.org.apache.http.client.config.RequestConfig;
-import com.fr.third.org.apache.http.client.protocol.HttpClientContext;
-import com.fr.third.org.apache.http.config.Lookup;
-import com.fr.third.org.apache.http.conn.routing.RouteInfo;
-import com.fr.third.org.apache.http.conn.scheme.Scheme;
-import com.fr.third.org.apache.http.cookie.CookieOrigin;
-import com.fr.third.org.apache.http.cookie.CookieSpec;
-import com.fr.third.org.apache.http.cookie.CookieSpecRegistry;
-import com.fr.third.org.apache.http.protocol.HttpContext;
-
/**
- * {@link HttpContext} attribute names for
+ * {@link com.fr.third.org.apache.http.protocol.HttpContext} attribute names for
* client side HTTP protocol processing.
*
* @since 4.0
@@ -54,7 +39,7 @@ import com.fr.third.org.apache.http.protocol.HttpContext;
public interface ClientContext {
/**
- * Attribute name of a {@link RouteInfo}
+ * Attribute name of a {@link com.fr.third.org.apache.http.conn.routing.RouteInfo}
* object that represents the actual connection route.
*
* @since 4.3
@@ -62,82 +47,77 @@ public interface ClientContext {
public static final String ROUTE = "http.route";
/**
- * Attribute name of a {@link Scheme}
+ * Attribute name of a {@link com.fr.third.org.apache.http.conn.scheme.Scheme}
* object that represents the actual protocol scheme registry.
*/
- @Deprecated
public static final String SCHEME_REGISTRY = "http.scheme-registry";
/**
- * Attribute name of a {@link Lookup} object that represents
- * the actual {@link CookieSpecRegistry} registry.
+ * Attribute name of a {@link com.fr.third.org.apache.http.config.Lookup} object that represents
+ * the actual {@link com.fr.third.org.apache.http.cookie.CookieSpecRegistry} registry.
*/
public static final String COOKIESPEC_REGISTRY = "http.cookiespec-registry";
/**
- * Attribute name of a {@link CookieSpec}
+ * Attribute name of a {@link com.fr.third.org.apache.http.cookie.CookieSpec}
* object that represents the actual cookie specification.
*/
public static final String COOKIE_SPEC = "http.cookie-spec";
/**
- * Attribute name of a {@link CookieOrigin}
+ * Attribute name of a {@link com.fr.third.org.apache.http.cookie.CookieOrigin}
* object that represents the actual details of the origin server.
*/
public static final String COOKIE_ORIGIN = "http.cookie-origin";
/**
- * Attribute name of a {@link CookieStore}
+ * Attribute name of a {@link com.fr.third.org.apache.http.client.CookieStore}
* object that represents the actual cookie store.
*/
public static final String COOKIE_STORE = "http.cookie-store";
/**
- * Attribute name of a {@link CredentialsProvider}
+ * Attribute name of a {@link com.fr.third.org.apache.http.client.CredentialsProvider}
* object that represents the actual credentials provider.
*/
public static final String CREDS_PROVIDER = "http.auth.credentials-provider";
/**
- * Attribute name of a {@link AuthCache} object
+ * Attribute name of a {@link com.fr.third.org.apache.http.client.AuthCache} object
* that represents the auth scheme cache.
*/
public static final String AUTH_CACHE = "http.auth.auth-cache";
/**
- * Attribute name of a {@link AuthState}
+ * Attribute name of a {@link com.fr.third.org.apache.http.auth.AuthState}
* object that represents the actual target authentication state.
*/
public static final String TARGET_AUTH_STATE = "http.auth.target-scope";
/**
- * Attribute name of a {@link AuthState}
+ * Attribute name of a {@link com.fr.third.org.apache.http.auth.AuthState}
* object that represents the actual proxy authentication state.
*/
public static final String PROXY_AUTH_STATE = "http.auth.proxy-scope";
- /**
- * @deprecated (4.1) do not use
- */
- @Deprecated
public static final String AUTH_SCHEME_PREF = "http.auth.scheme-pref";
/**
- * Attribute name of a {@link java.lang.Object} object that represents
+ * Attribute name of a {@link Object} object that represents
* the actual user identity such as user {@link java.security.Principal}.
*/
public static final String USER_TOKEN = "http.user-token";
/**
- * Attribute name of a {@link Lookup} object that represents
- * the actual {@link AuthSchemeRegistry} registry.
+ * Attribute name of a {@link com.fr.third.org.apache.http.config.Lookup} object that represents
+ * the actual {@link com.fr.third.org.apache.http.auth.AuthSchemeRegistry} registry.
*/
public static final String AUTHSCHEME_REGISTRY = "http.authscheme-registry";
public static final String SOCKET_FACTORY_REGISTRY = "http.socket-factory-registry";
/**
- * Attribute name of a {@link RequestConfig} object that
+ * Attribute name of a {@link com.fr.third.org.apache.http.client.config.RequestConfig} object that
* represents the actual request configuration.
*
* @since 4.3
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/RequestAuthenticationBase.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/RequestAuthenticationBase.java
index 1b1ed81a3..37d9a7a40 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/RequestAuthenticationBase.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/RequestAuthenticationBase.java
@@ -43,6 +43,9 @@ import com.fr.third.org.apache.http.auth.Credentials;
import com.fr.third.org.apache.http.protocol.HttpContext;
import com.fr.third.org.apache.http.util.Asserts;
+/**
+ * @deprecated Do not use.
+ */
@Deprecated
abstract class RequestAuthenticationBase implements HttpRequestInterceptor {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/RequestProxyAuthentication.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/RequestProxyAuthentication.java
index 5bd077382..065740056 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/RequestProxyAuthentication.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/RequestProxyAuthentication.java
@@ -37,7 +37,6 @@ import com.fr.third.org.apache.http.auth.AUTH;
import com.fr.third.org.apache.http.auth.AuthState;
import com.fr.third.org.apache.http.conn.HttpRoutedConnection;
import com.fr.third.org.apache.http.conn.routing.HttpRoute;
-import com.fr.third.org.apache.http.impl.auth.HttpAuthenticator;
import com.fr.third.org.apache.http.protocol.ExecutionContext;
import com.fr.third.org.apache.http.protocol.HttpContext;
import com.fr.third.org.apache.http.util.Args;
@@ -48,7 +47,7 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link HttpAuthenticator}.
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.impl.auth.HttpAuthenticator}.
*/
@Deprecated
@Contract(threading = ThreadingBehavior.IMMUTABLE)
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/RequestTargetAuthentication.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/RequestTargetAuthentication.java
index 6c2aad289..c943cf45f 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/RequestTargetAuthentication.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/RequestTargetAuthentication.java
@@ -35,7 +35,6 @@ import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.auth.AUTH;
import com.fr.third.org.apache.http.auth.AuthState;
-import com.fr.third.org.apache.http.impl.auth.HttpAuthenticator;
import com.fr.third.org.apache.http.protocol.HttpContext;
import com.fr.third.org.apache.http.util.Args;
@@ -45,7 +44,7 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link HttpAuthenticator}.
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.impl.auth.HttpAuthenticator}.
*/
@Deprecated
@Contract(threading = ThreadingBehavior.IMMUTABLE)
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/ResponseAuthCache.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/ResponseAuthCache.java
index d65f9cf1b..f660c5d32 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/ResponseAuthCache.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/client/protocol/ResponseAuthCache.java
@@ -29,7 +29,6 @@ package com.fr.third.org.apache.http.client.protocol;
import java.io.IOException;
-import com.fr.third.org.apache.http.client.AuthenticationStrategy;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.fr.third.org.apache.http.HttpException;
@@ -57,7 +56,7 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.1
*
- * @deprecated (4.2) use {@link AuthenticationStrategy}
+ * @deprecated (4.2) use {@link com.fr.third.org.apache.http.client.AuthenticationStrategy}
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE)
@Deprecated
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/BasicEofSensorWatcher.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/BasicEofSensorWatcher.java
index 20666ea96..a187051f4 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/BasicEofSensorWatcher.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/BasicEofSensorWatcher.java
@@ -29,8 +29,6 @@ package com.fr.third.org.apache.http.conn;
import java.io.IOException;
import java.io.InputStream;
-import com.fr.third.org.apache.http.conn.EofSensorWatcher;
-import com.fr.third.org.apache.http.conn.ManagedClientConnection;
import com.fr.third.org.apache.http.util.Args;
/**
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/BasicManagedEntity.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/BasicManagedEntity.java
index 2deccdf24..e8dd471ba 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/BasicManagedEntity.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/BasicManagedEntity.java
@@ -32,10 +32,6 @@ import java.io.OutputStream;
import java.net.SocketException;
import com.fr.third.org.apache.http.HttpEntity;
-import com.fr.third.org.apache.http.conn.ConnectionReleaseTrigger;
-import com.fr.third.org.apache.http.conn.EofSensorInputStream;
-import com.fr.third.org.apache.http.conn.EofSensorWatcher;
-import com.fr.third.org.apache.http.conn.ManagedClientConnection;
import com.fr.third.org.apache.http.entity.HttpEntityWrapper;
import com.fr.third.org.apache.http.util.Args;
import com.fr.third.org.apache.http.util.EntityUtils;
@@ -117,8 +113,8 @@ public class BasicManagedEntity extends HttpEntityWrapper
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- super.writeTo(outstream);
+ public void writeTo(final OutputStream outStream) throws IOException {
+ super.writeTo(outStream);
ensureConsumed();
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ClientConnectionManagerFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ClientConnectionManagerFactory.java
index cc38decbd..9ecfcae39 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ClientConnectionManagerFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ClientConnectionManagerFactory.java
@@ -27,8 +27,6 @@
package com.fr.third.org.apache.http.conn;
-import com.fr.third.org.apache.http.conn.ClientConnectionManager;
-import com.fr.third.org.apache.http.conn.HttpClientConnectionManager;
import com.fr.third.org.apache.http.conn.scheme.SchemeRegistry;
import com.fr.third.org.apache.http.params.HttpParams;
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ClientConnectionOperator.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ClientConnectionOperator.java
index 344ebe1dd..37cc8a9f4 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ClientConnectionOperator.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ClientConnectionOperator.java
@@ -31,7 +31,6 @@ import java.io.IOException;
import java.net.InetAddress;
import com.fr.third.org.apache.http.HttpHost;
-import com.fr.third.org.apache.http.conn.scheme.SchemeSocketFactory;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.protocol.HttpContext;
@@ -39,7 +38,7 @@ import com.fr.third.org.apache.http.protocol.HttpContext;
* ClientConnectionOperator represents a strategy for creating
* {@link OperatedClientConnection} instances and updating the underlying
* {@link java.net.Socket} of those objects. Implementations will most
- * likely make use of {@link SchemeSocketFactory}s
+ * likely make use of {@link com.fr.third.org.apache.http.conn.scheme.SchemeSocketFactory}s
* to create {@link java.net.Socket} instances.
*
* The methods in this interface allow the creation of plain and layered
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/MultihomePlainSocketFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/MultihomePlainSocketFactory.java
index c34789a7e..3cc07d994 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/MultihomePlainSocketFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/MultihomePlainSocketFactory.java
@@ -39,7 +39,6 @@ import java.util.List;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.conn.scheme.SchemeSocketFactory;
import com.fr.third.org.apache.http.conn.scheme.SocketFactory;
import com.fr.third.org.apache.http.params.HttpConnectionParams;
import com.fr.third.org.apache.http.params.HttpParams;
@@ -56,7 +55,7 @@ import com.fr.third.org.apache.http.util.Asserts;
* @since 4.0
*
* @deprecated (4.1) Do not use. For multihome support socket factories must implement
- * {@link SchemeSocketFactory} interface.
+ * {@link com.fr.third.org.apache.http.conn.scheme.SchemeSocketFactory} interface.
*/
@Deprecated
@Contract(threading = ThreadingBehavior.IMMUTABLE)
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/OperatedClientConnection.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/OperatedClientConnection.java
index c535a1e4c..ec69ed6b3 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/OperatedClientConnection.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/OperatedClientConnection.java
@@ -31,7 +31,6 @@ import java.io.IOException;
import java.net.Socket;
import com.fr.third.org.apache.http.HttpClientConnection;
-import com.fr.third.org.apache.http.HttpConnection;
import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.HttpInetConnection;
import com.fr.third.org.apache.http.params.HttpParams;
@@ -91,7 +90,7 @@ public interface OperatedClientConnection extends HttpClientConnection, HttpInet
* By calling this method, the connection can be re-initialized
* with a new Socket instance before {@link #openCompleted} is called.
* This enabled the connection to close that socket if
- * {@link HttpConnection#shutdown shutdown}
+ * {@link com.fr.third.org.apache.http.HttpConnection#shutdown shutdown}
* is called before it is fully open. Closing an unconnected socket
* will interrupt a thread that is blocked on the connect.
* Otherwise, that thread will either time out on the connect,
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnConnectionParamBean.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnConnectionParamBean.java
index 67fd1d01f..e684c0d3a 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnConnectionParamBean.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnConnectionParamBean.java
@@ -27,8 +27,6 @@
package com.fr.third.org.apache.http.conn.params;
-import com.fr.third.org.apache.http.conn.params.ConnConnectionPNames;
-import com.fr.third.org.apache.http.impl.conn.DefaultHttpResponseParser;
import com.fr.third.org.apache.http.params.HttpAbstractParamBean;
import com.fr.third.org.apache.http.params.HttpParams;
@@ -40,7 +38,7 @@ import com.fr.third.org.apache.http.params.HttpParams;
* @since 4.0
*
* @deprecated (4.1) use custom {@link
- * DefaultHttpResponseParser} implementation.
+ * com.fr.third.org.apache.http.impl.conn.DefaultHttpResponseParser} implementation.
*/
@Deprecated
public class ConnConnectionParamBean extends HttpAbstractParamBean {
@@ -51,7 +49,7 @@ public class ConnConnectionParamBean extends HttpAbstractParamBean {
/**
* @deprecated (4.2) Use custom {@link
- * DefaultHttpResponseParser} implementation
+ * com.fr.third.org.apache.http.impl.conn.DefaultHttpResponseParser} implementation
*/
@Deprecated
public void setMaxStatusLineGarbage (final int maxStatusLineGarbage) {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnManagerParams.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnManagerParams.java
index 324d6eb88..0dcc5a10e 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnManagerParams.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnManagerParams.java
@@ -28,9 +28,6 @@ package com.fr.third.org.apache.http.conn.params;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.conn.ClientConnectionManager;
-import com.fr.third.org.apache.http.conn.ManagedClientConnection;
-import com.fr.third.org.apache.http.params.HttpConnectionParams;
import com.fr.third.org.apache.http.conn.routing.HttpRoute;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
@@ -54,13 +51,13 @@ public final class ConnManagerParams implements ConnManagerPNames {
/**
* Returns the timeout in milliseconds used when retrieving a
- * {@link ManagedClientConnection} from the
- * {@link ClientConnectionManager}.
+ * {@link com.fr.third.org.apache.http.conn.ManagedClientConnection} from the
+ * {@link com.fr.third.org.apache.http.conn.ClientConnectionManager}.
*
* @return timeout in milliseconds.
*
* @deprecated (4.1) use {@link
- * HttpConnectionParams#getConnectionTimeout(HttpParams)}
+ * com.fr.third.org.apache.http.params.HttpConnectionParams#getConnectionTimeout(HttpParams)}
*/
@Deprecated
public static long getTimeout(final HttpParams params) {
@@ -70,13 +67,13 @@ public final class ConnManagerParams implements ConnManagerPNames {
/**
* Sets the timeout in milliseconds used when retrieving a
- * {@link ManagedClientConnection} from the
- * {@link ClientConnectionManager}.
+ * {@link com.fr.third.org.apache.http.conn.ManagedClientConnection} from the
+ * {@link com.fr.third.org.apache.http.conn.ClientConnectionManager}.
*
* @param timeout the timeout in milliseconds
*
* @deprecated (4.1) use {@link
- * HttpConnectionParams#setConnectionTimeout(HttpParams, int)}
+ * com.fr.third.org.apache.http.params.HttpConnectionParams#setConnectionTimeout(HttpParams, int)}
*/
@Deprecated
public static void setTimeout(final HttpParams params, final long timeout) {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnPerRoute.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnPerRoute.java
index ba0950173..30c9ba512 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnPerRoute.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnPerRoute.java
@@ -26,13 +26,12 @@
*/
package com.fr.third.org.apache.http.conn.params;
-import com.fr.third.org.apache.http.conn.ClientConnectionManager;
import com.fr.third.org.apache.http.conn.routing.HttpRoute;
/**
* This interface is intended for looking up maximum number of connections
* allowed for a given route. This class can be used by pooling
- * {@link ClientConnectionManager connection managers} for
+ * {@link com.fr.third.org.apache.http.conn.ClientConnectionManager connection managers} for
* a fine-grained control of connections on a per route basis.
*
* @since 4.0
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnPerRouteBean.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnPerRouteBean.java
index 26253631e..6dbf1fdd5 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnPerRouteBean.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnPerRouteBean.java
@@ -31,20 +31,18 @@ import java.util.concurrent.ConcurrentHashMap;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.conn.ClientConnectionManager;
-import com.fr.third.org.apache.http.pool.ConnPoolControl;
import com.fr.third.org.apache.http.conn.routing.HttpRoute;
import com.fr.third.org.apache.http.util.Args;
/**
* This class maintains a map of HTTP routes to maximum number of connections allowed
* for those routes. This class can be used by pooling
- * {@link ClientConnectionManager connection managers} for
+ * {@link com.fr.third.org.apache.http.conn.ClientConnectionManager connection managers} for
* a fine-grained control of connections on a per route basis.
*
* @since 4.0
*
- * @deprecated (4.2) use {@link ConnPoolControl}
+ * @deprecated (4.2) use {@link com.fr.third.org.apache.http.pool.ConnPoolControl}
*/
@Deprecated
@Contract(threading = ThreadingBehavior.SAFE)
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnRouteParamBean.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnRouteParamBean.java
index 4d2d6a6ca..636dff95e 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnRouteParamBean.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnRouteParamBean.java
@@ -30,8 +30,6 @@ package com.fr.third.org.apache.http.conn.params;
import java.net.InetAddress;
import com.fr.third.org.apache.http.HttpHost;
-import com.fr.third.org.apache.http.client.config.RequestConfig;
-import com.fr.third.org.apache.http.conn.params.ConnRoutePNames;
import com.fr.third.org.apache.http.conn.routing.HttpRoute;
import com.fr.third.org.apache.http.params.HttpAbstractParamBean;
import com.fr.third.org.apache.http.params.HttpParams;
@@ -43,7 +41,7 @@ import com.fr.third.org.apache.http.params.HttpParams;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig}.
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.client.config.RequestConfig}.
*/
@Deprecated
public class ConnRouteParamBean extends HttpAbstractParamBean {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnRouteParams.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnRouteParams.java
index f8d41e173..82e462d02 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnRouteParams.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/params/ConnRouteParams.java
@@ -31,8 +31,6 @@ import java.net.InetAddress;
import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.client.config.RequestConfig;
-import com.fr.third.org.apache.http.conn.params.ConnRoutePNames;
import com.fr.third.org.apache.http.conn.routing.HttpRoute;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
@@ -43,7 +41,7 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig}.
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.client.config.RequestConfig}.
*/
@Deprecated
@Contract(threading = ThreadingBehavior.IMMUTABLE)
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/scheme/PlainSocketFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/scheme/PlainSocketFactory.java
index 47ddd3fbd..9d8b888bc 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/scheme/PlainSocketFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/scheme/PlainSocketFactory.java
@@ -36,8 +36,6 @@ import java.net.UnknownHostException;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.conn.DnsResolver;
-import com.fr.third.org.apache.http.conn.socket.PlainConnectionSocketFactory;
import com.fr.third.org.apache.http.conn.ConnectTimeoutException;
import com.fr.third.org.apache.http.params.HttpConnectionParams;
import com.fr.third.org.apache.http.params.HttpParams;
@@ -48,7 +46,7 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link PlainConnectionSocketFactory}
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.conn.socket.PlainConnectionSocketFactory}
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE)
@Deprecated
@@ -66,7 +64,7 @@ public class PlainSocketFactory implements SocketFactory, SchemeSocketFactory {
}
/**
- * @deprecated (4.1) use {@link DnsResolver}
+ * @deprecated (4.1) use {@link com.fr.third.org.apache.http.conn.DnsResolver}
*/
@Deprecated
public PlainSocketFactory(final HostNameResolver nameResolver) {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ssl/SSLContexts.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ssl/SSLContexts.java
index c15e7b5db..aa24feeec 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ssl/SSLContexts.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ssl/SSLContexts.java
@@ -27,11 +27,10 @@
package com.fr.third.org.apache.http.conn.ssl;
+import javax.net.ssl.SSLContext;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
-import javax.net.ssl.SSLContext;
-
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ssl/SSLSocketFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ssl/SSLSocketFactory.java
index a999ca406..f8bc92e0a 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ssl/SSLSocketFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/conn/ssl/SSLSocketFactory.java
@@ -31,6 +31,7 @@ import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
+import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.KeyStore;
@@ -501,7 +502,7 @@ public class SSLSocketFactory implements LayeredConnectionSocketFactory, SchemeL
* (before the SSL handshake happens).
*
* The default implementation is a no-op, but could be overridden to, e.g.,
- * call {@link SSLSocket#setEnabledCipherSuites(java.lang.String[])}.
+ * call {@link SSLSocket#setEnabledCipherSuites(String[])}.
* @throws IOException (only if overridden)
*
* @since 4.2
@@ -540,12 +541,8 @@ public class SSLSocketFactory implements LayeredConnectionSocketFactory, SchemeL
}
try {
sock.connect(remoteAddress, connectTimeout);
- } catch (final IOException ex) {
- try {
- sock.close();
- } catch (final IOException ignore) {
- }
- throw ex;
+ } catch (final SocketTimeoutException ex) {
+ throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out");
}
// Setup SSL layering if necessary
if (sock instanceof SSLSocket) {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/cookie/params/CookieSpecParamBean.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/cookie/params/CookieSpecParamBean.java
index 091aba5c4..e595f7a6d 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/cookie/params/CookieSpecParamBean.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/cookie/params/CookieSpecParamBean.java
@@ -29,8 +29,6 @@ package com.fr.third.org.apache.http.cookie.params;
import java.util.Collection;
-import com.fr.third.org.apache.http.cookie.CookieSpecProvider;
-import com.fr.third.org.apache.http.cookie.params.CookieSpecPNames;
import com.fr.third.org.apache.http.params.HttpAbstractParamBean;
import com.fr.third.org.apache.http.params.HttpParams;
@@ -42,7 +40,7 @@ import com.fr.third.org.apache.http.params.HttpParams;
* @since 4.0
*
* @deprecated (4.3) use constructor parameters of {@link
- * CookieSpecProvider}s.
+ * com.fr.third.org.apache.http.cookie.CookieSpecProvider}s.
*/
@Deprecated
public class CookieSpecParamBean extends HttpAbstractParamBean {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/auth/SpnegoTokenGenerator.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/auth/SpnegoTokenGenerator.java
index 8473da5ff..7b6a52c86 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/auth/SpnegoTokenGenerator.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/auth/SpnegoTokenGenerator.java
@@ -26,9 +26,6 @@
*/
package com.fr.third.org.apache.http.impl.auth;
-import com.fr.third.org.apache.http.auth.Credentials;
-import com.fr.third.org.apache.http.impl.auth.KerberosScheme;
-
import java.io.IOException;
/**
@@ -40,7 +37,7 @@ import java.io.IOException;
* @since 4.1
*
* @deprecated (4.2) subclass {@link KerberosScheme} and override
- * {@link KerberosScheme#generateGSSToken(byte[], org.ietf.jgss.Oid, String, Credentials)}
+ * {@link KerberosScheme#generateGSSToken(byte[], org.ietf.jgss.Oid, String, com.fr.third.org.apache.http.auth.Credentials)}
*/
@Deprecated
public interface SpnegoTokenGenerator {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/AbstractAuthenticationHandler.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/AbstractAuthenticationHandler.java
index 29b4de84f..baff584ae 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/AbstractAuthenticationHandler.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/AbstractAuthenticationHandler.java
@@ -35,7 +35,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
-import com.fr.third.org.apache.http.client.AuthenticationStrategy;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.fr.third.org.apache.http.FormattedHeader;
@@ -60,7 +59,7 @@ import com.fr.third.org.apache.http.util.CharArrayBuffer;
*
* @since 4.0
*
- * @deprecated (4.2) use {@link AuthenticationStrategy}
+ * @deprecated (4.2) use {@link com.fr.third.org.apache.http.client.AuthenticationStrategy}
*/
@Deprecated
@Contract(threading = ThreadingBehavior.IMMUTABLE)
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/AbstractHttpClient.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/AbstractHttpClient.java
index 8f5c6c723..c959a56e8 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/AbstractHttpClient.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/AbstractHttpClient.java
@@ -30,7 +30,6 @@ package com.fr.third.org.apache.http.impl.client;
import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
-import com.fr.third.org.apache.http.client.HttpClient;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.fr.third.org.apache.http.ConnectionReuseStrategy;
@@ -95,7 +94,7 @@ import com.fr.third.org.apache.http.protocol.ImmutableHttpProcessor;
import com.fr.third.org.apache.http.util.Args;
/**
- * Base class for {@link HttpClient} implementations.
+ * Base class for {@link com.fr.third.org.apache.http.client.HttpClient} implementations.
* This class acts as a facade to a number of special purpose handler or
* strategy implementations responsible for handling of a particular aspect
* of the HTTP protocol such as redirect or authentication handling or
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/AuthenticationStrategyAdaptor.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/AuthenticationStrategyAdaptor.java
index b0ba21151..84385447d 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/AuthenticationStrategyAdaptor.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/AuthenticationStrategyAdaptor.java
@@ -32,7 +32,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Queue;
-import com.fr.third.org.apache.http.impl.client.BasicAuthCache;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.fr.third.org.apache.http.Header;
@@ -168,8 +167,7 @@ class AuthenticationStrategyAdaptor implements AuthenticationStrategy {
return false;
}
final String schemeName = authScheme.getSchemeName();
- return schemeName.equalsIgnoreCase(AuthPolicy.BASIC) ||
- schemeName.equalsIgnoreCase(AuthPolicy.DIGEST);
+ return schemeName.equalsIgnoreCase(AuthPolicy.BASIC);
}
public AuthenticationHandler getHandler() {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/ClientParamsStack.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/ClientParamsStack.java
index a290de875..69e3f577c 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/ClientParamsStack.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/ClientParamsStack.java
@@ -27,7 +27,6 @@
package com.fr.third.org.apache.http.impl.client;
-import com.fr.third.org.apache.http.client.HttpClient;
import com.fr.third.org.apache.http.params.AbstractHttpParams;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
@@ -46,7 +45,7 @@ import com.fr.third.org.apache.http.util.Args;
*
*
Client parameters:
* specific to an instance of
- * {@link HttpClient HttpClient}.
+ * {@link com.fr.third.org.apache.http.client.HttpClient HttpClient}.
* These provide client specific defaults.
*
Override parameters:
* specific to an instance of
- * {@link HttpClient HttpClient}.
+ * {@link com.fr.third.org.apache.http.client.HttpClient HttpClient}.
* These can be used to set parameters that cannot be overridden
* on a per-request basis.
*
@@ -66,8 +65,8 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Deprecated
public class ClientParamsStack extends AbstractHttpParams {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/CloseableHttpResponseProxy.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/CloseableHttpResponseProxy.java
index 1883567dd..90a1cfef8 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/CloseableHttpResponseProxy.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/CloseableHttpResponseProxy.java
@@ -40,7 +40,7 @@ import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse;
import com.fr.third.org.apache.http.util.EntityUtils;
/**
- * @since 4.3
+ * @deprecated Do not use.
*/
@Deprecated
class CloseableHttpResponseProxy implements InvocationHandler {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/ContentEncodingHttpClient.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/ContentEncodingHttpClient.java
index 5a1c98101..894f61a0a 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/ContentEncodingHttpClient.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/ContentEncodingHttpClient.java
@@ -28,7 +28,6 @@ package com.fr.third.org.apache.http.impl.client;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.client.HttpClient;
import com.fr.third.org.apache.http.client.protocol.RequestAcceptEncoding;
import com.fr.third.org.apache.http.client.protocol.ResponseContentEncoding;
import com.fr.third.org.apache.http.conn.ClientConnectionManager;
@@ -42,7 +41,7 @@ import com.fr.third.org.apache.http.protocol.BasicHttpProcessor;
* Deprecation note: due to the way this class modifies a response body
* without changing the response headers to reflect the entity changes, it cannot
* be used as the "backend" for a caching {@link
- * HttpClient} and still have uncompressed responses be cached.
+ * com.fr.third.org.apache.http.client.HttpClient} and still have uncompressed responses be cached.
* Users are encouraged to use the {@link DecompressingHttpClient} instead
* of this class, which can be wired in either before or after caching, depending on
* whether you want to cache responses in compressed or uncompressed form.
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/DefaultHttpClient.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/DefaultHttpClient.java
index 431143bf1..7bbf5339a 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/DefaultHttpClient.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/client/DefaultHttpClient.java
@@ -27,13 +27,6 @@
package com.fr.third.org.apache.http.impl.client;
-import com.fr.third.org.apache.http.auth.params.AuthPNames;
-import com.fr.third.org.apache.http.client.HttpClient;
-import com.fr.third.org.apache.http.client.params.ClientPNames;
-import com.fr.third.org.apache.http.conn.params.ConnRoutePNames;
-import com.fr.third.org.apache.http.cookie.params.CookieSpecPNames;
-import com.fr.third.org.apache.http.params.CoreConnectionPNames;
-import com.fr.third.org.apache.http.params.CoreProtocolPNames;
import com.fr.third.org.apache.http.HttpVersion;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
@@ -58,7 +51,7 @@ import com.fr.third.org.apache.http.protocol.RequestUserAgent;
import com.fr.third.org.apache.http.util.VersionInfo;
/**
- * Default implementation of {@link HttpClient} pre-configured
+ * Default implementation of {@link com.fr.third.org.apache.http.client.HttpClient} pre-configured
* for most common use scenarios.
*
* Please see the Javadoc for {@link #createHttpProcessor()} for the details of the interceptors
@@ -84,36 +77,36 @@ import com.fr.third.org.apache.http.util.VersionInfo;
* The following parameters can be used to customize the behavior of this
* class:
*
*
* @since 4.0
@@ -172,15 +165,15 @@ public class DefaultHttpClient extends AbstractHttpClient {
* Saves the default set of HttpParams in the provided parameter.
* These are:
*
*
* @since 4.2
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/AbstractClientConnAdapter.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/AbstractClientConnAdapter.java
index abdc4285e..87f201599 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/AbstractClientConnAdapter.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/AbstractClientConnAdapter.java
@@ -42,7 +42,6 @@ import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.conn.ClientConnectionManager;
import com.fr.third.org.apache.http.conn.ManagedClientConnection;
-import com.fr.third.org.apache.http.impl.conn.ConnectionShutdownException;
import com.fr.third.org.apache.http.conn.OperatedClientConnection;
import com.fr.third.org.apache.http.protocol.HttpContext;
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/AbstractPoolEntry.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/AbstractPoolEntry.java
index edc85c281..29948f521 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/AbstractPoolEntry.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/AbstractPoolEntry.java
@@ -30,7 +30,6 @@ import java.io.IOException;
import java.io.InterruptedIOException;
import com.fr.third.org.apache.http.HttpHost;
-import com.fr.third.org.apache.http.conn.ManagedClientConnection;
import com.fr.third.org.apache.http.conn.ClientConnectionOperator;
import com.fr.third.org.apache.http.conn.OperatedClientConnection;
import com.fr.third.org.apache.http.conn.routing.HttpRoute;
@@ -194,7 +193,7 @@ public abstract class AbstractPoolEntry {
* request to the previous proxy.
*
* @param next the proxy to which the tunnel was established.
- * See {@link ManagedClientConnection#tunnelProxy
+ * See {@link com.fr.third.org.apache.http.conn.ManagedClientConnection#tunnelProxy
* ManagedClientConnection.tunnelProxy}
* for details.
* @param secure {@code true} if the tunnel should be
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/AbstractPooledConnAdapter.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
index f8dbd9686..ff133469b 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
@@ -30,7 +30,6 @@ import java.io.IOException;
import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.conn.ClientConnectionManager;
-import com.fr.third.org.apache.http.conn.ManagedClientConnection;
import com.fr.third.org.apache.http.conn.OperatedClientConnection;
import com.fr.third.org.apache.http.conn.routing.HttpRoute;
import com.fr.third.org.apache.http.params.HttpParams;
@@ -38,7 +37,7 @@ import com.fr.third.org.apache.http.protocol.HttpContext;
/**
* Abstract adapter from pool {@link AbstractPoolEntry entries} to
- * {@link ManagedClientConnection managed}
+ * {@link com.fr.third.org.apache.http.conn.ManagedClientConnection managed}
* client connections.
* The connection in the pool entry is used to initialize the base class.
* In addition, methods to establish a route are delegated to the
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/BasicClientConnectionManager.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/BasicClientConnectionManager.java
index 3470b0ef1..a06355af4 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/BasicClientConnectionManager.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/BasicClientConnectionManager.java
@@ -141,7 +141,7 @@ public class BasicClientConnectionManager implements ClientConnectionManager {
@Override
public ManagedClientConnection getConnection(
- final long timeout, final TimeUnit tunit) {
+ final long timeout, final TimeUnit timeUnit) {
return BasicClientConnectionManager.this.getConnection(
route, state);
}
@@ -191,7 +191,7 @@ public class BasicClientConnectionManager implements ClientConnectionManager {
}
@Override
- public void releaseConnection(final ManagedClientConnection conn, final long keepalive, final TimeUnit tunit) {
+ public void releaseConnection(final ManagedClientConnection conn, final long keepalive, final TimeUnit timeUnit) {
Args.check(conn instanceof ManagedClientConnectionImpl, "Connection class mismatch, " +
"connection not obtained from this manager");
final ManagedClientConnectionImpl managedConn = (ManagedClientConnectionImpl) conn;
@@ -214,11 +214,11 @@ public class BasicClientConnectionManager implements ClientConnectionManager {
shutdownConnection(managedConn);
}
if (managedConn.isMarkedReusable()) {
- this.poolEntry.updateExpiry(keepalive, tunit != null ? tunit : TimeUnit.MILLISECONDS);
+ this.poolEntry.updateExpiry(keepalive, timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS);
if (this.log.isDebugEnabled()) {
final String s;
if (keepalive > 0) {
- s = "for " + keepalive + " " + tunit;
+ s = "for " + keepalive + " " + timeUnit;
} else {
s = "indefinitely";
}
@@ -249,11 +249,11 @@ public class BasicClientConnectionManager implements ClientConnectionManager {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
synchronized (this) {
assertNotShutdown();
- long time = tunit.toMillis(idletime);
+ long time = timeUnit.toMillis(idletime);
if (time < 0) {
time = 0;
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/DefaultClientConnection.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/DefaultClientConnection.java
index cc2bed788..f631593be 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/DefaultClientConnection.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/DefaultClientConnection.java
@@ -187,29 +187,29 @@ public class DefaultClientConnection extends SocketHttpClientConnection
@Override
protected SessionInputBuffer createSessionInputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
- SessionInputBuffer inbuffer = super.createSessionInputBuffer(
+ SessionInputBuffer inBuffer = super.createSessionInputBuffer(
socket,
- buffersize > 0 ? buffersize : 8192,
+ bufferSize > 0 ? bufferSize : 8192,
params);
if (wireLog.isDebugEnabled()) {
- inbuffer = new LoggingSessionInputBuffer(
- inbuffer,
+ inBuffer = new LoggingSessionInputBuffer(
+ inBuffer,
new Wire(wireLog),
HttpProtocolParams.getHttpElementCharset(params));
}
- return inbuffer;
+ return inBuffer;
}
@Override
protected SessionOutputBuffer createSessionOutputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
SessionOutputBuffer outbuffer = super.createSessionOutputBuffer(
socket,
- buffersize > 0 ? buffersize : 8192,
+ bufferSize > 0 ? bufferSize : 8192,
params);
if (wireLog.isDebugEnabled()) {
outbuffer = new LoggingSessionOutputBuffer(
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/DefaultClientConnectionOperator.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
index 7b50602db..c3453fbbc 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
@@ -34,8 +34,6 @@ import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
-import com.fr.third.org.apache.http.params.CoreConnectionPNames;
-import com.fr.third.org.apache.http.params.CoreProtocolPNames;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.fr.third.org.apache.http.HttpHost;
@@ -64,7 +62,7 @@ import com.fr.third.org.apache.http.util.Asserts;
* This connection operator is multihome network aware and will attempt to retry failed connects
* against all known IP addresses sequentially until the connect is successful or all known
* addresses fail to respond. Please note the same
- * {@link CoreConnectionPNames#CONNECTION_TIMEOUT} value will be used
+ * {@link com.fr.third.org.apache.http.params.CoreConnectionPNames#CONNECTION_TIMEOUT} value will be used
* for each connection attempt, so in the worst case the total elapsed time before timeout
* can be {@code CONNECTION_TIMEOUT * n} where {@code n} is the number of IP addresses
* of the given host. One can disable multihome support by overriding
@@ -74,14 +72,14 @@ import com.fr.third.org.apache.http.util.Asserts;
* The following parameters can be used to customize the behavior of this
* class:
*
*
* @since 4.0
@@ -254,7 +252,7 @@ public class DefaultClientConnectionOperator implements ClientConnectionOperator
*
* @param host host name to resolve
* @return array of IP addresses
- * @exception UnknownHostException if no IP address for the host could be determined.
+ * @throws UnknownHostException if no IP address for the host could be determined.
*
* @see DnsResolver
* @see SystemDefaultDnsResolver
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java
index 06b9940f7..6ab459bfd 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java
@@ -35,8 +35,6 @@ import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.conn.params.ConnRoutePNames;
-import com.fr.third.org.apache.http.impl.conn.DefaultRoutePlanner;
import com.fr.third.org.apache.http.conn.params.ConnRouteParams;
import com.fr.third.org.apache.http.conn.routing.HttpRoute;
import com.fr.third.org.apache.http.conn.routing.HttpRoutePlanner;
@@ -48,16 +46,16 @@ import com.fr.third.org.apache.http.util.Asserts;
/**
* Default implementation of an {@link HttpRoutePlanner}. This implementation
- * is based on {@link ConnRoutePNames parameters}.
+ * is based on {@link com.fr.third.org.apache.http.conn.params.ConnRoutePNames parameters}.
* It will not make use of any Java system properties, nor of system or
* browser proxy settings.
*
* The following parameters can be used to customize the behavior of this
* class:
*
*
* @since 4.0
@@ -89,7 +86,7 @@ public class DefaultResponseParser extends AbstractMessageParser {
protected int getMaxGarbageLines(final HttpParams params) {
return params.getIntParameter(
- ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE,
+ com.fr.third.org.apache.http.conn.params.ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE,
Integer.MAX_VALUE);
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/HttpConnPool.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/HttpConnPool.java
index 7e7e208c0..799579971 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/HttpConnPool.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/HttpConnPool.java
@@ -49,22 +49,22 @@ class HttpConnPool extends AbstractConnPool {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/HttpPoolEntry.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/HttpPoolEntry.java
index ceff9dcae..107184ffb 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/HttpPoolEntry.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/HttpPoolEntry.java
@@ -52,8 +52,8 @@ class HttpPoolEntry extends PoolEntry {
final String id,
final HttpRoute route,
final OperatedClientConnection conn,
- final long timeToLive, final TimeUnit tunit) {
- super(id, route, conn, timeToLive, tunit);
+ final long timeToLive, final TimeUnit timeUnit) {
+ super(id, route, conn, timeToLive, timeUnit);
this.log = log;
this.tracker = new RouteTracker(route);
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/IdleConnectionHandler.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/IdleConnectionHandler.java
index db20787ea..28c57cac4 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/IdleConnectionHandler.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/IdleConnectionHandler.java
@@ -32,18 +32,18 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
-import com.fr.third.org.apache.http.conn.ClientConnectionManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.fr.third.org.apache.http.HttpConnection;
// Currently only used by AbstractConnPool
+
/**
* A helper class for connection managers to track idle connections.
*
*
This class is not synchronized.
*
- * @see ClientConnectionManager#closeIdleConnections
+ * @see com.fr.third.org.apache.http.conn.ClientConnectionManager#closeIdleConnections
*
* @since 4.0
*
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/LoggingSessionInputBuffer.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
index 22424c765..3756f9c64 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
@@ -31,7 +31,6 @@ import java.io.IOException;
import com.fr.third.org.apache.http.Consts;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.impl.conn.Wire;
import com.fr.third.org.apache.http.io.EofSensor;
import com.fr.third.org.apache.http.io.HttpTransportMetrics;
import com.fr.third.org.apache.http.io.SessionInputBuffer;
@@ -84,29 +83,29 @@ public class LoggingSessionInputBuffer implements SessionInputBuffer, EofSensor
@Override
public int read(final byte[] b, final int off, final int len) throws IOException {
- final int l = this.in.read(b, off, len);
- if (this.wire.enabled() && l > 0) {
- this.wire.input(b, off, l);
+ final int readLen = this.in.read(b, off, len);
+ if (this.wire.enabled() && readLen > 0) {
+ this.wire.input(b, off, readLen);
}
- return l;
+ return readLen;
}
@Override
public int read() throws IOException {
- final int l = this.in.read();
- if (this.wire.enabled() && l != -1) {
- this.wire.input(l);
+ final int b = this.in.read();
+ if (this.wire.enabled() && b != -1) {
+ this.wire.input(b);
}
- return l;
+ return b;
}
@Override
public int read(final byte[] b) throws IOException {
- final int l = this.in.read(b);
- if (this.wire.enabled() && l > 0) {
- this.wire.input(b, 0, l);
+ final int readLen = this.in.read(b);
+ if (this.wire.enabled() && readLen > 0) {
+ this.wire.input(b, 0, readLen);
}
- return l;
+ return readLen;
}
@Override
@@ -121,14 +120,14 @@ public class LoggingSessionInputBuffer implements SessionInputBuffer, EofSensor
@Override
public int readLine(final CharArrayBuffer buffer) throws IOException {
- final int l = this.in.readLine(buffer);
- if (this.wire.enabled() && l >= 0) {
- final int pos = buffer.length() - l;
- final String s = new String(buffer.buffer(), pos, l);
+ final int readLen = this.in.readLine(buffer);
+ if (this.wire.enabled() && readLen >= 0) {
+ final int pos = buffer.length() - readLen;
+ final String s = new String(buffer.buffer(), pos, readLen);
final String tmp = s + "\r\n";
this.wire.input(tmp.getBytes(this.charset));
}
- return l;
+ return readLen;
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
index 35ee12599..a70498342 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
@@ -31,7 +31,6 @@ import java.io.IOException;
import com.fr.third.org.apache.http.Consts;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.impl.conn.Wire;
import com.fr.third.org.apache.http.io.HttpTransportMetrics;
import com.fr.third.org.apache.http.io.SessionOutputBuffer;
import com.fr.third.org.apache.http.util.CharArrayBuffer;
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/PoolingClientConnectionManager.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/PoolingClientConnectionManager.java
index a9d60d6ae..1e427f648 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/PoolingClientConnectionManager.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/PoolingClientConnectionManager.java
@@ -32,7 +32,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import com.fr.third.org.apache.http.conn.OperatedClientConnection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.fr.third.org.apache.http.annotation.Contract;
@@ -51,7 +50,7 @@ import com.fr.third.org.apache.http.util.Args;
import com.fr.third.org.apache.http.util.Asserts;
/**
- * Manages a pool of {@link OperatedClientConnection}
+ * Manages a pool of {@link com.fr.third.org.apache.http.conn.OperatedClientConnection}
* and is able to service connection requests from multiple execution threads.
* Connections are pooled on a per route basis. A request for a route which
* already the manager has persistent connections for available in the pool
@@ -99,12 +98,12 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
public PoolingClientConnectionManager(
final SchemeRegistry schemeRegistry,
- final long timeToLive, final TimeUnit tunit) {
- this(schemeRegistry, timeToLive, tunit, new SystemDefaultDnsResolver());
+ final long timeToLive, final TimeUnit timeUnit) {
+ this(schemeRegistry, timeToLive, timeUnit, new SystemDefaultDnsResolver());
}
public PoolingClientConnectionManager(final SchemeRegistry schemeRegistry,
- final long timeToLive, final TimeUnit tunit,
+ final long timeToLive, final TimeUnit timeUnit,
final DnsResolver dnsResolver) {
super();
Args.notNull(schemeRegistry, "Scheme registry");
@@ -112,7 +111,7 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
this.schemeRegistry = schemeRegistry;
this.dnsResolver = dnsResolver;
this.operator = createConnectionOperator(schemeRegistry);
- this.pool = new HttpConnPool(this.log, this.operator, 2, 20, timeToLive, tunit);
+ this.pool = new HttpConnPool(this.log, this.operator, 2, 20, timeToLive, timeUnit);
}
@Override
@@ -197,8 +196,8 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
@Override
public ManagedClientConnection getConnection(
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
- return leaseConnection(future, timeout, tunit);
+ final TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException {
+ return leaseConnection(future, timeout, timeUnit);
}
};
@@ -208,10 +207,10 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
ManagedClientConnection leaseConnection(
final Future future,
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
+ final TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException {
final HttpPoolEntry entry;
try {
- entry = future.get(timeout, tunit);
+ entry = future.get(timeout, timeUnit);
if (entry == null || future.isCancelled()) {
throw new InterruptedException();
}
@@ -235,7 +234,7 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
@Override
public void releaseConnection(
- final ManagedClientConnection conn, final long keepalive, final TimeUnit tunit) {
+ final ManagedClientConnection conn, final long keepalive, final TimeUnit timeUnit) {
Args.check(conn instanceof ManagedClientConnectionImpl, "Connection class mismatch, " +
"connection not obtained from this manager");
@@ -258,11 +257,11 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
}
// Only reusable connections can be kept alive
if (managedConn.isMarkedReusable()) {
- entry.updateExpiry(keepalive, tunit != null ? tunit : TimeUnit.MILLISECONDS);
+ entry.updateExpiry(keepalive, timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS);
if (this.log.isDebugEnabled()) {
final String s;
if (keepalive > 0) {
- s = "for " + keepalive + " " + tunit;
+ s = "for " + keepalive + " " + timeUnit;
} else {
s = "indefinitely";
}
@@ -290,11 +289,11 @@ public class PoolingClientConnectionManager implements ClientConnectionManager,
}
@Override
- public void closeIdleConnections(final long idleTimeout, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idleTimeout, final TimeUnit timeUnit) {
if (this.log.isDebugEnabled()) {
- this.log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit);
+ this.log.debug("Closing connections idle longer than " + idleTimeout + " " + timeUnit);
}
- this.pool.closeIdle(idleTimeout, tunit);
+ this.pool.closeIdle(idleTimeout, timeUnit);
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java
index 486f24177..2912925e9 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java
@@ -39,8 +39,6 @@ import java.util.List;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.HttpRequest;
-import com.fr.third.org.apache.http.conn.params.ConnRoutePNames;
-import com.fr.third.org.apache.http.impl.conn.SystemDefaultRoutePlanner;
import com.fr.third.org.apache.http.conn.params.ConnRouteParams;
import com.fr.third.org.apache.http.conn.routing.HttpRoute;
import com.fr.third.org.apache.http.conn.routing.HttpRoutePlanner;
@@ -53,19 +51,19 @@ import com.fr.third.org.apache.http.util.Asserts;
/**
* Default implementation of an {@link HttpRoutePlanner}.
- * This implementation is based on {@link java.net.ProxySelector}.
+ * This implementation is based on {@link ProxySelector}.
* By default, it will pick up the proxy settings of the JVM, either
* from system properties or from the browser running the application.
* Additionally, it interprets some
- * {@link ConnRoutePNames parameters},
+ * {@link com.fr.third.org.apache.http.conn.params.ConnRoutePNames parameters},
* though not the {@link
- * ConnRoutePNames#DEFAULT_PROXY DEFAULT_PROXY}.
+ * com.fr.third.org.apache.http.conn.params.ConnRoutePNames#DEFAULT_PROXY DEFAULT_PROXY}.
*
* The following parameters can be used to customize the behavior of this
* class:
*
*
* @since 4.0
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/SchemeRegistryFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/SchemeRegistryFactory.java
index 25f5b48d6..9ec4d0e9e 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/SchemeRegistryFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/SchemeRegistryFactory.java
@@ -28,7 +28,6 @@ package com.fr.third.org.apache.http.impl.conn;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.impl.client.HttpClientBuilder;
import com.fr.third.org.apache.http.conn.scheme.PlainSocketFactory;
import com.fr.third.org.apache.http.conn.scheme.Scheme;
import com.fr.third.org.apache.http.conn.scheme.SchemeRegistry;
@@ -37,7 +36,7 @@ import com.fr.third.org.apache.http.conn.ssl.SSLSocketFactory;
/**
* @since 4.1
*
- * @deprecated (4.3) use {@link HttpClientBuilder}.
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.impl.client.HttpClientBuilder}.
*/
@Contract(threading = ThreadingBehavior.SAFE)
@Deprecated
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/SingleClientConnManager.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/SingleClientConnManager.java
index aaca5932c..3a5ddd0c4 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/SingleClientConnManager.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/SingleClientConnManager.java
@@ -186,7 +186,7 @@ public class SingleClientConnManager implements ClientConnectionManager {
@Override
public ManagedClientConnection getConnection(
- final long timeout, final TimeUnit tunit) {
+ final long timeout, final TimeUnit timeUnit) {
return SingleClientConnManager.this.getConnection(
route, state);
}
@@ -317,16 +317,16 @@ public class SingleClientConnManager implements ClientConnectionManager {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
assertStillUp();
// idletime can be 0 or negative, no problem there
- Args.notNull(tunit, "Time unit");
+ Args.notNull(timeUnit, "Time unit");
synchronized (this) {
if ((managedConn == null) && uniquePoolEntry.connection.isOpen()) {
final long cutoff =
- System.currentTimeMillis() - tunit.toMillis(idletime);
+ System.currentTimeMillis() - timeUnit.toMillis(idletime);
if (lastReleaseTime <= cutoff) {
try {
uniquePoolEntry.close();
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/AbstractConnPool.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
index 47b004afd..b68b67d0f 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
@@ -99,7 +99,7 @@ public abstract class AbstractConnPool {
* @param route the route for which to get the connection
* @param state the state
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
*
* @return pool entry holding a connection for the route
@@ -114,9 +114,9 @@ public abstract class AbstractConnPool {
final HttpRoute route,
final Object state,
final long timeout,
- final TimeUnit tunit)
+ final TimeUnit timeUnit)
throws ConnectionPoolTimeoutException, InterruptedException {
- return requestPoolEntry(route, state).getPoolEntry(timeout, tunit);
+ return requestPoolEntry(route, state).getPoolEntry(timeout, timeUnit);
}
/**
@@ -154,16 +154,16 @@ public abstract class AbstractConnPool {
*
* @param idletime the time the connections should have been idle
* in order to be closed now
- * @param tunit the unit for the {@code idletime}
+ * @param timeUnit the unit for the {@code idletime}
*/
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
// idletime can be 0 or negative, no problem there
- Args.notNull(tunit, "Time unit");
+ Args.notNull(timeUnit, "Time unit");
poolLock.lock();
try {
- idleConnHandler.closeIdleConnections(tunit.toMillis(idletime));
+ idleConnHandler.closeIdleConnections(timeUnit.toMillis(idletime));
} finally {
poolLock.unlock();
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/BasicPoolEntry.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/BasicPoolEntry.java
index 081fdac90..9aa4f9824 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/BasicPoolEntry.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/BasicPoolEntry.java
@@ -29,7 +29,6 @@ package com.fr.third.org.apache.http.impl.conn.tsccm;
import java.lang.ref.ReferenceQueue;
import java.util.concurrent.TimeUnit;
-import com.fr.third.org.apache.http.pool.PoolEntry;
import com.fr.third.org.apache.http.conn.ClientConnectionOperator;
import com.fr.third.org.apache.http.conn.OperatedClientConnection;
import com.fr.third.org.apache.http.conn.routing.HttpRoute;
@@ -41,7 +40,7 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.2) use {@link PoolEntry}
+ * @deprecated (4.2) use {@link com.fr.third.org.apache.http.pool.PoolEntry}
*/
@Deprecated
public class BasicPoolEntry extends AbstractPoolEntry {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
index 336c99c29..ffb5d8679 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
@@ -295,9 +295,9 @@ public class ConnPoolByRoute extends AbstractConnPool {
@Override
public BasicPoolEntry getPoolEntry(
final long timeout,
- final TimeUnit tunit)
+ final TimeUnit timeUnit)
throws InterruptedException, ConnectionPoolTimeoutException {
- return getEntryBlocking(route, state, timeout, tunit, aborter);
+ return getEntryBlocking(route, state, timeout, timeUnit, aborter);
}
};
@@ -310,7 +310,7 @@ public class ConnPoolByRoute extends AbstractConnPool {
*
* @param route the route for which to get the connection
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
* @param aborter an object which can abort a {@link WaitingThread}.
*
@@ -323,14 +323,14 @@ public class ConnPoolByRoute extends AbstractConnPool {
*/
protected BasicPoolEntry getEntryBlocking(
final HttpRoute route, final Object state,
- final long timeout, final TimeUnit tunit,
+ final long timeout, final TimeUnit timeUnit,
final WaitingThreadAborter aborter)
throws ConnectionPoolTimeoutException, InterruptedException {
Date deadline = null;
if (timeout > 0) {
deadline = new Date
- (System.currentTimeMillis() + tunit.toMillis(timeout));
+ (System.currentTimeMillis() + timeUnit.toMillis(timeout));
}
BasicPoolEntry entry = null;
@@ -710,17 +710,17 @@ public class ConnPoolByRoute extends AbstractConnPool {
*
* @param idletime the time the connections should have been idle
* in order to be closed now
- * @param tunit the unit for the {@code idletime}
+ * @param timeUnit the unit for the {@code idletime}
*/
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
final long t = idletime > 0 ? idletime : 0;
if (log.isDebugEnabled()) {
- log.debug("Closing connections idle longer than " + t + " " + tunit);
+ log.debug("Closing connections idle longer than " + t + " " + timeUnit);
}
// the latest time for which connections will be closed
- final long deadline = System.currentTimeMillis() - tunit.toMillis(t);
+ final long deadline = System.currentTimeMillis() - timeUnit.toMillis(t);
poolLock.lock();
try {
final Iterator iter = freeConnections.iterator();
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
index 828a5712d..6db400eec 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/PoolEntryRequest.java
@@ -46,7 +46,7 @@ public interface PoolEntryRequest {
* an {@link InterruptedException} is thrown.
*
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
*
* @return pool entry holding a connection for the route
@@ -58,7 +58,7 @@ public interface PoolEntryRequest {
*/
BasicPoolEntry getPoolEntry(
long timeout,
- TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException;
+ TimeUnit timeUnit) throws InterruptedException, ConnectionPoolTimeoutException;
/**
* Aborts the active or next call to
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
index 2d4e311ba..154953b2b 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
@@ -31,7 +31,6 @@ import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Queue;
-import com.fr.third.org.apache.http.pool.AbstractConnPool;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.fr.third.org.apache.http.conn.OperatedClientConnection;
@@ -49,7 +48,7 @@ import com.fr.third.org.apache.http.util.LangUtils;
*
* @since 4.0
*
- * @deprecated (4.2) use {@link AbstractConnPool}
+ * @deprecated (4.2) use {@link com.fr.third.org.apache.http.pool.AbstractConnPool}
*/
@Deprecated
public class RouteSpecificPool {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
index 6099f5d96..14f4b2af6 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
@@ -29,8 +29,6 @@ package com.fr.third.org.apache.http.impl.conn.tsccm;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
-import com.fr.third.org.apache.http.conn.OperatedClientConnection;
-import com.fr.third.org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.fr.third.org.apache.http.annotation.Contract;
@@ -50,7 +48,7 @@ import com.fr.third.org.apache.http.util.Args;
import com.fr.third.org.apache.http.util.Asserts;
/**
- * Manages a pool of {@link OperatedClientConnection }
+ * Manages a pool of {@link com.fr.third.org.apache.http.conn.OperatedClientConnection }
* and is able to service connection requests from multiple execution threads.
* Connections are pooled on a per route basis. A request for a route which
* already the manager has persistent connections for available in the pool
@@ -67,7 +65,7 @@ import com.fr.third.org.apache.http.util.Asserts;
*
* @since 4.0
*
- * @deprecated (4.2) use {@link PoolingHttpClientConnectionManager}
+ * @deprecated (4.2) use {@link com.fr.third.org.apache.http.impl.conn.PoolingHttpClientConnectionManager}
*/
@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
@Deprecated
@@ -234,7 +232,7 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
@Override
public ManagedClientConnection getConnection(
- final long timeout, final TimeUnit tunit) throws InterruptedException,
+ final long timeout, final TimeUnit timeUnit) throws InterruptedException,
ConnectionPoolTimeoutException {
Args.notNull(route, "Route");
@@ -242,7 +240,7 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
log.debug("Get connection: " + route + ", timeout = " + timeout);
}
- final BasicPoolEntry entry = poolRequest.getPoolEntry(timeout, tunit);
+ final BasicPoolEntry entry = poolRequest.getPoolEntry(timeout, timeUnit);
return new BasicPooledConnAdapter(ThreadSafeClientConnManager.this, entry);
}
@@ -329,11 +327,11 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager {
}
@Override
- public void closeIdleConnections(final long idleTimeout, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idleTimeout, final TimeUnit timeUnit) {
if (log.isDebugEnabled()) {
- log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit);
+ log.debug("Closing connections idle longer than " + idleTimeout + " " + timeUnit);
}
- pool.closeIdleConnections(idleTimeout, tunit);
+ pool.closeIdleConnections(idleTimeout, timeUnit);
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BestMatchSpec.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BestMatchSpec.java
index 59e591452..90e38a6ca 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BestMatchSpec.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BestMatchSpec.java
@@ -29,13 +29,12 @@ package com.fr.third.org.apache.http.impl.cookie;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.impl.cookie.DefaultCookieSpec;
/**
* 'Meta' cookie specification that picks up a cookie policy based on
* the format of cookies sent with the HTTP response.
*
- * @deprecated (4.4) use {@link DefaultCookieSpec}.
+ * @deprecated (4.4) use {@link com.fr.third.org.apache.http.impl.cookie.DefaultCookieSpec}.
*
* @since 4.0
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BestMatchSpecFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BestMatchSpecFactory.java
index 2fb4a24a5..e3273b5ac 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BestMatchSpecFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BestMatchSpecFactory.java
@@ -39,11 +39,11 @@ import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
- * {@link CookieSpecProvider} implementation that provides an instance of
- * {@link BestMatchSpec}. The instance returned by this factory can
+ * {@link com.fr.third.org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
+ * {@link com.fr.third.org.apache.http.impl.cookie.BestMatchSpec}. The instance returned by this factory can
* be shared by multiple threads.
*
- * @deprecated (4.4) use {@link DefaultCookieSpecProvider}.
+ * @deprecated (4.4) use {@link com.fr.third.org.apache.http.impl.cookie.DefaultCookieSpecProvider}.
*
* @since 4.0
*/
@@ -55,7 +55,7 @@ public class BestMatchSpecFactory implements CookieSpecFactory, CookieSpecProvid
public BestMatchSpecFactory(final String[] datepatterns, final boolean oneHeader) {
super();
- this.cookieSpec = new BestMatchSpec(datepatterns, oneHeader);;
+ this.cookieSpec = new BestMatchSpec(datepatterns, oneHeader);
}
public BestMatchSpecFactory() {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BrowserCompatSpec.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BrowserCompatSpec.java
index 042f8de67..8ef0b2f5b 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BrowserCompatSpec.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BrowserCompatSpec.java
@@ -57,7 +57,7 @@ import com.fr.third.org.apache.http.util.CharArrayBuffer;
* common web browser applications such as Microsoft Internet Explorer
* and Mozilla FireFox.
*
- * @deprecated (4.4) use {@link DefaultCookieSpec}.
+ * @deprecated (4.4) use {@link com.fr.third.org.apache.http.impl.cookie.DefaultCookieSpec}.
*
* @since 4.0
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java
index 8a85cffd1..fa49e4b6f 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BrowserCompatSpecFactory.java
@@ -39,11 +39,11 @@ import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
- * {@link CookieSpecProvider} implementation that provides an instance of
- * {@link BrowserCompatSpec}. The instance returned by this factory
+ * {@link com.fr.third.org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
+ * {@link com.fr.third.org.apache.http.impl.cookie.BrowserCompatSpec}. The instance returned by this factory
* can be shared by multiple threads.
*
- * @deprecated (4.4) use {@link DefaultCookieSpecProvider}.
+ * @deprecated (4.4) use {@link com.fr.third.org.apache.http.impl.cookie.DefaultCookieSpecProvider}.
*
* @since 4.0
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
index 0af0dc22c..ddb82879f 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/BrowserCompatVersionAttributeHandler.java
@@ -33,7 +33,6 @@ import com.fr.third.org.apache.http.cookie.ClientCookie;
import com.fr.third.org.apache.http.cookie.CommonCookieAttributeHandler;
import com.fr.third.org.apache.http.cookie.MalformedCookieException;
import com.fr.third.org.apache.http.cookie.SetCookie;
-import com.fr.third.org.apache.http.impl.cookie.AbstractCookieAttributeHandler;
import com.fr.third.org.apache.http.util.Args;
/**
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/IgnoreSpecFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/IgnoreSpecFactory.java
index f7d0f891a..432d95ad1 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/IgnoreSpecFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/IgnoreSpecFactory.java
@@ -32,15 +32,13 @@ import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.cookie.CookieSpec;
import com.fr.third.org.apache.http.cookie.CookieSpecFactory;
import com.fr.third.org.apache.http.cookie.CookieSpecProvider;
-import com.fr.third.org.apache.http.impl.cookie.IgnoreSpec;
-import com.fr.third.org.apache.http.impl.cookie.IgnoreSpecProvider;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
* {@link CookieSpecProvider} implementation that ignores all cookies.
*
- * @deprecated (4.4) Use {@link IgnoreSpecProvider}.
+ * @deprecated (4.4) Use {@link com.fr.third.org.apache.http.impl.cookie.IgnoreSpecProvider}.
*
* @since 4.1
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
index ead2662e6..b921275de 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/NetscapeDraftSpecFactory.java
@@ -35,17 +35,15 @@ import com.fr.third.org.apache.http.cookie.CookieSpec;
import com.fr.third.org.apache.http.cookie.CookieSpecFactory;
import com.fr.third.org.apache.http.cookie.CookieSpecProvider;
import com.fr.third.org.apache.http.cookie.params.CookieSpecPNames;
-import com.fr.third.org.apache.http.impl.cookie.NetscapeDraftSpec;
-import com.fr.third.org.apache.http.impl.cookie.NetscapeDraftSpecProvider;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
- * {@link CookieSpecProvider} implementation that provides an instance of
- * {@link NetscapeDraftSpec}. The instance returned by this factory
+ * {@link com.fr.third.org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
+ * {@link com.fr.third.org.apache.http.impl.cookie.NetscapeDraftSpec}. The instance returned by this factory
* can be shared by multiple threads.
*
- * @deprecated (4.4) Use {@link NetscapeDraftSpecProvider}.
+ * @deprecated (4.4) Use {@link com.fr.third.org.apache.http.impl.cookie.NetscapeDraftSpecProvider}.
*
* @since 4.0
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/PublicSuffixFilter.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/PublicSuffixFilter.java
index a4b7f5661..390b17a3d 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/PublicSuffixFilter.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/PublicSuffixFilter.java
@@ -34,7 +34,6 @@ import com.fr.third.org.apache.http.cookie.CookieAttributeHandler;
import com.fr.third.org.apache.http.cookie.CookieOrigin;
import com.fr.third.org.apache.http.cookie.MalformedCookieException;
import com.fr.third.org.apache.http.cookie.SetCookie;
-import com.fr.third.org.apache.http.impl.cookie.PublicSuffixDomainFilter;
/**
* Wraps a CookieAttributeHandler and leverages its match method
@@ -44,7 +43,7 @@ import com.fr.third.org.apache.http.impl.cookie.PublicSuffixDomainFilter;
* An uptodate list of suffixes can be obtained from
* publicsuffix.org
*
- * @deprecated (4.4) use {@link PublicSuffixDomainFilter}
+ * @deprecated (4.4) use {@link com.fr.third.org.apache.http.impl.cookie.PublicSuffixDomainFilter}
*
* @since 4.0
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/RFC2109SpecFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/RFC2109SpecFactory.java
index 445f12c72..576e67917 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/RFC2109SpecFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/RFC2109SpecFactory.java
@@ -35,17 +35,15 @@ import com.fr.third.org.apache.http.cookie.CookieSpec;
import com.fr.third.org.apache.http.cookie.CookieSpecFactory;
import com.fr.third.org.apache.http.cookie.CookieSpecProvider;
import com.fr.third.org.apache.http.cookie.params.CookieSpecPNames;
-import com.fr.third.org.apache.http.impl.cookie.RFC2109Spec;
-import com.fr.third.org.apache.http.impl.cookie.RFC2109SpecProvider;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
- * {@link CookieSpecProvider} implementation that provides an instance of
- * {@link RFC2109Spec}. The instance returned by this factory
+ * {@link com.fr.third.org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
+ * {@link com.fr.third.org.apache.http.impl.cookie.RFC2109Spec}. The instance returned by this factory
* can be shared by multiple threads.
*
- * @deprecated (4.4) Use {@link RFC2109SpecProvider}.
+ * @deprecated (4.4) Use {@link com.fr.third.org.apache.http.impl.cookie.RFC2109SpecProvider}.
*
* @since 4.0
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/RFC2965SpecFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/RFC2965SpecFactory.java
index fe4e27ab7..a2db6bdbe 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/RFC2965SpecFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java-deprecated/com/fr/third/org/apache/http/impl/cookie/RFC2965SpecFactory.java
@@ -35,17 +35,15 @@ import com.fr.third.org.apache.http.cookie.CookieSpec;
import com.fr.third.org.apache.http.cookie.CookieSpecFactory;
import com.fr.third.org.apache.http.cookie.CookieSpecProvider;
import com.fr.third.org.apache.http.cookie.params.CookieSpecPNames;
-import com.fr.third.org.apache.http.impl.cookie.RFC2965Spec;
-import com.fr.third.org.apache.http.impl.cookie.RFC2965SpecProvider;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
- * {@link CookieSpecProvider} implementation that provides an instance of
- * {@link RFC2965Spec}. The instance returned by this factory can
+ * {@link com.fr.third.org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
+ * {@link com.fr.third.org.apache.http.impl.cookie.RFC2965Spec}. The instance returned by this factory can
* be shared by multiple threads.
*
- * @deprecated (4.4) Use {@link RFC2965SpecProvider}.
+ * @deprecated (4.4) Use {@link com.fr.third.org.apache.http.impl.cookie.RFC2965SpecProvider}.
*
* @since 4.0
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthScheme.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthScheme.java
index 29c52a420..fa293f4a0 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthScheme.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthScheme.java
@@ -26,7 +26,6 @@
*/
package com.fr.third.org.apache.http.auth;
-import com.fr.third.org.apache.http.protocol.HttpContext;
import com.fr.third.org.apache.http.Header;
import com.fr.third.org.apache.http.HttpRequest;
@@ -122,7 +121,7 @@ public interface AuthScheme {
*
* @return the authorization string
*
- * @deprecated (4.1) Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, HttpContext)}
+ * @deprecated (4.1) Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, com.fr.third.org.apache.http.protocol.HttpContext)}
*/
@Deprecated
Header authenticate(Credentials credentials, HttpRequest request)
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthSchemeRegistry.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthSchemeRegistry.java
index 8a16af357..c0854b86f 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthSchemeRegistry.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthSchemeRegistry.java
@@ -32,7 +32,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import com.fr.third.org.apache.http.config.Registry;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
@@ -48,7 +47,7 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link Registry}
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.config.Registry}
*/
@Contract(threading = ThreadingBehavior.SAFE)
@Deprecated
@@ -113,9 +112,8 @@ public final class AuthSchemeRegistry implements Lookup {
final AuthSchemeFactory factory = registeredSchemes.get(name.toLowerCase(Locale.ENGLISH));
if (factory != null) {
return factory.newInstance(params);
- } else {
- throw new IllegalStateException("Unsupported authentication scheme: " + name);
}
+ throw new IllegalStateException("Unsupported authentication scheme: " + name);
}
/**
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthScope.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthScope.java
index af9aa8fcd..e5cd48a01 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthScope.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthScope.java
@@ -265,7 +265,7 @@ public class AuthScope {
}
/**
- * @see java.lang.Object#equals(Object)
+ * @see Object#equals(Object)
*/
@Override
public boolean equals(final Object o) {
@@ -287,7 +287,7 @@ public class AuthScope {
}
/**
- * @see java.lang.Object#toString()
+ * @see Object#toString()
*/
@Override
public String toString() {
@@ -315,7 +315,7 @@ public class AuthScope {
}
/**
- * @see java.lang.Object#hashCode()
+ * @see Object#hashCode()
*/
@Override
public int hashCode() {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthState.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthState.java
index a4ff7e6d2..5bf507385 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthState.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/AuthState.java
@@ -133,6 +133,15 @@ public class AuthState {
return this.authOptions != null && !this.authOptions.isEmpty();
}
+ /**
+ * Returns {@code true} if the actual authentication scheme is connection based.
+ *
+ * @since 4.5.6
+ */
+ public boolean isConnectionBased() {
+ return this.authScheme != null && this.authScheme.isConnectionBased();
+ }
+
/**
* Updates the auth state with a queue of {@link AuthOption}s.
*
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/params/AuthPNames.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/params/AuthPNames.java
index 8bacb3ada..752324c1b 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/params/AuthPNames.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/auth/params/AuthPNames.java
@@ -27,26 +27,21 @@
package com.fr.third.org.apache.http.auth.params;
-import com.fr.third.org.apache.http.auth.AuthScheme;
-import com.fr.third.org.apache.http.auth.AuthSchemeProvider;
-import com.fr.third.org.apache.http.auth.Credentials;
-import com.fr.third.org.apache.http.client.config.RequestConfig;
-
/**
* Parameter names for HTTP authentication classes.
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig}
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.client.config.RequestConfig}
* and constructor parameters of
- * {@link AuthSchemeProvider}s.
+ * {@link com.fr.third.org.apache.http.auth.AuthSchemeProvider}s.
*/
@Deprecated
public interface AuthPNames {
/**
* Defines the charset to be used when encoding
- * {@link Credentials}.
+ * {@link com.fr.third.org.apache.http.auth.Credentials}.
*
* This parameter expects a value of type {@link String}.
*/
@@ -54,25 +49,25 @@ public interface AuthPNames {
/**
* Defines the order of preference for supported
- * {@link AuthScheme}s when authenticating with
+ * {@link com.fr.third.org.apache.http.auth.AuthScheme}s when authenticating with
* the target host.
*
* This parameter expects a value of type {@link java.util.Collection}. The
* collection is expected to contain {@link String} instances representing
* a name of an authentication scheme as returned by
- * {@link AuthScheme#getSchemeName()}.
+ * {@link com.fr.third.org.apache.http.auth.AuthScheme#getSchemeName()}.
*/
public static final String TARGET_AUTH_PREF = "http.auth.target-scheme-pref";
/**
* Defines the order of preference for supported
- * {@link AuthScheme}s when authenticating with the
+ * {@link com.fr.third.org.apache.http.auth.AuthScheme}s when authenticating with the
* proxy host.
*
* This parameter expects a value of type {@link java.util.Collection}. The
* collection is expected to contain {@link String} instances representing
* a name of an authentication scheme as returned by
- * {@link AuthScheme#getSchemeName()}.
+ * {@link com.fr.third.org.apache.http.auth.AuthScheme#getSchemeName()}.
*/
public static final String PROXY_AUTH_PREF = "http.auth.proxy-scheme-pref";
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/CookieStore.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/CookieStore.java
index e0ab2fb88..73b29137d 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/CookieStore.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/CookieStore.java
@@ -57,7 +57,7 @@ public interface CookieStore {
/**
* Removes all of {@link Cookie}s in this store that have expired by
- * the specified {@link java.util.Date}.
+ * the specified {@link Date}.
*
* @return true if any cookies were purged.
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/HttpClient.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/HttpClient.java
index f218ee3f9..5eaf52b0f 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/HttpClient.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/HttpClient.java
@@ -27,18 +27,16 @@
package com.fr.third.org.apache.http.client;
+import java.io.IOException;
+
import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
-import com.fr.third.org.apache.http.client.config.RequestConfig;
import com.fr.third.org.apache.http.client.methods.HttpUriRequest;
import com.fr.third.org.apache.http.conn.ClientConnectionManager;
-import com.fr.third.org.apache.http.impl.client.HttpClientBuilder;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.protocol.HttpContext;
-import java.io.IOException;
-
/**
* This interface represents only the most basic contract for HTTP request
* execution. It imposes no restrictions or particular details on the request
@@ -60,7 +58,7 @@ public interface HttpClient {
* @return the default parameters
*
* @deprecated (4.3) use
- * {@link RequestConfig}.
+ * {@link com.fr.third.org.apache.http.client.config.RequestConfig}.
*/
@Deprecated
HttpParams getParams();
@@ -71,7 +69,7 @@ public interface HttpClient {
* @return the connection manager
*
* @deprecated (4.3) use
- * {@link HttpClientBuilder}.
+ * {@link com.fr.third.org.apache.http.impl.client.HttpClientBuilder}.
*/
@Deprecated
ClientConnectionManager getConnectionManager();
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/HttpResponseException.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/HttpResponseException.java
index 4159761c2..2f435bee7 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/HttpResponseException.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/HttpResponseException.java
@@ -26,6 +26,8 @@
*/
package com.fr.third.org.apache.http.client;
+import com.fr.third.org.apache.http.util.TextUtils;
+
/**
* Signals a non 2xx HTTP response.
*
@@ -36,14 +38,21 @@ public class HttpResponseException extends ClientProtocolException {
private static final long serialVersionUID = -7186627969477257933L;
private final int statusCode;
+ private final String reasonPhrase;
- public HttpResponseException(final int statusCode, final String s) {
- super(s);
+ public HttpResponseException(final int statusCode, final String reasonPhrase) {
+ super(String.format("status code: %d" +
+ (TextUtils.isBlank(reasonPhrase) ? "" : ", reason phrase: %s"), statusCode, reasonPhrase));
this.statusCode = statusCode;
+ this.reasonPhrase = reasonPhrase;
}
public int getStatusCode() {
return this.statusCode;
}
+ public String getReasonPhrase() {
+ return this.reasonPhrase;
+ }
+
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/config/AuthSchemes.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/config/AuthSchemes.java
index d642a7f68..a85db83dd 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/config/AuthSchemes.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/config/AuthSchemes.java
@@ -65,6 +65,11 @@ public final class AuthSchemes {
*/
public static final String KERBEROS = "Kerberos";
+ /**
+ * CredSSP authentication scheme defined in [MS-CSSP].
+ */
+ public static final String CREDSSP = "CredSSP";
+
private AuthSchemes() {
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/config/RequestConfig.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/config/RequestConfig.java
index cff459916..e3ad4eb96 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/config/RequestConfig.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/config/RequestConfig.java
@@ -33,7 +33,6 @@ import java.util.Collection;
import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
/**
* Immutable class encapsulating request configuration items.
@@ -61,12 +60,13 @@ public class RequestConfig implements Cloneable {
private final int connectTimeout;
private final int socketTimeout;
private final boolean contentCompressionEnabled;
+ private final boolean normalizeUri;
/**
* Intended for CDI compatibility
*/
protected RequestConfig() {
- this(false, null, null, false, null, false, false, false, 0, false, null, null, 0, 0, 0, true);
+ this(false, null, null, false, null, false, false, false, 0, false, null, null, 0, 0, 0, true, true);
}
RequestConfig(
@@ -85,7 +85,8 @@ public class RequestConfig implements Cloneable {
final int connectionRequestTimeout,
final int connectTimeout,
final int socketTimeout,
- final boolean contentCompressionEnabled) {
+ final boolean contentCompressionEnabled,
+ final boolean normalizeUri) {
super();
this.expectContinueEnabled = expectContinueEnabled;
this.proxy = proxy;
@@ -103,6 +104,7 @@ public class RequestConfig implements Cloneable {
this.connectTimeout = connectTimeout;
this.socketTimeout = socketTimeout;
this.contentCompressionEnabled = contentCompressionEnabled;
+ this.normalizeUri = normalizeUri;
}
/**
@@ -166,7 +168,7 @@ public class RequestConfig implements Cloneable {
*
*
* @deprecated (4.4) Use {@link
- * PoolingHttpClientConnectionManager#getValidateAfterInactivity()}
+ * com.fr.third.org.apache.http.impl.conn.PoolingHttpClientConnectionManager#getValidateAfterInactivity()}
*/
@Deprecated
public boolean isStaleConnectionCheckEnabled() {
@@ -262,11 +264,10 @@ public class RequestConfig implements Cloneable {
/**
* Returns the timeout in milliseconds used when requesting a connection
- * from the connection manager. A timeout value of zero is interpreted
- * as an infinite timeout.
+ * from the connection manager.
*
* A timeout value of zero is interpreted as an infinite timeout.
- * A negative value is interpreted as undefined (system default).
+ * A negative value is interpreted as undefined (system default if applicable).
*
*
* Default: {@code -1}
@@ -278,10 +279,9 @@ public class RequestConfig implements Cloneable {
/**
* Determines the timeout in milliseconds until a connection is established.
- * A timeout value of zero is interpreted as an infinite timeout.
*
* A timeout value of zero is interpreted as an infinite timeout.
- * A negative value is interpreted as undefined (system default).
+ * A negative value is interpreted as undefined (system default if applicable).
*
*
* Default: {@code -1}
@@ -293,11 +293,11 @@ public class RequestConfig implements Cloneable {
/**
* Defines the socket timeout ({@code SO_TIMEOUT}) in milliseconds,
- * which is the timeout for waiting for data or, put differently,
+ * which is the timeout for waiting for data or, put differently,
* a maximum period inactivity between two consecutive data packets).
*
* A timeout value of zero is interpreted as an infinite timeout.
- * A negative value is interpreted as undefined (system default).
+ * A negative value is interpreted as undefined (system default if applicable).
*
*
* Default: {@code -1}
@@ -333,6 +333,18 @@ public class RequestConfig implements Cloneable {
return contentCompressionEnabled;
}
+ /**
+ * Determines whether client should normalize URIs in requests or not.
+ *
+ * Default: {@code true}
+ *
+ *
+ * @since 4.5.8
+ */
+ public boolean isNormalizeUri() {
+ return normalizeUri;
+ }
+
@Override
protected RequestConfig clone() throws CloneNotSupportedException {
return (RequestConfig) super.clone();
@@ -357,16 +369,17 @@ public class RequestConfig implements Cloneable {
builder.append(", connectTimeout=").append(connectTimeout);
builder.append(", socketTimeout=").append(socketTimeout);
builder.append(", contentCompressionEnabled=").append(contentCompressionEnabled);
+ builder.append(", normalizeUri=").append(normalizeUri);
builder.append("]");
return builder.toString();
}
- public static RequestConfig.Builder custom() {
+ public static Builder custom() {
return new Builder();
}
@SuppressWarnings("deprecation")
- public static RequestConfig.Builder copy(final RequestConfig config) {
+ public static Builder copy(final RequestConfig config) {
return new Builder()
.setExpectContinueEnabled(config.isExpectContinueEnabled())
.setProxy(config.getProxy())
@@ -384,7 +397,8 @@ public class RequestConfig implements Cloneable {
.setConnectTimeout(config.getConnectTimeout())
.setSocketTimeout(config.getSocketTimeout())
.setDecompressionEnabled(config.isDecompressionEnabled())
- .setContentCompressionEnabled(config.isContentCompressionEnabled());
+ .setContentCompressionEnabled(config.isContentCompressionEnabled())
+ .setNormalizeUri(config.isNormalizeUri());
}
public static class Builder {
@@ -405,6 +419,7 @@ public class RequestConfig implements Cloneable {
private int connectTimeout;
private int socketTimeout;
private boolean contentCompressionEnabled;
+ private boolean normalizeUri;
Builder() {
super();
@@ -417,6 +432,7 @@ public class RequestConfig implements Cloneable {
this.connectTimeout = -1;
this.socketTimeout = -1;
this.contentCompressionEnabled = true;
+ this.normalizeUri = true;
}
public Builder setExpectContinueEnabled(final boolean expectContinueEnabled) {
@@ -436,7 +452,7 @@ public class RequestConfig implements Cloneable {
/**
* @deprecated (4.4) Use {@link
- * PoolingHttpClientConnectionManager#setValidateAfterInactivity(int)}
+ * com.fr.third.org.apache.http.impl.conn.PoolingHttpClientConnectionManager#setValidateAfterInactivity(int)}
*/
@Deprecated
public Builder setStaleConnectionCheckEnabled(final boolean staleConnectionCheckEnabled) {
@@ -514,6 +530,11 @@ public class RequestConfig implements Cloneable {
return this;
}
+ public Builder setNormalizeUri(final boolean normalizeUri) {
+ this.normalizeUri = normalizeUri;
+ return this;
+ }
+
public RequestConfig build() {
return new RequestConfig(
expectContinueEnabled,
@@ -531,7 +552,8 @@ public class RequestConfig implements Cloneable {
connectionRequestTimeout,
connectTimeout,
socketTimeout,
- contentCompressionEnabled);
+ contentCompressionEnabled,
+ normalizeUri);
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/DecompressingEntity.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/DecompressingEntity.java
index e7a9b827a..1c0053cb8 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/DecompressingEntity.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/DecompressingEntity.java
@@ -79,23 +79,22 @@ public class DecompressingEntity extends HttpEntityWrapper {
content = getDecompressingStream();
}
return content;
- } else {
- return getDecompressingStream();
}
+ return getDecompressingStream();
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = getContent();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = getContent();
try {
final byte[] buffer = new byte[BUFFER_SIZE];
int l;
- while ((l = instream.read(buffer)) != -1) {
- outstream.write(buffer, 0, l);
+ while ((l = inStream.read(buffer)) != -1) {
+ outStream.write(buffer, 0, l);
}
} finally {
- instream.close();
+ inStream.close();
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/DeflateDecompressingEntity.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/DeflateDecompressingEntity.java
index b53ac2bab..d27062fbc 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/DeflateDecompressingEntity.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/DeflateDecompressingEntity.java
@@ -26,14 +26,10 @@
*/
package com.fr.third.org.apache.http.client.entity;
-import java.io.IOException;
-import java.io.InputStream;
-
-import com.fr.third.org.apache.http.entity.HttpEntityWrapper;
import com.fr.third.org.apache.http.HttpEntity;
/**
- * {@link HttpEntityWrapper} responsible for handling
+ * {@link com.fr.third.org.apache.http.entity.HttpEntityWrapper} responsible for handling
* deflate Content Coded responses. In RFC2616 terms, {@code deflate}
* means a {@code zlib} stream as defined in RFC1950. Some server
* implementations have misinterpreted RFC2616 to mean that a
@@ -58,14 +54,7 @@ public class DeflateDecompressingEntity extends DecompressingEntity {
* a non-null {@link HttpEntity} to be wrapped
*/
public DeflateDecompressingEntity(final HttpEntity entity) {
- super(entity, new InputStreamFactory() {
-
- @Override
- public InputStream create(final InputStream instream) throws IOException {
- return new DeflateInputStream(instream);
- }
-
- });
+ super(entity, DeflateInputStreamFactory.getInstance());
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/DeflateInputStreamFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/DeflateInputStreamFactory.java
new file mode 100644
index 000000000..e0cf26ed3
--- /dev/null
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/DeflateInputStreamFactory.java
@@ -0,0 +1,63 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+
+package com.fr.third.org.apache.http.client.entity;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
+
+/**
+ * {@link InputStreamFactory} for handling Deflate Content Coded responses.
+ *
+ * @since 4.5.4
+ */
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class DeflateInputStreamFactory implements InputStreamFactory {
+
+ /**
+ * Singleton instance.
+ */
+ private static final DeflateInputStreamFactory INSTANCE = new DeflateInputStreamFactory();
+
+ /**
+ * Gets the singleton instance.
+ *
+ * @return the singleton instance.
+ */
+ public static DeflateInputStreamFactory getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public InputStream create(final InputStream inputStream) throws IOException {
+ return new DeflateInputStream(inputStream);
+ }
+
+}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/EntityBuilder.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/EntityBuilder.java
index 0bd6e2c34..d6008231a 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/EntityBuilder.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/EntityBuilder.java
@@ -53,11 +53,11 @@ import com.fr.third.org.apache.http.entity.StringEntity;
*
*/
public EntityBuilder setFile(final File file) {
clearContent();
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/GZIPInputStreamFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/GZIPInputStreamFactory.java
new file mode 100644
index 000000000..0eb55c19f
--- /dev/null
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/GZIPInputStreamFactory.java
@@ -0,0 +1,64 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+
+package com.fr.third.org.apache.http.client.entity;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.GZIPInputStream;
+
+import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
+
+/**
+ * {@link InputStreamFactory} for handling GZIPContent Coded responses.
+ *
+ * @since 4.5.4
+ */
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class GZIPInputStreamFactory implements InputStreamFactory {
+
+ /**
+ * Singleton instance.
+ */
+ private static final GZIPInputStreamFactory INSTANCE = new GZIPInputStreamFactory();
+
+ /**
+ * Gets the singleton instance.
+ *
+ * @return the singleton instance.
+ */
+ public static GZIPInputStreamFactory getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public InputStream create(final InputStream inputStream) throws IOException {
+ return new GZIPInputStream(inputStream);
+ }
+
+}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/GzipCompressingEntity.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/GzipCompressingEntity.java
index ba2e67189..a08b64212 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/GzipCompressingEntity.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/GzipCompressingEntity.java
@@ -101,9 +101,9 @@ public class GzipCompressingEntity extends HttpEntityWrapper {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final GZIPOutputStream gzip = new GZIPOutputStream(outstream);
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final GZIPOutputStream gzip = new GZIPOutputStream(outStream);
wrappedEntity.writeTo(gzip);
// Only close output stream if the wrapped entity has been
// successfully written out
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/GzipDecompressingEntity.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/GzipDecompressingEntity.java
index ae19a7a20..624fa26aa 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/GzipDecompressingEntity.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/GzipDecompressingEntity.java
@@ -26,15 +26,10 @@
*/
package com.fr.third.org.apache.http.client.entity;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.GZIPInputStream;
-
-import com.fr.third.org.apache.http.entity.HttpEntityWrapper;
import com.fr.third.org.apache.http.HttpEntity;
/**
- * {@link HttpEntityWrapper} for handling gzip
+ * {@link com.fr.third.org.apache.http.entity.HttpEntityWrapper} for handling gzip
* Content Coded responses.
*
* @since 4.1
@@ -49,14 +44,7 @@ public class GzipDecompressingEntity extends DecompressingEntity {
* the non-null {@link HttpEntity} to be wrapped
*/
public GzipDecompressingEntity(final HttpEntity entity) {
- super(entity, new InputStreamFactory() {
-
- @Override
- public InputStream create(final InputStream instream) throws IOException {
- return new GZIPInputStream(instream);
- }
-
- });
+ super(entity, GZIPInputStreamFactory.getInstance());
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/InputStreamFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/InputStreamFactory.java
index 33656eb68..3f54db0fa 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/InputStreamFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/entity/InputStreamFactory.java
@@ -30,12 +30,12 @@ import java.io.IOException;
import java.io.InputStream;
/**
- * Factory for decorated {@link java.io.InputStream}s.
+ * Factory for decorated {@link InputStream}s.
*
* @since 4.4
*/
public interface InputStreamFactory {
- InputStream create(InputStream instream) throws IOException;
+ InputStream create(InputStream inStream) throws IOException;
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/AbortableHttpRequest.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/AbortableHttpRequest.java
index 675a56975..323efefa1 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/AbortableHttpRequest.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/AbortableHttpRequest.java
@@ -27,12 +27,6 @@
package com.fr.third.org.apache.http.client.methods;
-import com.fr.third.org.apache.http.HttpHost;
-import com.fr.third.org.apache.http.HttpRequest;
-import com.fr.third.org.apache.http.client.HttpClient;
-import com.fr.third.org.apache.http.conn.ClientConnectionManager;
-import com.fr.third.org.apache.http.conn.ManagedClientConnection;
-import com.fr.third.org.apache.http.protocol.HttpContext;
import com.fr.third.org.apache.http.conn.ClientConnectionRequest;
import com.fr.third.org.apache.http.conn.ConnectionReleaseTrigger;
@@ -51,11 +45,11 @@ import java.io.IOException;
public interface AbortableHttpRequest {
/**
- * Sets the {@link ClientConnectionRequest}
+ * Sets the {@link com.fr.third.org.apache.http.conn.ClientConnectionRequest}
* callback that can be used to abort a long-lived request for a connection.
* If the request is already aborted, throws an {@link IOException}.
*
- * @see ClientConnectionManager
+ * @see com.fr.third.org.apache.http.conn.ClientConnectionManager
*/
void setConnectionRequest(ClientConnectionRequest connRequest) throws IOException;
@@ -63,7 +57,7 @@ public interface AbortableHttpRequest {
* Sets the {@link ConnectionReleaseTrigger} callback that can
* be used to abort an active connection.
* Typically, this will be the
- * {@link ManagedClientConnection} itself.
+ * {@link com.fr.third.org.apache.http.conn.ManagedClientConnection} itself.
* If the request is already aborted, throws an {@link IOException}.
*/
void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) throws IOException;
@@ -74,13 +68,13 @@ public interface AbortableHttpRequest {
* the next execution. Aborting this request will cause all subsequent
* executions with this request to fail.
*
- * @see HttpClient#execute(HttpUriRequest)
- * @see HttpClient#execute(HttpHost,
- * HttpRequest)
- * @see HttpClient#execute(HttpUriRequest,
- * HttpContext)
- * @see HttpClient#execute(HttpHost,
- * HttpRequest, HttpContext)
+ * @see com.fr.third.org.apache.http.client.HttpClient#execute(HttpUriRequest)
+ * @see com.fr.third.org.apache.http.client.HttpClient#execute(org.apache.http.HttpHost,
+ * com.fr.third.org.apache.http.HttpRequest)
+ * @see com.fr.third.org.apache.http.client.HttpClient#execute(HttpUriRequest,
+ * com.fr.third.org.apache.http.protocol.HttpContext)
+ * @see com.fr.third.org.apache.http.client.HttpClient#execute(org.apache.http.HttpHost,
+ * com.fr.third.org.apache.http.HttpRequest, com.fr.third.org.apache.http.protocol.HttpContext)
*/
void abort();
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/AbstractExecutionAwareRequest.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/AbstractExecutionAwareRequest.java
index 05921ef9b..4b10786bc 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/AbstractExecutionAwareRequest.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/AbstractExecutionAwareRequest.java
@@ -27,8 +27,7 @@
package com.fr.third.org.apache.http.client.methods;
import java.io.IOException;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
+import java.util.concurrent.atomic.AtomicMarkableReference;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.client.utils.CloneUtils;
@@ -41,15 +40,16 @@ import com.fr.third.org.apache.http.message.AbstractHttpMessage;
public abstract class AbstractExecutionAwareRequest extends AbstractHttpMessage implements
HttpExecutionAware, AbortableHttpRequest, Cloneable, HttpRequest {
- private final AtomicBoolean aborted;
- private final AtomicReference cancellableRef;
+ private final AtomicMarkableReference cancellableRef;
protected AbstractExecutionAwareRequest() {
super();
- this.aborted = new AtomicBoolean(false);
- this.cancellableRef = new AtomicReference(null);
+ this.cancellableRef = new AtomicMarkableReference(null, false);
}
+ /**
+ * @deprecated Use {@link #setCancellable(Cancellable)}
+ */
@Override
@Deprecated
public void setConnectionRequest(final ClientConnectionRequest connRequest) {
@@ -64,6 +64,9 @@ public abstract class AbstractExecutionAwareRequest extends AbstractHttpMessage
});
}
+ /**
+ * @deprecated Use {@link #setCancellable(Cancellable)}
+ */
@Override
@Deprecated
public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger) {
@@ -84,17 +87,19 @@ public abstract class AbstractExecutionAwareRequest extends AbstractHttpMessage
@Override
public void abort() {
- if (this.aborted.compareAndSet(false, true)) {
- final Cancellable cancellable = this.cancellableRef.getAndSet(null);
- if (cancellable != null) {
- cancellable.cancel();
+ while (!cancellableRef.isMarked()) {
+ final Cancellable actualCancellable = cancellableRef.getReference();
+ if (cancellableRef.compareAndSet(actualCancellable, actualCancellable, false, true)) {
+ if (actualCancellable != null) {
+ actualCancellable.cancel();
+ }
}
}
}
@Override
public boolean isAborted() {
- return this.aborted.get();
+ return this.cancellableRef.isMarked();
}
/**
@@ -102,8 +107,9 @@ public abstract class AbstractExecutionAwareRequest extends AbstractHttpMessage
*/
@Override
public void setCancellable(final Cancellable cancellable) {
- if (!this.aborted.get()) {
- this.cancellableRef.set(cancellable);
+ final Cancellable actualCancellable = cancellableRef.getReference();
+ if (!cancellableRef.compareAndSet(actualCancellable, cancellable, false, false)) {
+ cancellable.cancel();
}
}
@@ -117,9 +123,12 @@ public abstract class AbstractExecutionAwareRequest extends AbstractHttpMessage
/**
* @since 4.2
+ *
+ * @deprecated Do not use.
*/
+ @Deprecated
public void completed() {
- this.cancellableRef.set(null);
+ this.cancellableRef.set(null, false);
}
/**
@@ -128,11 +137,16 @@ public abstract class AbstractExecutionAwareRequest extends AbstractHttpMessage
* @since 4.2
*/
public void reset() {
- final Cancellable cancellable = this.cancellableRef.getAndSet(null);
- if (cancellable != null) {
- cancellable.cancel();
+ for (;;) {
+ final boolean marked = cancellableRef.isMarked();
+ final Cancellable actualCancellable = cancellableRef.getReference();
+ if (actualCancellable != null) {
+ actualCancellable.cancel();
+ }
+ if (cancellableRef.compareAndSet(actualCancellable, null, marked, false)) {
+ break;
+ }
}
- this.aborted.set(false);
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/HttpRequestWrapper.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/HttpRequestWrapper.java
index 9529f09b3..32f0d96b1 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/HttpRequestWrapper.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/HttpRequestWrapper.java
@@ -36,7 +36,6 @@ import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.ProtocolVersion;
import com.fr.third.org.apache.http.RequestLine;
-import com.fr.third.org.apache.http.client.config.RequestConfig;
import com.fr.third.org.apache.http.message.AbstractHttpMessage;
import com.fr.third.org.apache.http.message.BasicRequestLine;
import com.fr.third.org.apache.http.params.HttpParams;
@@ -190,16 +189,15 @@ public class HttpRequestWrapper extends AbstractHttpMessage implements HttpUriRe
*/
public static HttpRequestWrapper wrap(final HttpRequest request, final HttpHost target) {
Args.notNull(request, "HTTP request");
- if (request instanceof HttpEntityEnclosingRequest) {
- return new HttpEntityEnclosingRequestWrapper((HttpEntityEnclosingRequest) request, target);
- } else {
- return new HttpRequestWrapper(request, target);
- }
+ return request instanceof HttpEntityEnclosingRequest
+ ? new HttpEntityEnclosingRequestWrapper(
+ (HttpEntityEnclosingRequest) request, target)
+ : new HttpRequestWrapper(request, target);
}
/**
* @deprecated (4.3) use
- * {@link RequestConfig}.
+ * {@link com.fr.third.org.apache.http.client.config.RequestConfig}.
*/
@Override
@Deprecated
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/RequestBuilder.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/RequestBuilder.java
index e226cd853..e20259b81 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/RequestBuilder.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/methods/RequestBuilder.java
@@ -59,7 +59,7 @@ import com.fr.third.org.apache.http.util.Args;
*
* Please note that this class treats parameters differently depending on composition
* of the request: if the request has a content entity explicitly set with
- * {@link #setEntity(HttpEntity)} or it is not an entity enclosing method
+ * {@link #setEntity(org.apache.http.HttpEntity)} or it is not an entity enclosing method
* (such as POST or PUT), parameters will be added to the query component of the request URI.
* Otherwise, parameters will be added as a URL encoded {@link UrlEncodedFormEntity entity}.
*
@@ -72,7 +72,7 @@ public class RequestBuilder {
private Charset charset;
private ProtocolVersion version;
private URI uri;
- private HeaderGroup headergroup;
+ private HeaderGroup headerGroup;
private HttpEntity entity;
private List parameters;
private RequestConfig config;
@@ -263,11 +263,11 @@ public class RequestBuilder {
method = request.getRequestLine().getMethod();
version = request.getRequestLine().getProtocolVersion();
- if (headergroup == null) {
- headergroup = new HeaderGroup();
+ if (headerGroup == null) {
+ headerGroup = new HeaderGroup();
}
- headergroup.clear();
- headergroup.setHeaders(request.getAllHeaders());
+ headerGroup.clear();
+ headerGroup.setHeaders(request.getAllHeaders());
parameters = null;
entity = null;
@@ -347,46 +347,46 @@ public class RequestBuilder {
}
public Header getFirstHeader(final String name) {
- return headergroup != null ? headergroup.getFirstHeader(name) : null;
+ return headerGroup != null ? headerGroup.getFirstHeader(name) : null;
}
public Header getLastHeader(final String name) {
- return headergroup != null ? headergroup.getLastHeader(name) : null;
+ return headerGroup != null ? headerGroup.getLastHeader(name) : null;
}
public Header[] getHeaders(final String name) {
- return headergroup != null ? headergroup.getHeaders(name) : null;
+ return headerGroup != null ? headerGroup.getHeaders(name) : null;
}
public RequestBuilder addHeader(final Header header) {
- if (headergroup == null) {
- headergroup = new HeaderGroup();
+ if (headerGroup == null) {
+ headerGroup = new HeaderGroup();
}
- headergroup.addHeader(header);
+ headerGroup.addHeader(header);
return this;
}
public RequestBuilder addHeader(final String name, final String value) {
- if (headergroup == null) {
- headergroup = new HeaderGroup();
+ if (headerGroup == null) {
+ headerGroup = new HeaderGroup();
}
- this.headergroup.addHeader(new BasicHeader(name, value));
+ this.headerGroup.addHeader(new BasicHeader(name, value));
return this;
}
public RequestBuilder removeHeader(final Header header) {
- if (headergroup == null) {
- headergroup = new HeaderGroup();
+ if (headerGroup == null) {
+ headerGroup = new HeaderGroup();
}
- headergroup.removeHeader(header);
+ headerGroup.removeHeader(header);
return this;
}
public RequestBuilder removeHeaders(final String name) {
- if (name == null || headergroup == null) {
+ if (name == null || headerGroup == null) {
return this;
}
- for (final HeaderIterator i = headergroup.iterator(); i.hasNext(); ) {
+ for (final HeaderIterator i = headerGroup.iterator(); i.hasNext(); ) {
final Header header = i.nextHeader();
if (name.equalsIgnoreCase(header.getName())) {
i.remove();
@@ -396,18 +396,18 @@ public class RequestBuilder {
}
public RequestBuilder setHeader(final Header header) {
- if (headergroup == null) {
- headergroup = new HeaderGroup();
+ if (headerGroup == null) {
+ headerGroup = new HeaderGroup();
}
- this.headergroup.updateHeader(header);
+ this.headerGroup.updateHeader(header);
return this;
}
public RequestBuilder setHeader(final String name, final String value) {
- if (headergroup == null) {
- headergroup = new HeaderGroup();
+ if (headerGroup == null) {
+ headerGroup = new HeaderGroup();
}
- this.headergroup.updateHeader(new BasicHeader(name, value));
+ this.headerGroup.updateHeader(new BasicHeader(name, value));
return this;
}
@@ -482,8 +482,8 @@ public class RequestBuilder {
}
result.setProtocolVersion(this.version);
result.setURI(uriNotNull);
- if (this.headergroup != null) {
- result.setHeaders(this.headergroup.getAllHeaders());
+ if (this.headerGroup != null) {
+ result.setHeaders(this.headerGroup.getAllHeaders());
}
result.setConfig(this.config);
return result;
@@ -521,4 +521,27 @@ public class RequestBuilder {
}
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("RequestBuilder [method=");
+ builder.append(method);
+ builder.append(", charset=");
+ builder.append(charset);
+ builder.append(", version=");
+ builder.append(version);
+ builder.append(", uri=");
+ builder.append(uri);
+ builder.append(", headerGroup=");
+ builder.append(headerGroup);
+ builder.append(", entity=");
+ builder.append(entity);
+ builder.append(", parameters=");
+ builder.append(parameters);
+ builder.append(", config=");
+ builder.append(config);
+ builder.append("]");
+ return builder.toString();
+ }
+
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/params/AllClientPNames.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/params/AllClientPNames.java
index 3982401ed..18239f51f 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/params/AllClientPNames.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/params/AllClientPNames.java
@@ -26,9 +26,6 @@
*/
package com.fr.third.org.apache.http.client.params;
-import com.fr.third.org.apache.http.client.config.RequestConfig;
-import com.fr.third.org.apache.http.config.ConnectionConfig;
-import com.fr.third.org.apache.http.config.SocketConfig;
import com.fr.third.org.apache.http.auth.params.AuthPNames;
import com.fr.third.org.apache.http.conn.params.ConnConnectionPNames;
import com.fr.third.org.apache.http.conn.params.ConnManagerPNames;
@@ -52,9 +49,9 @@ import com.fr.third.org.apache.http.params.CoreProtocolPNames;
* @since 4.0
*
* @deprecated (4.3) use
- * {@link RequestConfig},
- * {@link ConnectionConfig},
- * {@link SocketConfig}
+ * {@link com.fr.third.org.apache.http.client.config.RequestConfig},
+ * {@link com.fr.third.org.apache.http.config.ConnectionConfig},
+ * {@link com.fr.third.org.apache.http.config.SocketConfig}
*/
@Deprecated
public interface AllClientPNames extends
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/params/ClientPNames.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/params/ClientPNames.java
index 880ab5244..63bda93a1 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/params/ClientPNames.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/params/ClientPNames.java
@@ -26,18 +26,12 @@
*/
package com.fr.third.org.apache.http.client.params;
-import com.fr.third.org.apache.http.Header;
-import com.fr.third.org.apache.http.HttpHost;
-import com.fr.third.org.apache.http.client.config.RequestConfig;
-import com.fr.third.org.apache.http.conn.ClientConnectionManager;
-import com.fr.third.org.apache.http.conn.ManagedClientConnection;
-
/**
* Parameter names for HTTP client parameters.
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig}.
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.client.config.RequestConfig}.
*/
@Deprecated
public interface ClientPNames {
@@ -100,7 +94,7 @@ public interface ClientPNames {
* Defines the virtual host to be used in the {@code Host}
* request header instead of the physical host.
*
- * This parameter expects a value of type {@link HttpHost}.
+ * This parameter expects a value of type {@link com.fr.third.org.apache.http.HttpHost}.
*
* If a port is not provided, it will be derived from the request URL.
*/
@@ -110,7 +104,7 @@ public interface ClientPNames {
* Defines the request headers to be sent per default with each request.
*
* This parameter expects a value of type {@link java.util.Collection}. The
- * collection is expected to contain {@link Header}s.
+ * collection is expected to contain {@link com.fr.third.org.apache.http.Header}s.
*
*/
public static final String DEFAULT_HEADERS = "http.default-headers";
@@ -119,15 +113,15 @@ public interface ClientPNames {
* Defines the default host. The default value will be used if the target host is
* not explicitly specified in the request URI.
*
- * This parameter expects a value of type {@link HttpHost}.
+ * This parameter expects a value of type {@link com.fr.third.org.apache.http.HttpHost}.
*
*/
public static final String DEFAULT_HOST = "http.default-host";
/**
* Defines the timeout in milliseconds used when retrieving an instance of
- * {@link ManagedClientConnection} from the
- * {@link ClientConnectionManager}.
+ * {@link com.fr.third.org.apache.http.conn.ManagedClientConnection} from the
+ * {@link com.fr.third.org.apache.http.conn.ClientConnectionManager}.
*
* This parameter expects a value of type {@link Long}.
*
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/protocol/HttpClientContext.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/protocol/HttpClientContext.java
index 7406a4b3d..5b9bdd2e1 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/protocol/HttpClientContext.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/protocol/HttpClientContext.java
@@ -56,7 +56,7 @@ import com.fr.third.org.apache.http.protocol.HttpCoreContext;
public class HttpClientContext extends HttpCoreContext {
/**
- * Attribute name of a {@link RouteInfo}
+ * Attribute name of a {@link com.fr.third.org.apache.http.conn.routing.RouteInfo}
* object that represents the actual connection route.
*/
public static final String HTTP_ROUTE = "http.route";
@@ -68,77 +68,75 @@ public class HttpClientContext extends HttpCoreContext {
public static final String REDIRECT_LOCATIONS = "http.protocol.redirect-locations";
/**
- * Attribute name of a {@link Lookup} object that represents
+ * Attribute name of a {@link com.fr.third.org.apache.http.config.Lookup} object that represents
* the actual {@link CookieSpecProvider} registry.
*/
public static final String COOKIESPEC_REGISTRY = "http.cookiespec-registry";
/**
- * Attribute name of a {@link CookieSpec}
+ * Attribute name of a {@link com.fr.third.org.apache.http.cookie.CookieSpec}
* object that represents the actual cookie specification.
*/
public static final String COOKIE_SPEC = "http.cookie-spec";
/**
- * Attribute name of a {@link CookieOrigin}
+ * Attribute name of a {@link com.fr.third.org.apache.http.cookie.CookieOrigin}
* object that represents the actual details of the origin server.
*/
public static final String COOKIE_ORIGIN = "http.cookie-origin";
/**
- * Attribute name of a {@link CookieStore}
+ * Attribute name of a {@link com.fr.third.org.apache.http.client.CookieStore}
* object that represents the actual cookie store.
*/
public static final String COOKIE_STORE = "http.cookie-store";
/**
- * Attribute name of a {@link CredentialsProvider}
+ * Attribute name of a {@link com.fr.third.org.apache.http.client.CredentialsProvider}
* object that represents the actual credentials provider.
*/
public static final String CREDS_PROVIDER = "http.auth.credentials-provider";
/**
- * Attribute name of a {@link AuthCache} object
+ * Attribute name of a {@link com.fr.third.org.apache.http.client.AuthCache} object
* that represents the auth scheme cache.
*/
public static final String AUTH_CACHE = "http.auth.auth-cache";
/**
- * Attribute name of a {@link AuthState}
+ * Attribute name of a {@link com.fr.third.org.apache.http.auth.AuthState}
* object that represents the actual target authentication state.
*/
public static final String TARGET_AUTH_STATE = "http.auth.target-scope";
/**
- * Attribute name of a {@link AuthState}
+ * Attribute name of a {@link com.fr.third.org.apache.http.auth.AuthState}
* object that represents the actual proxy authentication state.
*/
public static final String PROXY_AUTH_STATE = "http.auth.proxy-scope";
/**
- * Attribute name of a {@link java.lang.Object} object that represents
+ * Attribute name of a {@link Object} object that represents
* the actual user identity such as user {@link java.security.Principal}.
*/
public static final String USER_TOKEN = "http.user-token";
/**
- * Attribute name of a {@link Lookup} object that represents
+ * Attribute name of a {@link com.fr.third.org.apache.http.config.Lookup} object that represents
* the actual {@link AuthSchemeProvider} registry.
*/
public static final String AUTHSCHEME_REGISTRY = "http.authscheme-registry";
/**
- * Attribute name of a {@link RequestConfig} object that
+ * Attribute name of a {@link com.fr.third.org.apache.http.client.config.RequestConfig} object that
* represents the actual request configuration.
*/
public static final String REQUEST_CONFIG = "http.request-config";
public static HttpClientContext adapt(final HttpContext context) {
- if (context instanceof HttpClientContext) {
- return (HttpClientContext) context;
- } else {
- return new HttpClientContext(context);
- }
+ return context instanceof HttpClientContext
+ ? (HttpClientContext) context
+ : new HttpClientContext(context);
}
public static HttpClientContext create() {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/protocol/RequestAuthCache.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/protocol/RequestAuthCache.java
index bc9137c4f..5a3d75d64 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/protocol/RequestAuthCache.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/protocol/RequestAuthCache.java
@@ -135,11 +135,6 @@ public class RequestAuthCache implements HttpRequestInterceptor {
final Credentials creds = credsProvider.getCredentials(authScope);
if (creds != null) {
- if ("BASIC".equalsIgnoreCase(authScheme.getSchemeName())) {
- authState.setState(AuthProtocolState.CHALLENGED);
- } else {
- authState.setState(AuthProtocolState.SUCCESS);
- }
authState.update(authScheme, creds);
} else {
this.log.debug("No credentials for preemptive authentication");
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/protocol/ResponseContentEncoding.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/protocol/ResponseContentEncoding.java
index 0fb2c8dfe..af77bac16 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/protocol/ResponseContentEncoding.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/protocol/ResponseContentEncoding.java
@@ -27,9 +27,7 @@
package com.fr.third.org.apache.http.client.protocol;
import java.io.IOException;
-import java.io.InputStream;
import java.util.Locale;
-import java.util.zip.GZIPInputStream;
import com.fr.third.org.apache.http.Header;
import com.fr.third.org.apache.http.HeaderElement;
@@ -41,7 +39,8 @@ import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.client.config.RequestConfig;
import com.fr.third.org.apache.http.client.entity.DecompressingEntity;
-import com.fr.third.org.apache.http.client.entity.DeflateInputStream;
+import com.fr.third.org.apache.http.client.entity.DeflateInputStreamFactory;
+import com.fr.third.org.apache.http.client.entity.GZIPInputStreamFactory;
import com.fr.third.org.apache.http.client.entity.InputStreamFactory;
import com.fr.third.org.apache.http.config.Lookup;
import com.fr.third.org.apache.http.config.RegistryBuilder;
@@ -61,23 +60,6 @@ public class ResponseContentEncoding implements HttpResponseInterceptor {
public static final String UNCOMPRESSED = "http.client.response.uncompressed";
- private final static InputStreamFactory GZIP = new InputStreamFactory() {
-
- @Override
- public InputStream create(final InputStream instream) throws IOException {
- return new GZIPInputStream(instream);
- }
- };
-
- private final static InputStreamFactory DEFLATE = new InputStreamFactory() {
-
- @Override
- public InputStream create(final InputStream instream) throws IOException {
- return new DeflateInputStream(instream);
- }
-
- };
-
private final Lookup decoderRegistry;
private final boolean ignoreUnknown;
@@ -87,9 +69,9 @@ public class ResponseContentEncoding implements HttpResponseInterceptor {
public ResponseContentEncoding(final Lookup decoderRegistry, final boolean ignoreUnknown) {
this.decoderRegistry = decoderRegistry != null ? decoderRegistry :
RegistryBuilder.create()
- .register("gzip", GZIP)
- .register("x-gzip", GZIP)
- .register("deflate", DEFLATE)
+ .register("gzip", GZIPInputStreamFactory.getInstance())
+ .register("x-gzip", GZIPInputStreamFactory.getInstance())
+ .register("deflate", DeflateInputStreamFactory.getInstance())
.build();
this.ignoreUnknown = ignoreUnknown;
}
@@ -112,8 +94,8 @@ public class ResponseContentEncoding implements HttpResponseInterceptor {
* Handles {@code gzip} and {@code deflate} compressed entities by using the following
* decoders:
*
- *
gzip - see {@link GZIPInputStream}
- *
deflate - see {@link DeflateInputStream}
+ *
gzip - see {@link java.util.zip.GZIPInputStream}
+ *
deflate - see {@link com.fr.third.org.apache.http.client.entity.DeflateInputStream}
*
*/
public ResponseContentEncoding() {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/CloneUtils.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/CloneUtils.java
index 13e12b933..1fcf1a97f 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/CloneUtils.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/CloneUtils.java
@@ -59,15 +59,13 @@ public class CloneUtils {
final Throwable cause = ex.getCause();
if (cause instanceof CloneNotSupportedException) {
throw ((CloneNotSupportedException) cause);
- } else {
- throw new Error("Unexpected exception", cause);
}
+ throw new Error("Unexpected exception", cause);
} catch (final IllegalAccessException ex) {
throw new IllegalAccessError(ex.getMessage());
}
- } else {
- throw new CloneNotSupportedException();
}
+ throw new CloneNotSupportedException();
}
public static Object clone(final Object obj) throws CloneNotSupportedException {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/URIBuilder.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/URIBuilder.java
index b74fadfff..ec8ab6b47 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/URIBuilder.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/URIBuilder.java
@@ -30,6 +30,8 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -37,6 +39,7 @@ import com.fr.third.org.apache.http.Consts;
import com.fr.third.org.apache.http.NameValuePair;
import com.fr.third.org.apache.http.conn.util.InetAddressUtils;
import com.fr.third.org.apache.http.message.BasicNameValuePair;
+import com.fr.third.org.apache.http.util.TextUtils;
/**
* Builder for {@link URI} instances.
@@ -52,8 +55,8 @@ public class URIBuilder {
private String encodedUserInfo;
private String host;
private int port;
- private String path;
private String encodedPath;
+ private List pathSegments;
private String encodedQuery;
private List queryParams;
private String query;
@@ -76,8 +79,7 @@ public class URIBuilder {
* @throws URISyntaxException if the input is not a valid URI
*/
public URIBuilder(final String string) throws URISyntaxException {
- super();
- digestURI(new URI(string));
+ this(new URI(string), null);
}
/**
@@ -85,7 +87,26 @@ public class URIBuilder {
* @param uri
*/
public URIBuilder(final URI uri) {
+ this(uri, null);
+ }
+
+ /**
+ * Construct an instance from the string which must be a valid URI.
+ *
+ * @param string a valid URI in string form
+ * @throws URISyntaxException if the input is not a valid URI
+ */
+ public URIBuilder(final String string, final Charset charset) throws URISyntaxException {
+ this(new URI(string), charset);
+ }
+
+ /**
+ * Construct an instance from the provided URI.
+ * @param uri
+ */
+ public URIBuilder(final URI uri, final Charset charset) {
super();
+ setCharset(charset);
digestURI(uri);
}
@@ -111,6 +132,13 @@ public class URIBuilder {
return null;
}
+ private List parsePath(final String path, final Charset charset) {
+ if (path != null && !path.isEmpty()) {
+ return URLEncodedUtils.parsePathSegments(path, charset);
+ }
+ return null;
+ }
+
/**
* Builds a {@link URI} instance.
*/
@@ -145,13 +173,13 @@ public class URIBuilder {
}
}
if (this.encodedPath != null) {
- sb.append(normalizePath(this.encodedPath));
- } else if (this.path != null) {
- sb.append(encodePath(normalizePath(this.path)));
+ sb.append(normalizePath(this.encodedPath, sb.length() == 0));
+ } else if (this.pathSegments != null) {
+ sb.append(encodePath(this.pathSegments));
}
if (this.encodedQuery != null) {
sb.append("?").append(this.encodedQuery);
- } else if (this.queryParams != null) {
+ } else if (this.queryParams != null && !this.queryParams.isEmpty()) {
sb.append("?").append(encodeUrlForm(this.queryParams));
} else if (this.query != null) {
sb.append("?").append(encodeUric(this.query));
@@ -165,6 +193,17 @@ public class URIBuilder {
return sb.toString();
}
+ private static String normalizePath(final String path, final boolean relative) {
+ String s = path;
+ if (TextUtils.isBlank(s)) {
+ return "";
+ }
+ if (!relative && !s.startsWith("/")) {
+ s = "/" + s;
+ }
+ return s;
+ }
+
private void digestURI(final URI uri) {
this.scheme = uri.getScheme();
this.encodedSchemeSpecificPart = uri.getRawSchemeSpecificPart();
@@ -174,7 +213,7 @@ public class URIBuilder {
this.encodedUserInfo = uri.getRawUserInfo();
this.userInfo = uri.getUserInfo();
this.encodedPath = uri.getRawPath();
- this.path = uri.getPath();
+ this.pathSegments = parsePath(uri.getRawPath(), this.charset != null ? this.charset : Consts.UTF_8);
this.encodedQuery = uri.getRawQuery();
this.queryParams = parseQuery(uri.getRawQuery(), this.charset != null ? this.charset : Consts.UTF_8);
this.encodedFragment = uri.getRawFragment();
@@ -185,8 +224,8 @@ public class URIBuilder {
return URLEncodedUtils.encUserInfo(userInfo, this.charset != null ? this.charset : Consts.UTF_8);
}
- private String encodePath(final String path) {
- return URLEncodedUtils.encPath(path, this.charset != null ? this.charset : Consts.UTF_8);
+ private String encodePath(final List pathSegments) {
+ return URLEncodedUtils.formatSegments(pathSegments, this.charset != null ? this.charset : Consts.UTF_8);
}
private String encodeUrlForm(final List params) {
@@ -247,9 +286,36 @@ public class URIBuilder {
/**
* Sets URI path. The value is expected to be unescaped and may contain non ASCII characters.
+ *
+ * @return this.
*/
public URIBuilder setPath(final String path) {
- this.path = path;
+ return setPathSegments(path != null ? URLEncodedUtils.splitPathSegments(path) : null);
+ }
+
+ /**
+ * Sets URI path. The value is expected to be unescaped and may contain non ASCII characters.
+ *
+ * @return this.
+ *
+ * @since 4.5.8
+ */
+ public URIBuilder setPathSegments(final String... pathSegments) {
+ this.pathSegments = pathSegments.length > 0 ? Arrays.asList(pathSegments) : null;
+ this.encodedSchemeSpecificPart = null;
+ this.encodedPath = null;
+ return this;
+ }
+
+ /**
+ * Sets URI path. The value is expected to be unescaped and may contain non ASCII characters.
+ *
+ * @return this.
+ *
+ * @since 4.5.8
+ */
+ public URIBuilder setPathSegments(final List pathSegments) {
+ this.pathSegments = pathSegments != null && pathSegments.size() > 0 ? new ArrayList(pathSegments) : null;
this.encodedSchemeSpecificPart = null;
this.encodedPath = null;
return this;
@@ -450,7 +516,7 @@ public class URIBuilder {
* @since 4.3
*/
public boolean isOpaque() {
- return this.path == null;
+ return this.pathSegments == null && this.encodedPath == null;
}
public String getScheme() {
@@ -469,16 +535,41 @@ public class URIBuilder {
return this.port;
}
+ /**
+ * @since 4.5.8
+ */
+ public boolean isPathEmpty() {
+ return (this.pathSegments == null || this.pathSegments.isEmpty()) &&
+ (this.encodedPath == null || this.encodedPath.isEmpty());
+ }
+
+ /**
+ * @since 4.5.8
+ */
+ public List getPathSegments() {
+ return this.pathSegments != null ? new ArrayList(this.pathSegments) : Collections.emptyList();
+ }
+
public String getPath() {
- return this.path;
+ if (this.pathSegments == null) {
+ return null;
+ }
+ final StringBuilder result = new StringBuilder();
+ for (final String segment : this.pathSegments) {
+ result.append('/').append(segment);
+ }
+ return result.toString();
+ }
+
+ /**
+ * @since 4.5.8
+ */
+ public boolean isQueryEmpty() {
+ return (this.queryParams == null || this.queryParams.isEmpty()) && this.encodedQuery == null;
}
public List getQueryParams() {
- if (this.queryParams != null) {
- return new ArrayList(this.queryParams);
- } else {
- return new ArrayList();
- }
+ return this.queryParams != null ? new ArrayList(this.queryParams) : Collections.emptyList();
}
public String getFragment() {
@@ -490,24 +581,4 @@ public class URIBuilder {
return buildString();
}
- private static String normalizePath(final String path) {
- String s = path;
- if (s == null) {
- return "/";
- }
- int n = 0;
- for (; n < s.length(); n++) {
- if (s.charAt(n) != '/') {
- break;
- }
- }
- if (n > 1) {
- s = s.substring(n - 1);
- }
- if (!s.startsWith("/")) {
- s = "/" + s;
- }
- return s;
- }
-
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/URIUtils.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/URIUtils.java
index 5408eb216..e711e82eb 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/URIUtils.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/URIUtils.java
@@ -28,6 +28,9 @@ package com.fr.third.org.apache.http.client.utils;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Stack;
@@ -45,6 +48,44 @@ import com.fr.third.org.apache.http.util.TextUtils;
*/
public class URIUtils {
+ /**
+ * Flags that control how URI is being rewritten.
+ *
+ * @since 4.5.8
+ */
+ public enum UriFlag {
+ DROP_FRAGMENT,
+ NORMALIZE
+ }
+
+ /**
+ * Empty set of uri flags.
+ *
+ * @since 4.5.8
+ */
+ public static final EnumSet NO_FLAGS = EnumSet.noneOf(UriFlag.class);
+
+ /**
+ * Set of uri flags containing {@link UriFlag#DROP_FRAGMENT}.
+ *
+ * @since 4.5.8
+ */
+ public static final EnumSet DROP_FRAGMENT = EnumSet.of(UriFlag.DROP_FRAGMENT);
+
+ /**
+ * Set of uri flags containing {@link UriFlag#NORMALIZE}.
+ *
+ * @since 4.5.8
+ */
+ public static final EnumSet NORMALIZE = EnumSet.of(UriFlag.NORMALIZE);
+
+ /**
+ * Set of uri flags containing {@link UriFlag#DROP_FRAGMENT} and {@link UriFlag#NORMALIZE}.
+ *
+ * @since 4.5.8
+ */
+ public static final EnumSet DROP_FRAGMENT_AND_NORMALIZE = EnumSet.of(UriFlag.DROP_FRAGMENT, UriFlag.NORMALIZE);
+
/**
* Constructs a {@link URI} using all the parameters. This should be
* used instead of
@@ -125,12 +166,40 @@ public class URIUtils {
*
* @throws URISyntaxException
* If the resulting URI is invalid.
+ * @deprecated (4.5.8) Use {@link #rewriteURI(URI, HttpHost, EnumSet)}
+ */
+ @Deprecated
+ public static URI rewriteURI(
+ final URI uri,
+ final HttpHost target,
+ final boolean dropFragment) throws URISyntaxException
+ {
+ return rewriteURI(uri, target, dropFragment ? DROP_FRAGMENT : NO_FLAGS);
+ }
+
+ /**
+ * A convenience method for creating a new {@link URI} whose scheme, host
+ * and port are taken from the target host, but whose path, query and
+ * fragment are taken from the existing URI. What exactly is used and how
+ * is driven by the passed in flags. The path is set to "/" if not explicitly specified.
+ *
+ * @param uri
+ * Contains the path, query and fragment to use.
+ * @param target
+ * Contains the scheme, host and port to use.
+ * @param flags
+ * True if the fragment should not be copied.
+ *
+ * @throws URISyntaxException
+ * If the resulting URI is invalid.
+ * @since 4.5.8
*/
public static URI rewriteURI(
final URI uri,
final HttpHost target,
- final boolean dropFragment) throws URISyntaxException {
+ final EnumSet flags) throws URISyntaxException {
Args.notNull(uri, "URI");
+ Args.notNull(flags, "URI flags");
if (uri.isOpaque()) {
return uri;
}
@@ -144,24 +213,37 @@ public class URIUtils {
uribuilder.setHost(null);
uribuilder.setPort(-1);
}
- if (dropFragment) {
+ if (flags.contains(UriFlag.DROP_FRAGMENT)) {
uribuilder.setFragment(null);
}
- if (TextUtils.isEmpty(uribuilder.getPath())) {
- uribuilder.setPath("/");
+ if (flags.contains(UriFlag.NORMALIZE)) {
+ final List originalPathSegments = uribuilder.getPathSegments();
+ final List pathSegments = new ArrayList(originalPathSegments);
+ for (final Iterator it = pathSegments.iterator(); it.hasNext(); ) {
+ final String pathSegment = it.next();
+ if (pathSegment.isEmpty() && it.hasNext()) {
+ it.remove();
+ }
+ }
+ if (pathSegments.size() != originalPathSegments.size()) {
+ uribuilder.setPathSegments(pathSegments);
+ }
+ }
+ if (uribuilder.isPathEmpty()) {
+ uribuilder.setPathSegments("");
}
return uribuilder.build();
}
/**
* A convenience method for
- * {@link URIUtils#rewriteURI(URI, HttpHost, boolean)} that always keeps the
+ * {@link URIUtils#rewriteURI(URI, HttpHost, EnumSet)} that always keeps the
* fragment.
*/
public static URI rewriteURI(
final URI uri,
final HttpHost target) throws URISyntaxException {
- return rewriteURI(uri, target, false);
+ return rewriteURI(uri, target, NORMALIZE);
}
/**
@@ -184,6 +266,9 @@ public class URIUtils {
if (uribuilder.getUserInfo() != null) {
uribuilder.setUserInfo(null);
}
+ if (uribuilder.getPathSegments().isEmpty()) {
+ uribuilder.setPathSegments("");
+ }
if (TextUtils.isEmpty(uribuilder.getPath())) {
uribuilder.setPath("/");
}
@@ -195,7 +280,7 @@ public class URIUtils {
}
/**
- * A convenience method that optionally converts the original {@link java.net.URI} either
+ * A convenience method that optionally converts the original {@link URI} either
* to a relative or an absolute form as required by the specified route.
*
* @param uri
@@ -206,25 +291,32 @@ public class URIUtils {
* @since 4.4
*/
public static URI rewriteURIForRoute(final URI uri, final RouteInfo route) throws URISyntaxException {
+ return rewriteURIForRoute(uri, route, true);
+ }
+
+ /**
+ * A convenience method that optionally converts the original {@link URI} either
+ * to a relative or an absolute form as required by the specified route.
+ *
+ * @param uri
+ * original URI.
+ * @throws URISyntaxException
+ * If the resulting URI is invalid.
+ *
+ * @since 4.5.8
+ */
+ public static URI rewriteURIForRoute(final URI uri, final RouteInfo route, final boolean normalizeUri) throws URISyntaxException {
if (uri == null) {
return null;
}
if (route.getProxyHost() != null && !route.isTunnelled()) {
// Make sure the request URI is absolute
- if (!uri.isAbsolute()) {
- final HttpHost target = route.getTargetHost();
- return rewriteURI(uri, target, true);
- } else {
- return rewriteURI(uri);
- }
- } else {
- // Make sure the request URI is relative
- if (uri.isAbsolute()) {
- return rewriteURI(uri, null, true);
- } else {
- return rewriteURI(uri);
- }
+ return uri.isAbsolute()
+ ? rewriteURI(uri)
+ : rewriteURI(uri, route.getTargetHost(), normalizeUri ? DROP_FRAGMENT_AND_NORMALIZE : DROP_FRAGMENT);
}
+ // Make sure the request URI is relative
+ return uri.isAbsolute() ? rewriteURI(uri, null, normalizeUri ? DROP_FRAGMENT_AND_NORMALIZE : DROP_FRAGMENT) : rewriteURI(uri);
}
/**
@@ -279,39 +371,32 @@ public class URIUtils {
*
* @param uri the original URI
* @return the URI without dot segments
+ *
+ * @since 4.5
*/
- static URI normalizeSyntax(final URI uri) throws URISyntaxException {
+ public static URI normalizeSyntax(final URI uri) throws URISyntaxException {
if (uri.isOpaque() || uri.getAuthority() == null) {
// opaque and file: URIs
return uri;
}
- Args.check(uri.isAbsolute(), "Base URI must be absolute");
final URIBuilder builder = new URIBuilder(uri);
- final String path = builder.getPath();
- if (path != null && !path.equals("/")) {
- final String[] inputSegments = path.split("/");
- final Stack outputSegments = new Stack();
- for (final String inputSegment : inputSegments) {
- if ((inputSegment.isEmpty()) || (".".equals(inputSegment))) {
- // Do nothing
- } else if ("..".equals(inputSegment)) {
- if (!outputSegments.isEmpty()) {
- outputSegments.pop();
- }
- } else {
- outputSegments.push(inputSegment);
+ final List inputSegments = builder.getPathSegments();
+ final Stack outputSegments = new Stack();
+ for (final String inputSegment : inputSegments) {
+ if (".".equals(inputSegment)) {
+ // Do nothing
+ } else if ("..".equals(inputSegment)) {
+ if (!outputSegments.isEmpty()) {
+ outputSegments.pop();
}
+ } else {
+ outputSegments.push(inputSegment);
}
- final StringBuilder outputBuffer = new StringBuilder();
- for (final String outputSegment : outputSegments) {
- outputBuffer.append('/').append(outputSegment);
- }
- if (path.lastIndexOf('/') == path.length() - 1) {
- // path.endsWith("/") || path.equals("")
- outputBuffer.append('/');
- }
- builder.setPath(outputBuffer.toString());
}
+ if (outputSegments.size() == 0) {
+ outputSegments.add("");
+ }
+ builder.setPathSegments(outputSegments);
if (builder.getScheme() != null) {
builder.setScheme(builder.getScheme().toLowerCase(Locale.ROOT));
}
@@ -334,56 +419,43 @@ public class URIUtils {
if (uri == null) {
return null;
}
- HttpHost target = null;
if (uri.isAbsolute()) {
- int port = uri.getPort(); // may be overridden later
- String host = uri.getHost();
- if (host == null) { // normal parse failed; let's do it ourselves
+ if (uri.getHost() == null) { // normal parse failed; let's do it ourselves
// authority does not seem to care about the valid character-set for host names
- host = uri.getAuthority();
- if (host != null) {
+ if (uri.getAuthority() != null) {
+ String content = uri.getAuthority();
// Strip off any leading user credentials
- final int at = host.indexOf('@');
- if (at >= 0) {
- if (host.length() > at+1 ) {
- host = host.substring(at+1);
- } else {
- host = null; // @ on its own
- }
+ int at = content.indexOf('@');
+ if (at != -1) {
+ content = content.substring(at + 1);
}
- // Extract the port suffix, if present
- if (host != null) {
- final int colon = host.indexOf(':');
- if (colon >= 0) {
- final int pos = colon + 1;
- int len = 0;
- for (int i = pos; i < host.length(); i++) {
- if (Character.isDigit(host.charAt(i))) {
- len++;
- } else {
- break;
- }
- }
- if (len > 0) {
- try {
- port = Integer.parseInt(host.substring(pos, pos + len));
- } catch (final NumberFormatException ex) {
- }
- }
- host = host.substring(0, colon);
+ final String scheme = uri.getScheme();
+ final String hostname;
+ final int port;
+ at = content.indexOf(":");
+ if (at != -1) {
+ hostname = content.substring(0, at);
+ try {
+ final String portText = content.substring(at + 1);
+ port = !TextUtils.isEmpty(portText) ? Integer.parseInt(portText) : -1;
+ } catch (final NumberFormatException ex) {
+ return null;
}
+ } else {
+ hostname = content;
+ port = -1;
+ }
+ try {
+ return new HttpHost(hostname, port, scheme);
+ } catch (final IllegalArgumentException ex) {
+ return null;
}
}
- }
- final String scheme = uri.getScheme();
- if (!TextUtils.isBlank(host)) {
- try {
- target = new HttpHost(host, port, scheme);
- } catch (final IllegalArgumentException ignore) {
- }
+ } else {
+ return new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme());
}
}
- return target;
+ return null;
}
/**
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/URLEncodedUtils.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/URLEncodedUtils.java
index 9b514bee0..dedef29e2 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/URLEncodedUtils.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/client/utils/URLEncodedUtils.java
@@ -36,6 +36,7 @@ import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.List;
@@ -69,28 +70,28 @@ public class URLEncodedUtils {
private static final char QP_SEP_A = '&';
private static final char QP_SEP_S = ';';
private static final String NAME_VALUE_SEPARATOR = "=";
+ private static final char PATH_SEPARATOR = '/';
+
+ private static final BitSet PATH_SEPARATORS = new BitSet(256);
+ static {
+ PATH_SEPARATORS.set(PATH_SEPARATOR);
+ }
/**
* @deprecated 4.5 Use {@link #parse(URI, Charset)}
*/
+ @Deprecated
public static List parse(final URI uri, final String charsetName) {
return parse(uri, charsetName != null ? Charset.forName(charsetName) : null);
}
/**
- * Returns a list of {@link NameValuePair NameValuePairs} as built from the URI's query portion. For example, a URI
- * of {@code http://example.org/path/to/file?a=1&b=2&c=3} would return a list of three NameValuePairs, one for a=1,
- * one for b=2, and one for c=3. By convention, {@code '&'} and {@code ';'} are accepted as parameter separators.
- *
- * This is typically useful while parsing an HTTP PUT.
+ * Returns a list of {@link NameValuePair}s URI query parameters.
+ * By convention, {@code '&'} and {@code ';'} are accepted as parameter separators.
*
- * This API is currently only used for testing.
- *
- * @param uri
- * URI to parse
- * @param charset
- * Charset to use while parsing the query
- * @return a list of {@link NameValuePair} as built from the URI's query portion.
+ * @param uri input URI.
+ * @param charset parameter charset.
+ * @return list of query parameters.
*
* @since 4.5
*/
@@ -100,7 +101,7 @@ public class URLEncodedUtils {
if (query != null && !query.isEmpty()) {
return parse(query, charset);
}
- return Collections.emptyList();
+ return createEmptyList();
}
/**
@@ -120,19 +121,19 @@ public class URLEncodedUtils {
Args.notNull(entity, "HTTP entity");
final ContentType contentType = ContentType.get(entity);
if (contentType == null || !contentType.getMimeType().equalsIgnoreCase(CONTENT_TYPE)) {
- return Collections.emptyList();
+ return createEmptyList();
}
final long len = entity.getContentLength();
Args.check(len <= Integer.MAX_VALUE, "HTTP entity is too large");
final Charset charset = contentType.getCharset() != null ? contentType.getCharset() : HTTP.DEF_CONTENT_CHARSET;
- final InputStream instream = entity.getContent();
- if (instream == null) {
- return Collections.emptyList();
+ final InputStream inStream = entity.getContent();
+ if (inStream == null) {
+ return createEmptyList();
}
final CharArrayBuffer buf;
try {
buf = new CharArrayBuffer(len > 0 ? (int) len : 1024);
- final Reader reader = new InputStreamReader(instream, charset);
+ final Reader reader = new InputStreamReader(inStream, charset);
final char[] tmp = new char[1024];
int l;
while((l = reader.read(tmp)) != -1) {
@@ -140,10 +141,10 @@ public class URLEncodedUtils {
}
} finally {
- instream.close();
+ inStream.close();
}
- if (buf.length() == 0) {
- return Collections.emptyList();
+ if (buf.isEmpty()) {
+ return createEmptyList();
}
return parse(buf, charset, QP_SEP_A);
}
@@ -178,7 +179,7 @@ public class URLEncodedUtils {
* @param charset
* Encoding to use when decoding the parameters.
*
- * @deprecated (4.4) use {@link #parse(String, java.nio.charset.Charset)}
+ * @deprecated (4.4) use {@link #parse(String, Charset)}
*/
@Deprecated
public static void parse(
@@ -204,7 +205,7 @@ public class URLEncodedUtils {
* @param charset
* Encoding to use when decoding the parameters.
*
- * @deprecated (4.4) use {@link #parse(CharArrayBuffer, java.nio.charset.Charset, char...)}
+ * @deprecated (4.4) use {@link #parse(org.apache.http.util.CharArrayBuffer, Charset, char...)}
*/
@Deprecated
public static void parse(
@@ -230,20 +231,18 @@ public class URLEncodedUtils {
}
/**
- * Returns a list of {@link NameValuePair NameValuePairs} as parsed from the given string using the given character
- * encoding. By convention, {@code '&'} and {@code ';'} are accepted as parameter separators.
+ * Returns a list of {@link NameValuePair}s URI query parameters.
+ * By convention, {@code '&'} and {@code ';'} are accepted as parameter separators.
*
- * @param s
- * text to parse.
- * @param charset
- * Encoding to use when decoding the parameters.
- * @return a list of {@link NameValuePair} as built from the URI's query portion.
+ * @param s URI query component.
+ * @param charset charset to use when decoding the parameters.
+ * @return list of query parameters.
*
* @since 4.2
*/
public static List parse(final String s, final Charset charset) {
if (s == null) {
- return Collections.emptyList();
+ return createEmptyList();
}
final CharArrayBuffer buffer = new CharArrayBuffer(s.length());
buffer.append(s);
@@ -254,19 +253,16 @@ public class URLEncodedUtils {
* Returns a list of {@link NameValuePair NameValuePairs} as parsed from the given string using the given character
* encoding.
*
- * @param s
- * text to parse.
- * @param charset
- * Encoding to use when decoding the parameters.
- * @param separators
- * element separators.
- * @return a list of {@link NameValuePair} as built from the URI's query portion.
+ * @param s input text.
+ * @param charset parameter charset.
+ * @param separators parameter separators.
+ * @return list of query parameters.
*
* @since 4.3
*/
public static List parse(final String s, final Charset charset, final char... separators) {
if (s == null) {
- return Collections.emptyList();
+ return createEmptyList();
}
final CharArrayBuffer buffer = new CharArrayBuffer(s.length());
buffer.append(s);
@@ -274,8 +270,7 @@ public class URLEncodedUtils {
}
/**
- * Returns a list of {@link NameValuePair NameValuePairs} as parsed from the given string using
- * the given character encoding.
+ * Returns a list of {@link NameValuePair}s parameters.
*
* @param buf
* text to parse.
@@ -306,7 +301,7 @@ public class URLEncodedUtils {
cursor.updatePos(cursor.getPos() + 1);
if (delim == '=') {
delimSet.clear('=');
- value = tokenParser.parseValue(buf, cursor, delimSet);
+ value = tokenParser.parseToken(buf, cursor, delimSet);
if (!cursor.atEnd()) {
cursor.updatePos(cursor.getPos() + 1);
}
@@ -321,6 +316,98 @@ public class URLEncodedUtils {
return list;
}
+ static List splitSegments(final CharSequence s, final BitSet separators) {
+ final ParserCursor cursor = new ParserCursor(0, s.length());
+ // Skip leading separator
+ if (cursor.atEnd()) {
+ return Collections.emptyList();
+ }
+ if (separators.get(s.charAt(cursor.getPos()))) {
+ cursor.updatePos(cursor.getPos() + 1);
+ }
+ final List list = new ArrayList();
+ final StringBuilder buf = new StringBuilder();
+ for (;;) {
+ if (cursor.atEnd()) {
+ list.add(buf.toString());
+ break;
+ }
+ final char current = s.charAt(cursor.getPos());
+ if (separators.get(current)) {
+ list.add(buf.toString());
+ buf.setLength(0);
+ } else {
+ buf.append(current);
+ }
+ cursor.updatePos(cursor.getPos() + 1);
+ }
+ return list;
+ }
+
+ static List splitPathSegments(final CharSequence s) {
+ return splitSegments(s, PATH_SEPARATORS);
+ }
+
+ /**
+ * Returns a list of URI path segments.
+ *
+ * @param s URI path component.
+ * @param charset parameter charset.
+ * @return list of segments.
+ *
+ * @since 4.5
+ */
+ public static List parsePathSegments(final CharSequence s, final Charset charset) {
+ Args.notNull(s, "Char sequence");
+ final List list = splitPathSegments(s);
+ for (int i = 0; i < list.size(); i++) {
+ list.set(i, urlDecode(list.get(i), charset != null ? charset : Consts.UTF_8, false));
+ }
+ return list;
+ }
+
+ /**
+ * Returns a list of URI path segments.
+ *
+ * @param s URI path component.
+ * @return list of segments.
+ *
+ * @since 4.5
+ */
+ public static List parsePathSegments(final CharSequence s) {
+ return parsePathSegments(s, Consts.UTF_8);
+ }
+
+ /**
+ * Returns a string consisting of joint encoded path segments.
+ *
+ * @param segments the segments.
+ * @param charset parameter charset.
+ * @return URI path component
+ *
+ * @since 4.5
+ */
+ public static String formatSegments(final Iterable segments, final Charset charset) {
+ Args.notNull(segments, "Segments");
+ final StringBuilder result = new StringBuilder();
+ for (final String segment : segments) {
+ result.append(PATH_SEPARATOR).append(urlEncode(segment, charset, PATHSAFE, false));
+ }
+ return result.toString();
+ }
+
+ /**
+ * Returns a string consisting of joint encoded path segments.
+ *
+ * @param segments the segments.
+ * @return URI path component
+ *
+ * @since 4.5
+ */
+ public static String formatSegments(final String... segments) {
+ return formatSegments(Arrays.asList(segments), Consts.UTF_8);
+ }
+
/**
* Returns a String that is suitable for use as an {@code application/x-www-form-urlencoded}
* list of parameters in an HTTP PUT or HTTP POST.
@@ -454,6 +541,8 @@ public class URLEncodedUtils {
*/
private static final BitSet URLENCODER = new BitSet(256);
+ private static final BitSet PATH_SPECIAL = new BitSet(256);
+
static {
// unreserved chars
// alpha characters
@@ -491,9 +580,8 @@ public class URLEncodedUtils {
// URL path safe
PATHSAFE.or(UNRESERVED);
- PATHSAFE.set('/'); // segment separator
PATHSAFE.set(';'); // param separator
- PATHSAFE.set(':'); // rest as per list in 2396, i.e. : @ & = + $ ,
+ PATHSAFE.set(':'); // RFC 2396
PATHSAFE.set('@');
PATHSAFE.set('&');
PATHSAFE.set('=');
@@ -501,6 +589,9 @@ public class URLEncodedUtils {
PATHSAFE.set('$');
PATHSAFE.set(',');
+ PATH_SPECIAL.or(PATHSAFE);
+ PATH_SPECIAL.set('/');
+
RESERVED.set(';');
RESERVED.set('/');
RESERVED.set('?');
@@ -520,6 +611,10 @@ public class URLEncodedUtils {
private static final int RADIX = 16;
+ private static List createEmptyList() {
+ return new ArrayList(0);
+ }
+
private static String urlEncode(
final String content,
final Charset charset,
@@ -679,7 +774,7 @@ public class URLEncodedUtils {
}
/**
- * Encode a String using the {@link #PATHSAFE} set of characters.
+ * Encode a String using the {@link #PATH_SPECIAL} set of characters.
*
* Used by URIBuilder to encode path segments.
*
@@ -688,7 +783,7 @@ public class URLEncodedUtils {
* @return the encoded string
*/
static String encPath(final String content, final Charset charset) {
- return urlEncode(content, charset, PATHSAFE, false);
+ return urlEncode(content, charset, PATH_SPECIAL, false);
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ClientConnectionManager.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ClientConnectionManager.java
index bbac27681..f9290d2e0 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ClientConnectionManager.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ClientConnectionManager.java
@@ -92,11 +92,11 @@ public interface ClientConnectionManager {
* All expired connections will also be closed.
*
* @param idletime the idle time of connections to be closed
- * @param tunit the unit for the {@code idletime}
+ * @param timeUnit the unit for the {@code idletime}
*
* @see #closeExpiredConnections()
*/
- void closeIdleConnections(long idletime, TimeUnit tunit);
+ void closeIdleConnections(long idletime, TimeUnit timeUnit);
/**
* Closes all expired connections in the pool.
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ClientConnectionRequest.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ClientConnectionRequest.java
index 1c8dd480b..03c6032ef 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ClientConnectionRequest.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ClientConnectionRequest.java
@@ -51,7 +51,7 @@ public interface ClientConnectionRequest {
* be thrown.
*
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
*
* @return a connection that can be used to communicate
@@ -62,7 +62,7 @@ public interface ClientConnectionRequest {
* @throws InterruptedException
* if the calling thread is interrupted while waiting
*/
- ManagedClientConnection getConnection(long timeout, TimeUnit tunit)
+ ManagedClientConnection getConnection(long timeout, TimeUnit timeUnit)
throws InterruptedException, ConnectionPoolTimeoutException;
/**
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ConnectionKeepAliveStrategy.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ConnectionKeepAliveStrategy.java
index eda834635..75536ad5b 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ConnectionKeepAliveStrategy.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ConnectionKeepAliveStrategy.java
@@ -26,7 +26,6 @@
*/
package com.fr.third.org.apache.http.conn;
-import com.fr.third.org.apache.http.ConnectionReuseStrategy;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.protocol.HttpContext;
@@ -48,8 +47,8 @@ public interface ConnectionKeepAliveStrategy {
* it MUST not reused. A value of 0 or less may be returned to indicate that
* there is no suitable suggestion.
*
- * When coupled with a {@link ConnectionReuseStrategy}, if
- * {@link ConnectionReuseStrategy#keepAlive(
+ * When coupled with a {@link com.fr.third.org.apache.http.ConnectionReuseStrategy}, if
+ * {@link com.fr.third.org.apache.http.ConnectionReuseStrategy#keepAlive(
* HttpResponse, HttpContext)} returns true, this allows you to control
* how long the reuse will last. If keepAlive returns false, this should
* have no meaningful impact
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ConnectionRequest.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ConnectionRequest.java
index c1f323bca..9ed5ae937 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ConnectionRequest.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ConnectionRequest.java
@@ -52,7 +52,7 @@ public interface ConnectionRequest extends Cancellable {
* be thrown.
*
* @param timeout the timeout, 0 or negative for no timeout
- * @param tunit the unit for the {@code timeout},
+ * @param timeUnit the unit for the {@code timeout},
* may be {@code null} only if there is no timeout
*
* @return a connection that can be used to communicate
@@ -63,7 +63,7 @@ public interface ConnectionRequest extends Cancellable {
* @throws InterruptedException
* if the calling thread is interrupted while waiting
*/
- HttpClientConnection get(long timeout, TimeUnit tunit)
+ HttpClientConnection get(long timeout, TimeUnit timeUnit)
throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException;
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/EofSensorInputStream.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/EofSensorInputStream.java
index 59707824b..465334bc2 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/EofSensorInputStream.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/EofSensorInputStream.java
@@ -111,36 +111,36 @@ public class EofSensorInputStream extends InputStream implements ConnectionRelea
@Override
public int read() throws IOException {
- int l = -1;
+ int readLen = -1;
if (isReadAllowed()) {
try {
- l = wrappedStream.read();
- checkEOF(l);
+ readLen = wrappedStream.read();
+ checkEOF(readLen);
} catch (final IOException ex) {
checkAbort();
throw ex;
}
}
- return l;
+ return readLen;
}
@Override
public int read(final byte[] b, final int off, final int len) throws IOException {
- int l = -1;
+ int readLen = -1;
if (isReadAllowed()) {
try {
- l = wrappedStream.read(b, off, len);
- checkEOF(l);
+ readLen = wrappedStream.read(b, off, len);
+ checkEOF(readLen);
} catch (final IOException ex) {
checkAbort();
throw ex;
}
}
- return l;
+ return readLen;
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/HttpClientConnectionManager.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/HttpClientConnectionManager.java
index ae7cde640..4d41f3859 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/HttpClientConnectionManager.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/HttpClientConnectionManager.java
@@ -59,18 +59,18 @@ public interface HttpClientConnectionManager {
* Please note that newly allocated connections can be returned
* in the closed state. The consumer of that connection is responsible
* for fully establishing the route the to the connection target
- * by calling {@link #connect(HttpClientConnection,
- * HttpRoute, int,
- * HttpContext) connect} in order to connect
+ * by calling {@link #connect(org.apache.http.HttpClientConnection,
+ * com.fr.third.org.apache.http.conn.routing.HttpRoute, int,
+ * com.fr.third.org.apache.http.protocol.HttpContext) connect} in order to connect
* directly to the target or to the first proxy hop, optionally calling
- * {@link #upgrade(HttpClientConnection,
- * HttpRoute,
- * HttpContext) upgrade} method to upgrade
+ * {@link #upgrade(org.apache.http.HttpClientConnection,
+ * com.fr.third.org.apache.http.conn.routing.HttpRoute,
+ * com.fr.third.org.apache.http.protocol.HttpContext) upgrade} method to upgrade
* the connection after having executed {@code CONNECT} method to
* all intermediate proxy hops and and finally calling {@link #routeComplete(
- * HttpClientConnection,
- * HttpRoute,
- * HttpContext) routeComplete} to mark the route
+ * com.fr.third.org.apache.http.HttpClientConnection,
+ * com.fr.third.org.apache.http.conn.routing.HttpRoute,
+ * com.fr.third.org.apache.http.protocol.HttpContext) routeComplete} to mark the route
* as fully completed.
*
*
@@ -155,11 +155,11 @@ public interface HttpClientConnectionManager {
*
*
* @param idletime the idle time of connections to be closed
- * @param tunit the unit for the {@code idletime}
+ * @param timeUnit the unit for the {@code idletime}
*
* @see #closeExpiredConnections()
*/
- void closeIdleConnections(long idletime, TimeUnit tunit);
+ void closeIdleConnections(long idletime, TimeUnit timeUnit);
/**
* Closes all expired connections in the pool.
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/HttpClientConnectionOperator.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/HttpClientConnectionOperator.java
index 06b285062..aceb10da3 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/HttpClientConnectionOperator.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/HttpClientConnectionOperator.java
@@ -32,12 +32,11 @@ import java.net.InetSocketAddress;
import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.config.SocketConfig;
-import com.fr.third.org.apache.http.conn.socket.ConnectionSocketFactory;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
* Connection operator that performs connection connect and upgrade operations. Usually, components
- * participating in these operations are registry of {@link ConnectionSocketFactory},
+ * participating in these operations are registry of {@link com.fr.third.org.apache.http.conn.socket.ConnectionSocketFactory},
* {@link SchemePortResolver} and {@link DnsResolver}. In general, HTTP client user should not
* provide implementations of this interface, as HttpClient will use the default one that covers
* most of the cases needed for majority of users.
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/HttpHostConnectException.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/HttpHostConnectException.java
index 717a0a65d..4501bc856 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/HttpHostConnectException.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/HttpHostConnectException.java
@@ -46,8 +46,8 @@ public class HttpHostConnectException extends ConnectException {
private final HttpHost host;
/**
- * @deprecated (4.3) use {@link #HttpHostConnectException(java.io.IOException, HttpHost,
- * java.net.InetAddress...)}
+ * @deprecated (4.3) use {@link #HttpHostConnectException(IOException, com.fr.third.org.apache.http.HttpHost,
+ * InetAddress...)}
*/
@Deprecated
public HttpHostConnectException(final HttpHost host, final ConnectException cause) {
@@ -55,7 +55,7 @@ public class HttpHostConnectException extends ConnectException {
}
/**
- * Creates a HttpHostConnectException based on original {@link java.io.IOException}.
+ * Creates a HttpHostConnectException based on original {@link IOException}.
*
* @since 4.3
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ManagedClientConnection.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ManagedClientConnection.java
index f6d5cb1ec..d911c95ab 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ManagedClientConnection.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ManagedClientConnection.java
@@ -32,8 +32,6 @@ import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLSession;
-import com.fr.third.org.apache.http.ConnectionReuseStrategy;
-import com.fr.third.org.apache.http.HttpClientConnection;
import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.conn.routing.HttpRoute;
import com.fr.third.org.apache.http.params.HttpParams;
@@ -49,7 +47,7 @@ import com.fr.third.org.apache.http.protocol.HttpContext;
*/
@Deprecated
public interface ManagedClientConnection extends
- HttpClientConnection, HttpRoutedConnection, ManagedHttpClientConnection, ConnectionReleaseTrigger {
+ HttpRoutedConnection, ManagedHttpClientConnection, ConnectionReleaseTrigger {
/**
* Indicates whether this connection is secure.
@@ -186,7 +184,7 @@ public interface ManagedClientConnection extends
* This can be used immediately before releasing this connection
* to prevent its reuse. Reasons for preventing reuse include
* error conditions and the evaluation of a
- * {@link ConnectionReuseStrategy reuse strategy}.
+ * {@link com.fr.third.org.apache.http.ConnectionReuseStrategy reuse strategy}.
*
* Note:
* It is not necessary to call here before writing to
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/params/ConnConnectionPNames.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/params/ConnConnectionPNames.java
index 7c2664300..2554a010f 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/params/ConnConnectionPNames.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/params/ConnConnectionPNames.java
@@ -26,15 +26,13 @@
*/
package com.fr.third.org.apache.http.conn.params;
-import com.fr.third.org.apache.http.impl.conn.DefaultHttpResponseParser;
-
/**
* Parameter names for HTTP client connections.
*
* @since 4.0
*
* @deprecated (4.1) use custom {@link
- * DefaultHttpResponseParser} implementation.
+ * com.fr.third.org.apache.http.impl.conn.DefaultHttpResponseParser} implementation.
*/
@Deprecated
public interface ConnConnectionPNames {
@@ -53,11 +51,11 @@ public interface ConnConnectionPNames {
*
* This parameter expects a value of type {@link Integer}.
* 0 disallows all garbage/empty lines before the status line.
- * Use {@link java.lang.Integer#MAX_VALUE} for unlimited number.
+ * Use {@link Integer#MAX_VALUE} for unlimited number.
*
*
* @deprecated (4.1) Use custom {@link
- * DefaultHttpResponseParser} implementation
+ * com.fr.third.org.apache.http.impl.conn.DefaultHttpResponseParser} implementation
*/
@Deprecated
public static final String MAX_STATUS_LINE_GARBAGE = "http.connection.max-status-line-garbage";
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/params/ConnManagerPNames.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/params/ConnManagerPNames.java
index d4a7faea4..0ff3b7fc1 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/params/ConnManagerPNames.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/params/ConnManagerPNames.java
@@ -26,9 +26,6 @@
*/
package com.fr.third.org.apache.http.conn.params;
-import com.fr.third.org.apache.http.conn.ClientConnectionManager;
-import com.fr.third.org.apache.http.conn.ManagedClientConnection;
-
/**
* Parameter names for connection managers in HttpConn.
*
@@ -41,8 +38,8 @@ public interface ConnManagerPNames {
/**
* Defines the timeout in milliseconds used when retrieving an instance of
- * {@link ManagedClientConnection} from the
- * {@link ClientConnectionManager}.
+ * {@link com.fr.third.org.apache.http.conn.ManagedClientConnection} from the
+ * {@link com.fr.third.org.apache.http.conn.ClientConnectionManager}.
*
* This parameter expects a value of type {@link Long}.
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/params/ConnRoutePNames.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/params/ConnRoutePNames.java
index b7d11ce5e..31f0cdce5 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/params/ConnRoutePNames.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/params/ConnRoutePNames.java
@@ -26,17 +26,12 @@
*/
package com.fr.third.org.apache.http.conn.params;
-import com.fr.third.org.apache.http.HttpHost;
-import com.fr.third.org.apache.http.client.config.RequestConfig;
-import com.fr.third.org.apache.http.conn.routing.HttpRoute;
-import com.fr.third.org.apache.http.conn.routing.HttpRoutePlanner;
-
/**
* Parameter names for connection routing.
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig}.
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.client.config.RequestConfig}.
*/
@Deprecated
public interface ConnRoutePNames {
@@ -44,10 +39,10 @@ public interface ConnRoutePNames {
/**
* Parameter for the default proxy.
* The default value will be used by some
- * {@link HttpRoutePlanner HttpRoutePlanner}
+ * {@link com.fr.third.org.apache.http.conn.routing.HttpRoutePlanner HttpRoutePlanner}
* implementations, in particular the default implementation.
*
- * This parameter expects a value of type {@link HttpHost}.
+ * This parameter expects a value of type {@link com.fr.third.org.apache.http.HttpHost}.
*
*/
public static final String DEFAULT_PROXY = "http.route.default-proxy";
@@ -58,7 +53,7 @@ public interface ConnRoutePNames {
* can be used to select the network interface from which the
* connection originates.
* It will be interpreted by the standard
- * {@link HttpRoutePlanner HttpRoutePlanner}
+ * {@link com.fr.third.org.apache.http.conn.routing.HttpRoutePlanner HttpRoutePlanner}
* implementations, in particular the default implementation.
*
* This parameter expects a value of type {@link java.net.InetAddress}.
@@ -69,13 +64,13 @@ public interface ConnRoutePNames {
/**
* Parameter for an forced route.
* The forced route will be interpreted by the standard
- * {@link HttpRoutePlanner HttpRoutePlanner}
+ * {@link com.fr.third.org.apache.http.conn.routing.HttpRoutePlanner HttpRoutePlanner}
* implementations.
* Instead of computing a route, the given forced route will be
* returned, even if it points to the wrong target host.
*
* This parameter expects a value of type
- * {@link HttpRoute HttpRoute}.
+ * {@link com.fr.third.org.apache.http.conn.routing.HttpRoute HttpRoute}.
*
*/
public static final String FORCED_ROUTE = "http.route.forced-route";
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/routing/HttpRoute.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/routing/HttpRoute.java
index 32d1d2586..e93a80847 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/routing/HttpRoute.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/routing/HttpRoute.java
@@ -103,16 +103,13 @@ public final class HttpRoute implements RouteInfo, Cloneable {
private static HttpHost normalize(final HttpHost target) {
if (target.getPort() >= 0 ) {
return target;
- } else {
- final InetAddress address = target.getAddress();
- final String schemeName = target.getSchemeName();
- if (address != null) {
- return new HttpHost(address, getDefaultPort(schemeName), schemeName);
- } else {
- final String hostName = target.getHostName();
- return new HttpHost(hostName, getDefaultPort(schemeName), schemeName);
- }
}
+ final InetAddress address = target.getAddress();
+ final String schemeName = target.getSchemeName();
+ return address != null
+ ? new HttpHost(address, getDefaultPort(schemeName), schemeName)
+ : new HttpHost(target.getHostName(), getDefaultPort(schemeName),
+ schemeName);
}
/**
@@ -238,11 +235,7 @@ public final class HttpRoute implements RouteInfo, Cloneable {
Args.notNegative(hop, "Hop index");
final int hopcount = getHopCount();
Args.check(hop < hopcount, "Hop index exceeds tracked route length");
- if (hop < hopcount - 1) {
- return this.proxyChain.get(hop);
- } else {
- return this.targetHost;
- }
+ return hop < hopcount - 1 ? this.proxyChain.get(hop) : this.targetHost;
}
@Override
@@ -298,9 +291,8 @@ public final class HttpRoute implements RouteInfo, Cloneable {
LangUtils.equals(this.targetHost, that.targetHost) &&
LangUtils.equals(this.localAddress, that.localAddress) &&
LangUtils.equals(this.proxyChain, that.proxyChain);
- } else {
- return false;
}
+ return false;
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/Scheme.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/Scheme.java
index f4dd2e483..b37f9b20c 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/Scheme.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/Scheme.java
@@ -30,8 +30,6 @@ import java.util.Locale;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.config.Registry;
-import com.fr.third.org.apache.http.conn.SchemePortResolver;
import com.fr.third.org.apache.http.util.Args;
import com.fr.third.org.apache.http.util.LangUtils;
@@ -50,8 +48,8 @@ import com.fr.third.org.apache.http.util.LangUtils;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link SchemePortResolver} for default port
- * resolution and {@link Registry} for socket factory lookups.
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.conn.SchemePortResolver} for default port
+ * resolution and {@link com.fr.third.org.apache.http.config.Registry} for socket factory lookups.
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE)
@Deprecated
@@ -165,14 +163,11 @@ public final class Scheme {
public final SocketFactory getSocketFactory() {
if (this.socketFactory instanceof SchemeSocketFactoryAdaptor) {
return ((SchemeSocketFactoryAdaptor) this.socketFactory).getFactory();
- } else {
- if (this.layered) {
- return new LayeredSocketFactoryAdaptor(
- (LayeredSchemeSocketFactory) this.socketFactory);
- } else {
- return new SocketFactoryAdaptor(this.socketFactory);
- }
}
+ return this.layered
+ ? new LayeredSocketFactoryAdaptor(
+ (LayeredSchemeSocketFactory) this.socketFactory)
+ : new SocketFactoryAdaptor(this.socketFactory);
}
/**
@@ -247,9 +242,8 @@ public final class Scheme {
return this.name.equals(that.name)
&& this.defaultPort == that.defaultPort
&& this.layered == that.layered;
- } else {
- return false;
}
+ return false;
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeLayeredSocketFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeLayeredSocketFactory.java
index 89d282784..26e1bf427 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeLayeredSocketFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeLayeredSocketFactory.java
@@ -31,7 +31,6 @@ import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
-import com.fr.third.org.apache.http.conn.socket.LayeredConnectionSocketFactory;
import com.fr.third.org.apache.http.params.HttpParams;
/**
@@ -40,7 +39,7 @@ import com.fr.third.org.apache.http.params.HttpParams;
* @since 4.2
*
* @deprecated (4.3) use {@link
- * LayeredConnectionSocketFactory}
+ * com.fr.third.org.apache.http.conn.socket.LayeredConnectionSocketFactory}
*/
@Deprecated
public interface SchemeLayeredSocketFactory extends SchemeSocketFactory {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeRegistry.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeRegistry.java
index 12f9b2ff3..15e872188 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeRegistry.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeRegistry.java
@@ -31,7 +31,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import com.fr.third.org.apache.http.config.Registry;
import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
@@ -43,7 +42,7 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link Registry}
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.config.Registry}
*/
@Contract(threading = ThreadingBehavior.SAFE)
@Deprecated
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeSocketFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeSocketFactory.java
index 4da5c2497..22ff83875 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeSocketFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeSocketFactory.java
@@ -32,9 +32,6 @@ import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
-import com.fr.third.org.apache.http.HttpHost;
-import com.fr.third.org.apache.http.conn.HttpInetSocketAddress;
-import com.fr.third.org.apache.http.conn.socket.ConnectionSocketFactory;
import com.fr.third.org.apache.http.conn.ConnectTimeoutException;
import com.fr.third.org.apache.http.params.HttpParams;
@@ -44,7 +41,7 @@ import com.fr.third.org.apache.http.params.HttpParams;
*
* @since 4.1
*
- * @deprecated (4.3) use {@link ConnectionSocketFactory}
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.conn.socket.ConnectionSocketFactory}
*/
@Deprecated
public interface SchemeSocketFactory {
@@ -70,10 +67,10 @@ public interface SchemeSocketFactory {
/**
* Connects a socket to the target host with the given remote address.
*
- * Please note that {@link HttpInetSocketAddress} class should
+ * Please note that {@link com.fr.third.org.apache.http.conn.HttpInetSocketAddress} class should
* be used in order to pass the target remote address along with the original
- * {@link HttpHost} value used to resolve the address. The use of
- * {@link HttpInetSocketAddress} can also ensure that no reverse
+ * {@link com.fr.third.org.apache.http.HttpHost} value used to resolve the address. The use of
+ * {@link com.fr.third.org.apache.http.conn.HttpInetSocketAddress} can also ensure that no reverse
* DNS lookup will be performed if the target remote address was specified
* as an IP address.
*
@@ -97,7 +94,7 @@ public interface SchemeSocketFactory {
* @throws ConnectTimeoutException if the socket cannot be connected
* within the time limit defined in the {@code params}
*
- * @see HttpInetSocketAddress
+ * @see com.fr.third.org.apache.http.conn.HttpInetSocketAddress
*/
Socket connectSocket(
Socket sock,
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java
index 0282f29c7..bc3e21a84 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java
@@ -88,11 +88,9 @@ class SchemeSocketFactoryAdaptor implements SchemeSocketFactory {
if (this == obj) {
return true;
}
- if (obj instanceof SchemeSocketFactoryAdaptor) {
- return this.factory.equals(((SchemeSocketFactoryAdaptor)obj).factory);
- } else {
- return this.factory.equals(obj);
- }
+ return obj instanceof SchemeSocketFactoryAdaptor
+ ? this.factory.equals(((SchemeSocketFactoryAdaptor) obj).factory)
+ : this.factory.equals(obj);
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SocketFactoryAdaptor.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SocketFactoryAdaptor.java
index 86b89e12a..0058c729a 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SocketFactoryAdaptor.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/scheme/SocketFactoryAdaptor.java
@@ -37,6 +37,9 @@ import com.fr.third.org.apache.http.conn.ConnectTimeoutException;
import com.fr.third.org.apache.http.params.BasicHttpParams;
import com.fr.third.org.apache.http.params.HttpParams;
+/**
+ * @deprecated Do not use.
+ */
@Deprecated
class SocketFactoryAdaptor implements SocketFactory {
@@ -85,11 +88,9 @@ class SocketFactoryAdaptor implements SocketFactory {
if (this == obj) {
return true;
}
- if (obj instanceof SocketFactoryAdaptor) {
- return this.factory.equals(((SocketFactoryAdaptor)obj).factory);
- } else {
- return this.factory.equals(obj);
- }
+ return obj instanceof SocketFactoryAdaptor
+ ? this.factory.equals(((SocketFactoryAdaptor) obj).factory)
+ : this.factory.equals(obj);
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/AbstractVerifier.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/AbstractVerifier.java
index a477f3aa0..ae49725d9 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/AbstractVerifier.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/AbstractVerifier.java
@@ -136,13 +136,13 @@ public abstract class AbstractVerifier implements X509HostnameVerifier {
final List allSubjectAltNames = DefaultHostnameVerifier.getSubjectAltNames(cert);
final List subjectAlts = new ArrayList();
if (InetAddressUtils.isIPv4Address(host) || InetAddressUtils.isIPv6Address(host)) {
- for (SubjectName subjectName: allSubjectAltNames) {
+ for (final SubjectName subjectName: allSubjectAltNames) {
if (subjectName.getType() == SubjectName.IP) {
subjectAlts.add(subjectName.getValue());
}
}
} else {
- for (SubjectName subjectName: allSubjectAltNames) {
+ for (final SubjectName subjectName: allSubjectAltNames) {
if (subjectName.getType() == SubjectName.DNS) {
subjectAlts.add(subjectName.getValue());
}
@@ -203,7 +203,7 @@ public abstract class AbstractVerifier implements X509HostnameVerifier {
final boolean doWildcard = parts.length >= 3 && parts[0].endsWith("*") &&
(!strict || validCountryWildcard(parts));
if (doWildcard) {
- boolean match;
+ final boolean match;
final String firstpart = parts[0];
if (firstpart.length() > 1) { // e.g. server*
final String prefix = firstpart.substring(0, firstpart.length() - 1); // e.g. server
@@ -214,9 +214,8 @@ public abstract class AbstractVerifier implements X509HostnameVerifier {
match = normalizedHost.endsWith(normalizedIdentity.substring(1));
}
return match && (!strict || countDots(normalizedHost) == countDots(normalizedIdentity));
- } else {
- return normalizedHost.equals(normalizedIdentity);
}
+ return normalizedHost.equals(normalizedIdentity);
}
private static boolean validCountryWildcard(final String parts[]) {
@@ -262,7 +261,7 @@ public abstract class AbstractVerifier implements X509HostnameVerifier {
return null;
}
final List dnsAlts = new ArrayList();
- for (SubjectName subjectName: subjectAltNames) {
+ for (final SubjectName subjectName: subjectAltNames) {
if (subjectName.getType() == SubjectName.DNS) {
dnsAlts.add(subjectName.getValue());
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java
index d8c999245..e2e641626 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java
@@ -37,7 +37,7 @@ import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
*
* @since 4.0
*
- * @deprecated (4.4) Use {@link NoopHostnameVerifier}
+ * @deprecated (4.4) Use {@link com.fr.third.org.apache.http.conn.ssl.NoopHostnameVerifier}
*/
@Deprecated
@Contract(threading = ThreadingBehavior.IMMUTABLE)
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier.java
index 4f35b6191..4b9fef4ae 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/BrowserCompatHostnameVerifier.java
@@ -46,7 +46,7 @@ import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
*
* @since 4.0
*
- * @deprecated (4.4) Use {@link DefaultHostnameVerifier}
+ * @deprecated (4.4) Use {@link com.fr.third.org.apache.http.conn.ssl.DefaultHostnameVerifier}
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE)
@Deprecated
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/DefaultHostnameVerifier.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/DefaultHostnameVerifier.java
index bc7792425..875caad12 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/DefaultHostnameVerifier.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/DefaultHostnameVerifier.java
@@ -36,7 +36,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import java.util.Locale;
import java.util.NoSuchElementException;
import javax.naming.InvalidNameException;
@@ -55,12 +54,13 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
+import com.fr.third.org.apache.http.conn.util.DnsUtils;
import com.fr.third.org.apache.http.conn.util.DomainType;
import com.fr.third.org.apache.http.conn.util.InetAddressUtils;
import com.fr.third.org.apache.http.conn.util.PublicSuffixMatcher;
/**
- * Default {@link javax.net.ssl.HostnameVerifier} implementation.
+ * Default {@link HostnameVerifier} implementation.
*
* @since 4.4
*/
@@ -164,11 +164,11 @@ public final class DefaultHostnameVerifier implements HostnameVerifier {
static void matchDNSName(final String host, final List subjectAlts,
final PublicSuffixMatcher publicSuffixMatcher) throws SSLException {
- final String normalizedHost = host.toLowerCase(Locale.ROOT);
+ final String normalizedHost = DnsUtils.normalize(host);
for (int i = 0; i < subjectAlts.size(); i++) {
final SubjectName subjectAlt = subjectAlts.get(i);
if (subjectAlt.getType() == SubjectName.DNS) {
- final String normalizedSubjectAlt = subjectAlt.getValue().toLowerCase(Locale.ROOT);
+ final String normalizedSubjectAlt = DnsUtils.normalize(subjectAlt.getValue());
if (matchIdentityStrict(normalizedHost, normalizedSubjectAlt, publicSuffixMatcher)) {
return;
}
@@ -180,8 +180,8 @@ public final class DefaultHostnameVerifier implements HostnameVerifier {
static void matchCN(final String host, final String cn,
final PublicSuffixMatcher publicSuffixMatcher) throws SSLException {
- final String normalizedHost = host.toLowerCase(Locale.ROOT);
- final String normalizedCn = cn.toLowerCase(Locale.ROOT);
+ final String normalizedHost = DnsUtils.normalize(host);
+ final String normalizedCn = DnsUtils.normalize(cn);
if (!matchIdentityStrict(normalizedHost, normalizedCn, publicSuffixMatcher)) {
throw new SSLPeerUnverifiedException("Certificate for <" + host + "> doesn't match " +
"common name of the certificate subject: " + cn);
@@ -198,9 +198,10 @@ public final class DefaultHostnameVerifier implements HostnameVerifier {
private static boolean matchIdentity(final String host, final String identity,
final PublicSuffixMatcher publicSuffixMatcher,
+ final DomainType domainType,
final boolean strict) {
if (publicSuffixMatcher != null && host.contains(".")) {
- if (!matchDomainRoot(host, publicSuffixMatcher.getDomainRoot(identity, DomainType.ICANN))) {
+ if (!matchDomainRoot(host, publicSuffixMatcher.getDomainRoot(identity, domainType))) {
return false;
}
}
@@ -235,20 +236,32 @@ public final class DefaultHostnameVerifier implements HostnameVerifier {
static boolean matchIdentity(final String host, final String identity,
final PublicSuffixMatcher publicSuffixMatcher) {
- return matchIdentity(host, identity, publicSuffixMatcher, false);
+ return matchIdentity(host, identity, publicSuffixMatcher, null, false);
}
static boolean matchIdentity(final String host, final String identity) {
- return matchIdentity(host, identity, null, false);
+ return matchIdentity(host, identity, null, null, false);
}
static boolean matchIdentityStrict(final String host, final String identity,
final PublicSuffixMatcher publicSuffixMatcher) {
- return matchIdentity(host, identity, publicSuffixMatcher, true);
+ return matchIdentity(host, identity, publicSuffixMatcher, null, true);
}
static boolean matchIdentityStrict(final String host, final String identity) {
- return matchIdentity(host, identity, null, true);
+ return matchIdentity(host, identity, null, null, true);
+ }
+
+ static boolean matchIdentity(final String host, final String identity,
+ final PublicSuffixMatcher publicSuffixMatcher,
+ final DomainType domainType) {
+ return matchIdentity(host, identity, publicSuffixMatcher, domainType, false);
+ }
+
+ static boolean matchIdentityStrict(final String host, final String identity,
+ final PublicSuffixMatcher publicSuffixMatcher,
+ final DomainType domainType) {
+ return matchIdentity(host, identity, publicSuffixMatcher, domainType, true);
}
static String extractCN(final String subjectPrincipal) throws SSLException {
@@ -284,14 +297,13 @@ public final class DefaultHostnameVerifier implements HostnameVerifier {
static HostNameType determineHostFormat(final String host) {
if (InetAddressUtils.isIPv4Address(host)) {
return HostNameType.IPv4;
- } else {
- String s = host;
- if (s.startsWith("[") && s.endsWith("]")) {
- s = host.substring(1, host.length() - 1);
- }
- if (InetAddressUtils.isIPv6Address(s)) {
- return HostNameType.IPv6;
- }
+ }
+ String s = host;
+ if (s.startsWith("[") && s.endsWith("]")) {
+ s = host.substring(1, host.length() - 1);
+ }
+ if (InetAddressUtils.isIPv6Address(s)) {
+ return HostNameType.IPv6;
}
return HostNameType.DNS;
}
@@ -303,11 +315,17 @@ public final class DefaultHostnameVerifier implements HostnameVerifier {
return Collections.emptyList();
}
final List result = new ArrayList();
- for (List> entry: entries) {
+ for (final List> entry : entries) {
final Integer type = entry.size() >= 2 ? (Integer) entry.get(0) : null;
if (type != null) {
- final String s = (String) entry.get(1);
- result.add(new SubjectName(s, type));
+ if (type == SubjectName.DNS || type == SubjectName.IP) {
+ final Object o = entry.get(1);
+ if (o instanceof String) {
+ result.add(new SubjectName((String) o, type));
+ } else if (o instanceof byte[]) {
+ // TODO ASN.1 DER encoded form
+ }
+ }
}
}
return result;
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
index 599cb5152..9060f58d3 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/SSLConnectionSocketFactory.java
@@ -36,7 +36,9 @@ import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
+import java.util.regex.Pattern;
import javax.net.SocketFactory;
import javax.net.ssl.HostnameVerifier;
@@ -76,7 +78,7 @@ import com.fr.third.org.apache.http.util.TextUtils;
*
*
* In special cases the standard trust verification process can be bypassed by using a custom
- * {@link TrustStrategy}. This interface is primarily intended for allowing self-signed
+ * {@link com.fr.third.org.apache.http.conn.ssl.TrustStrategy}. This interface is primarily intended for allowing self-signed
* certificates to be accepted as trusted without having to add them to the trust-store file.
*
* SSLSocketFactory will enable client authentication when supplied with
@@ -142,18 +144,36 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
public static final String SSL = "SSL";
public static final String SSLV2 = "SSLv2";
+ /**
+ * @deprecated Use {@link AllowAllHostnameVerifier#INSTANCE}.
+ */
@Deprecated
public static final X509HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER
= AllowAllHostnameVerifier.INSTANCE;
+ /**
+ * @deprecated Use {@link BrowserCompatHostnameVerifier#INSTANCE}.
+ */
@Deprecated
public static final X509HostnameVerifier BROWSER_COMPATIBLE_HOSTNAME_VERIFIER
= BrowserCompatHostnameVerifier.INSTANCE;
+ /**
+ * @deprecated Use {@link StrictHostnameVerifier#INSTANCE}.
+ */
@Deprecated
public static final X509HostnameVerifier STRICT_HOSTNAME_VERIFIER
= StrictHostnameVerifier.INSTANCE;
+ private static final String WEAK_KEY_EXCHANGES
+ = "^(TLS|SSL)_(NULL|ECDH_anon|DH_anon|DH_anon_EXPORT|DHE_RSA_EXPORT|DHE_DSS_EXPORT|"
+ + "DSS_EXPORT|DH_DSS_EXPORT|DH_RSA_EXPORT|RSA_EXPORT|KRB5_EXPORT)_(.*)";
+ private static final String WEAK_CIPHERS
+ = "^(TLS|SSL)_(.*)_WITH_(NULL|DES_CBC|DES40_CBC|DES_CBC_40|3DES_EDE_CBC|RC4_128|RC4_40|RC2_CBC_40)_(.*)";
+ private static final List WEAK_CIPHER_SUITE_PATTERNS = Collections.unmodifiableList(Arrays.asList(
+ Pattern.compile(WEAK_KEY_EXCHANGES, Pattern.CASE_INSENSITIVE),
+ Pattern.compile(WEAK_CIPHERS, Pattern.CASE_INSENSITIVE)));
+
private final Log log = LogFactory.getLog(getClass());
/**
@@ -174,6 +194,15 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
return new SSLConnectionSocketFactory(SSLContexts.createDefault(), getDefaultHostnameVerifier());
}
+ static boolean isWeakCipherSuite(final String cipherSuite) {
+ for (final Pattern pattern : WEAK_CIPHER_SUITE_PATTERNS) {
+ if (pattern.matcher(cipherSuite).matches()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private static String[] split(final String s) {
if (TextUtils.isBlank(s)) {
return null;
@@ -207,8 +236,8 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
}
/**
- * @deprecated (4.4) Use {@link #SSLConnectionSocketFactory(javax.net.ssl.SSLContext,
- * javax.net.ssl.HostnameVerifier)}
+ * @deprecated (4.4) Use {@link #SSLConnectionSocketFactory(SSLContext,
+ * HostnameVerifier)}
*/
@Deprecated
public SSLConnectionSocketFactory(
@@ -218,8 +247,8 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
}
/**
- * @deprecated (4.4) Use {@link #SSLConnectionSocketFactory(javax.net.ssl.SSLContext,
- * String[], String[], javax.net.ssl.HostnameVerifier)}
+ * @deprecated (4.4) Use {@link #SSLConnectionSocketFactory(SSLContext,
+ * String[], String[], HostnameVerifier)}
*/
@Deprecated
public SSLConnectionSocketFactory(
@@ -233,7 +262,7 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
/**
* @deprecated (4.4) Use {@link #SSLConnectionSocketFactory(javax.net.ssl.SSLSocketFactory,
- * javax.net.ssl.HostnameVerifier)}
+ * HostnameVerifier)}
*/
@Deprecated
public SSLConnectionSocketFactory(
@@ -244,7 +273,7 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
/**
* @deprecated (4.4) Use {@link #SSLConnectionSocketFactory(javax.net.ssl.SSLSocketFactory,
- * String[], String[], javax.net.ssl.HostnameVerifier)}
+ * String[], String[], HostnameVerifier)}
*/
@Deprecated
public SSLConnectionSocketFactory(
@@ -304,7 +333,7 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
* (before the SSL handshake happens).
*
* The default implementation is a no-op, but could be overridden to, e.g.,
- * call {@link javax.net.ssl.SSLSocket#setEnabledCipherSuites(String[])}.
+ * call {@link SSLSocket#setEnabledCipherSuites(String[])}.
* @throws IOException may be thrown if overridden
*/
protected void prepareSocket(final SSLSocket socket) throws IOException {
@@ -351,9 +380,8 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
sslsock.startHandshake();
verifyHostname(sslsock, host.getHostName());
return sock;
- } else {
- return createLayeredSocket(sock, host.getHostName(), remoteAddress.getPort(), context);
}
+ return createLayeredSocket(sock, host.getHostName(), remoteAddress.getPort(), context);
}
@Override
@@ -384,6 +412,18 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
}
if (supportedCipherSuites != null) {
sslsock.setEnabledCipherSuites(supportedCipherSuites);
+ } else {
+ // If cipher suites are not explicitly set, remove all insecure ones
+ final String[] allCipherSuites = sslsock.getEnabledCipherSuites();
+ final List enabledCipherSuites = new ArrayList(allCipherSuites.length);
+ for (final String cipherSuite : allCipherSuites) {
+ if (!isWeakCipherSuite(cipherSuite)) {
+ enabledCipherSuites.add(cipherSuite);
+ }
+ }
+ if (!enabledCipherSuites.isEmpty()) {
+ sslsock.setEnabledCipherSuites(enabledCipherSuites.toArray(new String[enabledCipherSuites.size()]));
+ }
}
if (this.log.isDebugEnabled()) {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/StrictHostnameVerifier.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/StrictHostnameVerifier.java
index cf47d0d76..b5db3fd7a 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/StrictHostnameVerifier.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/StrictHostnameVerifier.java
@@ -52,7 +52,7 @@ import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
*
* @since 4.0
*
- * @deprecated (4.4) Use {@link DefaultHostnameVerifier}
+ * @deprecated (4.4) Use {@link com.fr.third.org.apache.http.conn.ssl.DefaultHostnameVerifier}
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE)
@Deprecated
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/TrustAllStrategy.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/TrustAllStrategy.java
new file mode 100644
index 000000000..96de1ed62
--- /dev/null
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/TrustAllStrategy.java
@@ -0,0 +1,48 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+package com.fr.third.org.apache.http.conn.ssl;
+
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+/**
+ * A trust strategy that accepts all certificates as trusted. Verification of
+ * all other certificates is done by the trust manager configured in the SSL
+ * context.
+ *
+ * @since 4.5.4
+ */
+public class TrustAllStrategy implements TrustStrategy {
+
+ public static final TrustAllStrategy INSTANCE = new TrustAllStrategy();
+
+ @Override
+ public boolean isTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {
+ return true;
+ }
+
+}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/TrustStrategy.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/TrustStrategy.java
index 6da09ac21..468196388 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/TrustStrategy.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/TrustStrategy.java
@@ -27,12 +27,14 @@
package com.fr.third.org.apache.http.conn.ssl;
/**
- * A strategy to establish trustworthiness of certificates without consulting the trust manager
- * configured in the actual SSL context. This interface can be used to override the standard
- * JSSE certificate verification process.
+ * A strategy to establish trustworthiness of certificates without consulting
+ * the trust manager configured in the actual SSL context. This interface can be
+ * used to override the standard JSSE certificate verification process.
*
* @since 4.1
*/
public interface TrustStrategy extends com.fr.third.org.apache.http.ssl.TrustStrategy {
+ // Empty! Inherits from com.fr.third.org.apache.http.ssl.TrustStrategy.
+
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/X509HostnameVerifier.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/X509HostnameVerifier.java
index 88b6e63b7..148cc49a7 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/X509HostnameVerifier.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/X509HostnameVerifier.java
@@ -37,12 +37,12 @@ import javax.net.ssl.SSLSocket;
/**
* Interface for checking if a hostname matches the names stored inside the
* server's X.509 certificate. This interface extends
- * {@link javax.net.ssl.HostnameVerifier}, but it is recommended to use
+ * {@link HostnameVerifier}, but it is recommended to use
* methods added by X509HostnameVerifier.
*
* @since 4.0
*
- * @deprecated (4.4) Use {@link javax.net.ssl.HostnameVerifier}.
+ * @deprecated (4.4) Use {@link HostnameVerifier}.
*/
@Deprecated
public interface X509HostnameVerifier extends HostnameVerifier {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/DnsUtils.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/DnsUtils.java
new file mode 100644
index 000000000..6b8205ea4
--- /dev/null
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/DnsUtils.java
@@ -0,0 +1,76 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+
+package com.fr.third.org.apache.http.conn.util;
+
+/**
+ * A collection of utilities relating to Domain Name System.
+ *
+ * @since 4.5
+ */
+public class DnsUtils {
+
+ private DnsUtils() {
+ }
+
+ private static boolean isUpper(final char c) {
+ return c >= 'A' && c <= 'Z';
+ }
+
+ public static String normalize(final String s) {
+ if (s == null) {
+ return null;
+ }
+ int pos = 0;
+ int remaining = s.length();
+ while (remaining > 0) {
+ if (isUpper(s.charAt(pos))) {
+ break;
+ }
+ pos++;
+ remaining--;
+ }
+ if (remaining > 0) {
+ final StringBuilder buf = new StringBuilder(s.length());
+ buf.append(s, 0, pos);
+ while (remaining > 0) {
+ final char c = s.charAt(pos);
+ if (isUpper(c)) {
+ buf.append((char) (c + ('a' - 'A')));
+ } else {
+ buf.append(c);
+ }
+ pos++;
+ remaining--;
+ }
+ return buf.toString();
+ } else {
+ return s;
+ }
+ }
+
+}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/PublicSuffixListParser.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/PublicSuffixListParser.java
index 0cc484eb5..2efcb356e 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/PublicSuffixListParser.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/PublicSuffixListParser.java
@@ -54,7 +54,7 @@ public final class PublicSuffixListParser {
* (the original list is in UTF-8).
*
* @param reader the data reader. The caller is responsible for closing the reader.
- * @throws java.io.IOException on error while reading from list
+ * @throws IOException on error while reading from list
*/
public PublicSuffixList parse(final Reader reader) throws IOException {
final List rules = new ArrayList();
@@ -94,7 +94,7 @@ public final class PublicSuffixListParser {
* (the original list is in UTF-8).
*
* @param reader the data reader. The caller is responsible for closing the reader.
- * @throws java.io.IOException on error while reading from list
+ * @throws IOException on error while reading from list
*
* @since 4.5
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/PublicSuffixMatcher.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/PublicSuffixMatcher.java
index 9c1c4fb8a..5648f6994 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/PublicSuffixMatcher.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/PublicSuffixMatcher.java
@@ -29,7 +29,6 @@ package com.fr.third.org.apache.http.conn.util;
import java.net.IDN;
import java.util.Collection;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -43,7 +42,7 @@ import com.fr.third.org.apache.http.util.Args;
* An up-to-date list of suffixes can be obtained from
* publicsuffix.org
*
- * @see PublicSuffixList
+ * @see com.fr.third.org.apache.http.conn.util.PublicSuffixList
*
* @since 4.4
*/
@@ -98,24 +97,15 @@ public final class PublicSuffixMatcher {
}
}
- private static boolean hasEntry(final Map map, final String rule, final DomainType expectedType) {
+ private static DomainType findEntry(final Map map, final String rule) {
if (map == null) {
- return false;
- }
- final DomainType domainType = map.get(rule);
- if (domainType == null) {
- return false;
- } else {
- return expectedType == null || domainType.equals(expectedType);
+ return null;
}
+ return map.get(rule);
}
- private boolean hasRule(final String rule, final DomainType expectedType) {
- return hasEntry(this.rules, rule, expectedType);
- }
-
- private boolean hasException(final String exception, final DomainType expectedType) {
- return hasEntry(this.exceptions, exception, expectedType);
+ private static boolean match(final DomainType domainType, final DomainType expectedType) {
+ return domainType != null && (expectedType == null || domainType.equals(expectedType));
}
/**
@@ -146,33 +136,47 @@ public final class PublicSuffixMatcher {
if (domain.startsWith(".")) {
return null;
}
- String domainName = null;
- String segment = domain.toLowerCase(Locale.ROOT);
+ final String normalized = DnsUtils.normalize(domain);
+ String segment = normalized;
+ String result = null;
while (segment != null) {
-
// An exception rule takes priority over any other matching rule.
- if (hasException(IDN.toUnicode(segment), expectedType)) {
+ final String key = IDN.toUnicode(segment);
+ final DomainType exceptionRule = findEntry(exceptions, key);
+ if (match(exceptionRule, expectedType)) {
return segment;
}
-
- if (hasRule(IDN.toUnicode(segment), expectedType)) {
- break;
+ final DomainType domainRule = findEntry(rules, key);
+ if (match(domainRule, expectedType)) {
+ if (domainRule == DomainType.PRIVATE) {
+ return segment;
+ }
+ return result;
}
final int nextdot = segment.indexOf('.');
final String nextSegment = nextdot != -1 ? segment.substring(nextdot + 1) : null;
if (nextSegment != null) {
- if (hasRule("*." + IDN.toUnicode(nextSegment), expectedType)) {
- break;
+ final DomainType wildcardDomainRule = findEntry(rules, "*." + IDN.toUnicode(nextSegment));
+ if (match(wildcardDomainRule, expectedType)) {
+ if (wildcardDomainRule == DomainType.PRIVATE) {
+ return segment;
+ }
+ return result;
}
}
- if (nextdot != -1) {
- domainName = segment;
- }
+ result = segment;
segment = nextSegment;
}
- return domainName;
+
+ // If no expectations then this result is good.
+ if (expectedType == null || expectedType == DomainType.UNKNOWN) {
+ return result;
+ }
+
+ // If we did have expectations apparently there was no match
+ return null;
}
/**
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/PublicSuffixMatcherLoader.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/PublicSuffixMatcherLoader.java
index 62e492c0f..c03161274 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/PublicSuffixMatcherLoader.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/util/PublicSuffixMatcherLoader.java
@@ -43,7 +43,7 @@ import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.util.Args;
/**
- * {@link PublicSuffixMatcher} loader.
+ * {@link com.fr.third.org.apache.http.conn.util.PublicSuffixMatcher} loader.
*
* @since 4.4
*/
@@ -95,7 +95,7 @@ public final class PublicSuffixMatcherLoader {
}
}
} else {
- DEFAULT_INSTANCE = new PublicSuffixMatcher(Arrays.asList("com"), null);
+ DEFAULT_INSTANCE = new PublicSuffixMatcher(DomainType.ICANN, Arrays.asList("com"), null);
}
}
}
@@ -103,4 +103,4 @@ public final class PublicSuffixMatcherLoader {
return DEFAULT_INSTANCE;
}
-}
\ No newline at end of file
+}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/CommonCookieAttributeHandler.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/CommonCookieAttributeHandler.java
index 7eb86b3d3..ce80d608c 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/CommonCookieAttributeHandler.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/CommonCookieAttributeHandler.java
@@ -27,7 +27,7 @@
package com.fr.third.org.apache.http.cookie;
/**
- * Extension of {@link CookieAttributeHandler} intended
+ * Extension of {@link com.fr.third.org.apache.http.cookie.CookieAttributeHandler} intended
* to handle one specific common attribute whose name is returned with
* {@link #getAttributeName()} method.
*
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/CookieAttributeHandler.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/CookieAttributeHandler.java
index 86034b798..4e8d913c3 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/CookieAttributeHandler.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/CookieAttributeHandler.java
@@ -42,9 +42,9 @@ public interface CookieAttributeHandler {
/**
* Parse the given cookie attribute value and update the corresponding
- * {@link Cookie} property.
+ * {@link com.fr.third.org.apache.http.cookie.Cookie} property.
*
- * @param cookie {@link Cookie} to be updated
+ * @param cookie {@link com.fr.third.org.apache.http.cookie.Cookie} to be updated
* @param value cookie attribute value from the cookie response header
*/
void parse(SetCookie cookie, String value)
@@ -53,7 +53,7 @@ public interface CookieAttributeHandler {
/**
* Peforms cookie validation for the given attribute value.
*
- * @param cookie {@link Cookie} to validate
+ * @param cookie {@link com.fr.third.org.apache.http.cookie.Cookie} to validate
* @param origin the cookie source to validate against
* @throws MalformedCookieException if cookie validation fails for this attribute
*/
@@ -64,7 +64,7 @@ public interface CookieAttributeHandler {
* Matches the given value (property of the destination host where request is being
* submitted) with the corresponding cookie attribute.
*
- * @param cookie {@link Cookie} to match
+ * @param cookie {@link com.fr.third.org.apache.http.cookie.Cookie} to match
* @param origin the cookie source to match against
* @return {@code true} if the match is successful; {@code false} otherwise
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/CookieSpecRegistry.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/CookieSpecRegistry.java
index a8ad7e4e9..401357a68 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/CookieSpecRegistry.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/CookieSpecRegistry.java
@@ -33,7 +33,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import com.fr.third.org.apache.http.config.Registry;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
@@ -50,7 +49,7 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link Registry}.
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.config.Registry}.
*/
@Contract(threading = ThreadingBehavior.SAFE)
@Deprecated
@@ -108,9 +107,8 @@ public final class CookieSpecRegistry implements Lookup {
final CookieSpecFactory factory = registeredSpecs.get(name.toLowerCase(Locale.ENGLISH));
if (factory != null) {
return factory.newInstance(params);
- } else {
- throw new IllegalStateException("Unsupported cookie spec: " + name);
}
+ throw new IllegalStateException("Unsupported cookie spec: " + name);
}
/**
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/params/CookieSpecPNames.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/params/CookieSpecPNames.java
index 4b4ffa9a6..5fa790e6b 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/params/CookieSpecPNames.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/cookie/params/CookieSpecPNames.java
@@ -27,15 +27,13 @@
package com.fr.third.org.apache.http.cookie.params;
-import com.fr.third.org.apache.http.cookie.CookieSpecProvider;
-
/**
* Parameter names for HTTP cookie management classes.
*
* @since 4.0
*
* @deprecated (4.3) use constructor parameters of {@link
- * CookieSpecProvider}s.
+ * com.fr.third.org.apache.http.cookie.CookieSpecProvider}s.
*/
@Deprecated
public interface CookieSpecPNames {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/AuthSchemeBase.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/AuthSchemeBase.java
index 447bd837d..eda245623 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/AuthSchemeBase.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/AuthSchemeBase.java
@@ -159,11 +159,7 @@ public abstract class AuthSchemeBase implements ContextAwareAuthScheme {
@Override
public String toString() {
final String name = getSchemeName();
- if (name != null) {
- return name.toUpperCase(Locale.ROOT);
- } else {
- return super.toString();
- }
+ return name != null ? name.toUpperCase(Locale.ROOT) : super.toString();
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/BasicScheme.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/BasicScheme.java
index 2bf008bab..17f62a440 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/BasicScheme.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/BasicScheme.java
@@ -28,8 +28,6 @@ package com.fr.third.org.apache.http.impl.auth;
import java.nio.charset.Charset;
-import com.fr.third.org.apache.http.auth.ContextAwareAuthScheme;
-import com.fr.third.org.apache.http.auth.InvalidCredentialsException;
import com.fr.third.org.apache.commons.codec.binary.Base64;
import com.fr.third.org.apache.http.Consts;
import com.fr.third.org.apache.http.Header;
@@ -130,8 +128,8 @@ public class BasicScheme extends RFC2617Scheme {
}
/**
- * @deprecated (4.2) Use {@link ContextAwareAuthScheme#authenticate(
- * Credentials, HttpRequest, HttpContext)}
+ * @deprecated (4.2) Use {@link com.fr.third.org.apache.http.auth.ContextAwareAuthScheme#authenticate(
+ * Credentials, HttpRequest, com.fr.third.org.apache.http.protocol.HttpContext)}
*/
@Override
@Deprecated
@@ -145,7 +143,7 @@ public class BasicScheme extends RFC2617Scheme {
*
* @param credentials The set of credentials to be used for authentication
* @param request The request being authenticated
- * @throws InvalidCredentialsException if authentication
+ * @throws com.fr.third.org.apache.http.auth.InvalidCredentialsException if authentication
* credentials are not valid or not applicable for this authentication scheme
* @throws AuthenticationException if authorization string cannot
* be generated due to an authentication failure
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/DigestScheme.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/DigestScheme.java
index e68a13847..ddc1a6e76 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/DigestScheme.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/DigestScheme.java
@@ -46,9 +46,7 @@ import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.auth.AUTH;
import com.fr.third.org.apache.http.auth.AuthenticationException;
import com.fr.third.org.apache.http.auth.ChallengeState;
-import com.fr.third.org.apache.http.auth.ContextAwareAuthScheme;
import com.fr.third.org.apache.http.auth.Credentials;
-import com.fr.third.org.apache.http.auth.InvalidCredentialsException;
import com.fr.third.org.apache.http.auth.MalformedChallengeException;
import com.fr.third.org.apache.http.message.BasicHeaderValueFormatter;
import com.fr.third.org.apache.http.message.BasicNameValuePair;
@@ -154,11 +152,7 @@ public class DigestScheme extends RFC2617Scheme {
@Override
public boolean isComplete() {
final String s = getParameter("stale");
- if ("true".equalsIgnoreCase(s)) {
- return false;
- } else {
- return this.complete;
- }
+ return "true".equalsIgnoreCase(s) ? false : this.complete;
}
/**
@@ -186,8 +180,8 @@ public class DigestScheme extends RFC2617Scheme {
}
/**
- * @deprecated (4.2) Use {@link ContextAwareAuthScheme#authenticate(
- * Credentials, HttpRequest, HttpContext)}
+ * @deprecated (4.2) Use {@link com.fr.third.org.apache.http.auth.ContextAwareAuthScheme#authenticate(
+ * Credentials, HttpRequest, com.fr.third.org.apache.http.protocol.HttpContext)}
*/
@Override
@Deprecated
@@ -203,7 +197,7 @@ public class DigestScheme extends RFC2617Scheme {
* @param credentials A set of credentials to be used for athentication
* @param request The request being authenticated
*
- * @throws InvalidCredentialsException if authentication credentials
+ * @throws com.fr.third.org.apache.http.auth.InvalidCredentialsException if authentication credentials
* are not valid or not applicable for this authentication scheme
* @throws AuthenticationException if authorization string cannot
* be generated due to an authentication failure
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/GGSSchemeBase.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/GGSSchemeBase.java
index a95bcb4eb..62eb7da54 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/GGSSchemeBase.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/GGSSchemeBase.java
@@ -29,7 +29,6 @@ package com.fr.third.org.apache.http.impl.auth;
import java.net.InetAddress;
import java.net.UnknownHostException;
-import com.fr.third.org.apache.http.auth.ContextAwareAuthScheme;
import com.fr.third.org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -121,11 +120,9 @@ public abstract class GGSSchemeBase extends AuthSchemeBase {
}
final GSSContext gssContext = createGSSContext(manager, oid, serverName, gssCredential);
- if (input != null) {
- return gssContext.initSecContext(input, 0, input.length);
- } else {
- return gssContext.initSecContext(new byte[] {}, 0, 0);
- }
+ return input != null
+ ? gssContext.initSecContext(input, 0, input.length)
+ : gssContext.initSecContext(new byte[] {}, 0, 0);
}
GSSContext createGSSContext(
@@ -139,7 +136,7 @@ public abstract class GGSSchemeBase extends AuthSchemeBase {
return gssContext;
}
/**
- * @deprecated (4.4) Use {@link #generateToken(byte[], String, Credentials)}.
+ * @deprecated (4.4) Use {@link #generateToken(byte[], String, com.fr.third.org.apache.http.auth.Credentials)}.
*/
@Deprecated
protected byte[] generateToken(final byte[] input, final String authServer) throws GSSException {
@@ -162,8 +159,8 @@ public abstract class GGSSchemeBase extends AuthSchemeBase {
}
/**
- * @deprecated (4.2) Use {@link ContextAwareAuthScheme#authenticate(
- * Credentials, HttpRequest, HttpContext)}
+ * @deprecated (4.2) Use {@link com.fr.third.org.apache.http.auth.ContextAwareAuthScheme#authenticate(
+ * Credentials, HttpRequest, com.fr.third.org.apache.http.protocol.HttpContext)}
*/
@Override
@Deprecated
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/HttpAuthenticator.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/HttpAuthenticator.java
index f71252d83..ceb24ece5 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/HttpAuthenticator.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/HttpAuthenticator.java
@@ -79,21 +79,20 @@ public class HttpAuthenticator {
authStrategy.authFailed(host, authState.getAuthScheme(), context);
}
return true;
- } else {
- switch (authState.getState()) {
- case CHALLENGED:
- case HANDSHAKE:
- this.log.debug("Authentication succeeded");
- authState.setState(AuthProtocolState.SUCCESS);
- authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
- break;
- case SUCCESS:
- break;
- default:
- authState.setState(AuthProtocolState.UNCHALLENGED);
- }
- return false;
}
+ switch (authState.getState()) {
+ case CHALLENGED:
+ case HANDSHAKE:
+ this.log.debug("Authentication succeeded");
+ authState.setState(AuthProtocolState.SUCCESS);
+ authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
+ break;
+ case SUCCESS:
+ break;
+ default:
+ authState.setState(AuthProtocolState.UNCHALLENGED);
+ }
+ return false;
}
public boolean handleAuthChallenge(
@@ -141,14 +140,12 @@ public class HttpAuthenticator {
authState.reset();
authState.setState(AuthProtocolState.FAILURE);
return false;
- } else {
- authState.setState(AuthProtocolState.HANDSHAKE);
- return true;
}
- } else {
- authState.reset();
- // Retry authentication with a different scheme
+ authState.setState(AuthProtocolState.HANDSHAKE);
+ return true;
}
+ authState.reset();
+ // Retry authentication with a different scheme
}
}
final Queue authOptions = authStrategy.select(challenges, host, response, context);
@@ -159,9 +156,8 @@ public class HttpAuthenticator {
authState.setState(AuthProtocolState.CHALLENGED);
authState.update(authOptions);
return true;
- } else {
- return false;
}
+ return false;
} catch (final MalformedChallengeException ex) {
if (this.log.isWarnEnabled()) {
this.log.warn("Malformed challenge: " + ex.getMessage());
@@ -209,9 +205,8 @@ public class HttpAuthenticator {
}
}
return;
- } else {
- ensureAuthScheme(authScheme);
}
+ ensureAuthScheme(authScheme);
}
if (authScheme != null) {
try {
@@ -235,11 +230,10 @@ public class HttpAuthenticator {
final Credentials creds,
final HttpRequest request,
final HttpContext context) throws AuthenticationException {
- if (authScheme instanceof ContextAwareAuthScheme) {
- return ((ContextAwareAuthScheme) authScheme).authenticate(creds, request, context);
- } else {
- return authScheme.authenticate(creds, request);
- }
+ return authScheme instanceof ContextAwareAuthScheme
+ ? ((ContextAwareAuthScheme) authScheme).authenticate(creds, request,
+ context)
+ : authScheme.authenticate(creds, request);
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/NTLMEngineImpl.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/NTLMEngineImpl.java
index a6fb42250..8ede9eaa7 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/NTLMEngineImpl.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/auth/NTLMEngineImpl.java
@@ -26,12 +26,15 @@
*/
package com.fr.third.org.apache.http.impl.auth;
-import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.security.Key;
import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
import java.util.Arrays;
import java.util.Locale;
+import java.util.Random;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
@@ -39,8 +42,6 @@ import javax.crypto.spec.SecretKeySpec;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.commons.codec.binary.Base64;
import com.fr.third.org.apache.http.Consts;
-import com.fr.third.org.apache.http.util.CharsetUtils;
-import com.fr.third.org.apache.http.util.EncodingUtils;
/**
* Provides an implementation for NTLMv1, NTLMv2, and NTLM2 Session forms of the NTLM
@@ -51,7 +52,7 @@ import com.fr.third.org.apache.http.util.EncodingUtils;
final class NTLMEngineImpl implements NTLMEngine {
/** Unicode encoding */
- private static final Charset UNICODE_LITTLE_UNMARKED = CharsetUtils.lookup("UnicodeLittleUnmarked");
+ private static final Charset UNICODE_LITTLE_UNMARKED = Charset.forName("UnicodeLittleUnmarked");
/** Character encoding */
private static final Charset DEFAULT_CHARSET = Consts.ASCII;
@@ -59,22 +60,41 @@ final class NTLMEngineImpl implements NTLMEngine {
// http://davenport.sourceforge.net/ntlm.html
// and
// http://msdn.microsoft.com/en-us/library/cc236650%28v=prot.20%29.aspx
- protected static final int FLAG_REQUEST_UNICODE_ENCODING = 0x00000001; // Unicode string encoding requested
- protected static final int FLAG_REQUEST_TARGET = 0x00000004; // Requests target field
- protected static final int FLAG_REQUEST_SIGN = 0x00000010; // Requests all messages have a signature attached, in NEGOTIATE message.
- protected static final int FLAG_REQUEST_SEAL = 0x00000020; // Request key exchange for message confidentiality in NEGOTIATE message. MUST be used in conjunction with 56BIT.
- protected static final int FLAG_REQUEST_LAN_MANAGER_KEY = 0x00000080; // Request Lan Manager key instead of user session key
- protected static final int FLAG_REQUEST_NTLMv1 = 0x00000200; // Request NTLMv1 security. MUST be set in NEGOTIATE and CHALLENGE both
- protected static final int FLAG_DOMAIN_PRESENT = 0x00001000; // Domain is present in message
- protected static final int FLAG_WORKSTATION_PRESENT = 0x00002000; // Workstation is present in message
- protected static final int FLAG_REQUEST_ALWAYS_SIGN = 0x00008000; // Requests a signature block on all messages. Overridden by REQUEST_SIGN and REQUEST_SEAL.
- protected static final int FLAG_REQUEST_NTLM2_SESSION = 0x00080000; // From server in challenge, requesting NTLM2 session security
- protected static final int FLAG_REQUEST_VERSION = 0x02000000; // Request protocol version
- protected static final int FLAG_TARGETINFO_PRESENT = 0x00800000; // From server in challenge message, indicating targetinfo is present
- protected static final int FLAG_REQUEST_128BIT_KEY_EXCH = 0x20000000; // Request explicit 128-bit key exchange
- protected static final int FLAG_REQUEST_EXPLICIT_KEY_EXCH = 0x40000000; // Request explicit key exchange
- protected static final int FLAG_REQUEST_56BIT_ENCRYPTION = 0x80000000; // Must be used in conjunction with SEAL
-
+ // [MS-NLMP] section 2.2.2.5
+ static final int FLAG_REQUEST_UNICODE_ENCODING = 0x00000001; // Unicode string encoding requested
+ static final int FLAG_REQUEST_OEM_ENCODING = 0x00000002; // OEM string encoding requested
+ static final int FLAG_REQUEST_TARGET = 0x00000004; // Requests target field
+ static final int FLAG_REQUEST_SIGN = 0x00000010; // Requests all messages have a signature attached, in NEGOTIATE message.
+ static final int FLAG_REQUEST_SEAL = 0x00000020; // Request key exchange for message confidentiality in NEGOTIATE message. MUST be used in conjunction with 56BIT.
+ static final int FLAG_REQUEST_LAN_MANAGER_KEY = 0x00000080; // Request Lan Manager key instead of user session key
+ static final int FLAG_REQUEST_NTLMv1 = 0x00000200; // Request NTLMv1 security. MUST be set in NEGOTIATE and CHALLENGE both
+ static final int FLAG_DOMAIN_PRESENT = 0x00001000; // Domain is present in message
+ static final int FLAG_WORKSTATION_PRESENT = 0x00002000; // Workstation is present in message
+ static final int FLAG_REQUEST_ALWAYS_SIGN = 0x00008000; // Requests a signature block on all messages. Overridden by REQUEST_SIGN and REQUEST_SEAL.
+ static final int FLAG_REQUEST_NTLM2_SESSION = 0x00080000; // From server in challenge, requesting NTLM2 session security
+ static final int FLAG_REQUEST_VERSION = 0x02000000; // Request protocol version
+ static final int FLAG_TARGETINFO_PRESENT = 0x00800000; // From server in challenge message, indicating targetinfo is present
+ static final int FLAG_REQUEST_128BIT_KEY_EXCH = 0x20000000; // Request explicit 128-bit key exchange
+ static final int FLAG_REQUEST_EXPLICIT_KEY_EXCH = 0x40000000; // Request explicit key exchange
+ static final int FLAG_REQUEST_56BIT_ENCRYPTION = 0x80000000; // Must be used in conjunction with SEAL
+
+ // Attribute-value identifiers (AvId)
+ // according to [MS-NLMP] section 2.2.2.1
+ static final int MSV_AV_EOL = 0x0000; // Indicates that this is the last AV_PAIR in the list.
+ static final int MSV_AV_NB_COMPUTER_NAME = 0x0001; // The server's NetBIOS computer name.
+ static final int MSV_AV_NB_DOMAIN_NAME = 0x0002; // The server's NetBIOS domain name.
+ static final int MSV_AV_DNS_COMPUTER_NAME = 0x0003; // The fully qualified domain name (FQDN) of the computer.
+ static final int MSV_AV_DNS_DOMAIN_NAME = 0x0004; // The FQDN of the domain.
+ static final int MSV_AV_DNS_TREE_NAME = 0x0005; // The FQDN of the forest.
+ static final int MSV_AV_FLAGS = 0x0006; // A 32-bit value indicating server or client configuration.
+ static final int MSV_AV_TIMESTAMP = 0x0007; // server local time
+ static final int MSV_AV_SINGLE_HOST = 0x0008; // A Single_Host_Data structure.
+ static final int MSV_AV_TARGET_NAME = 0x0009; // The SPN of the target server.
+ static final int MSV_AV_CHANNEL_BINDINGS = 0x000A; // A channel bindings hash.
+
+ static final int MSV_AV_FLAGS_ACCOUNT_AUTH_CONSTAINED = 0x00000001; // Indicates to the client that the account authentication is constrained.
+ static final int MSV_AV_FLAGS_MIC = 0x00000002; // Indicates that the client is providing message integrity in the MIC field in the AUTHENTICATE_MESSAGE.
+ static final int MSV_AV_FLAGS_UNTRUSTED_TARGET_SPN = 0x00000004; // Indicates that the client is providing a target SPN generated from an untrusted source.
/** Secure random generator */
private static final java.security.SecureRandom RND_GEN;
@@ -88,46 +108,34 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** The signature string as bytes in the default encoding */
- private static final byte[] SIGNATURE;
-
- static {
- final byte[] bytesWithoutNull = "NTLMSSP".getBytes(Consts.ASCII);
- SIGNATURE = new byte[bytesWithoutNull.length + 1];
- System.arraycopy(bytesWithoutNull, 0, SIGNATURE, 0, bytesWithoutNull.length);
- SIGNATURE[bytesWithoutNull.length] = (byte) 0x00;
+ private static final byte[] SIGNATURE = getNullTerminatedAsciiString("NTLMSSP");
+
+ // Key derivation magic strings for the SIGNKEY algorithm defined in
+ // [MS-NLMP] section 3.4.5.2
+ private static final byte[] SIGN_MAGIC_SERVER = getNullTerminatedAsciiString(
+ "session key to server-to-client signing key magic constant");
+ private static final byte[] SIGN_MAGIC_CLIENT = getNullTerminatedAsciiString(
+ "session key to client-to-server signing key magic constant");
+ private static final byte[] SEAL_MAGIC_SERVER = getNullTerminatedAsciiString(
+ "session key to server-to-client sealing key magic constant");
+ private static final byte[] SEAL_MAGIC_CLIENT = getNullTerminatedAsciiString(
+ "session key to client-to-server sealing key magic constant");
+
+ // prefix for GSS API channel binding
+ private static final byte[] MAGIC_TLS_SERVER_ENDPOINT = "tls-server-end-point:".getBytes(Consts.ASCII);
+
+ private static byte[] getNullTerminatedAsciiString( final String source )
+ {
+ final byte[] bytesWithoutNull = source.getBytes(Consts.ASCII);
+ final byte[] target = new byte[bytesWithoutNull.length + 1];
+ System.arraycopy(bytesWithoutNull, 0, target, 0, bytesWithoutNull.length);
+ target[bytesWithoutNull.length] = (byte) 0x00;
+ return target;
}
private static final String TYPE_1_MESSAGE = new Type1Message().getResponse();
- /**
- * Returns the response for the given message.
- *
- * @param message
- * the message that was received from the server.
- * @param username
- * the username to authenticate with.
- * @param password
- * the password to authenticate with.
- * @param host
- * The host.
- * @param domain
- * the NT domain to authenticate in.
- * @return The response.
- * @throws HttpException
- * If the messages cannot be retrieved.
- */
- static String getResponseFor(final String message, final String username, final String password,
- final String host, final String domain) throws NTLMEngineException {
-
- final String response;
- if (message == null || message.trim().equals("")) {
- response = getType1Message(host, domain);
- } else {
- final Type2Message t2m = new Type2Message(message);
- response = getType3Message(username, password, host, domain, t2m.getChallenge(), t2m
- .getFlags(), t2m.getTarget(), t2m.getTargetInfo());
- }
- return response;
+ NTLMEngineImpl() {
}
/**
@@ -141,7 +149,7 @@ final class NTLMEngineImpl implements NTLMEngine {
* The domain to authenticate with.
* @return String the message to add to the HTTP request header.
*/
- static String getType1Message(final String host, final String domain) throws NTLMEngineException {
+ static String getType1Message(final String host, final String domain) {
// For compatibility reason do not include domain and host in type 1 message
//return new Type1Message(domain, host).getResponse();
return TYPE_1_MESSAGE;
@@ -165,7 +173,8 @@ final class NTLMEngineImpl implements NTLMEngine {
* the 8 byte array the server sent.
* @return The type 3 message.
* @throws NTLMEngineException
- * If {@encrypt(byte[],byte[])} fails.
+ * If {@link #Type3Message
+ * (String, String, String, String, byte[], int, String, byte[])} fails.
*/
static String getType3Message(final String user, final String password, final String host, final String domain,
final byte[] nonce, final int type2Flags, final String target, final byte[] targetInformation)
@@ -174,49 +183,55 @@ final class NTLMEngineImpl implements NTLMEngine {
targetInformation).getResponse();
}
- /** Strip dot suffix from a name */
- private static String stripDotSuffix(final String value) {
- if (value == null) {
- return null;
- }
- final int index = value.indexOf(".");
- if (index != -1) {
- return value.substring(0, index);
- }
- return value;
- }
-
- /** Convert host to standard form */
- private static String convertHost(final String host) {
- return stripDotSuffix(host);
- }
-
- /** Convert domain to standard form */
- private static String convertDomain(final String domain) {
- return stripDotSuffix(domain);
+ /**
+ * Creates the type 3 message using the given server nonce. The type 3
+ * message includes all the information for authentication, host, domain,
+ * username and the result of encrypting the nonce sent by the server using
+ * the user's password as the key.
+ *
+ * @param user
+ * The user name. This should not include the domain name.
+ * @param password
+ * The password.
+ * @param host
+ * The host that is originating the authentication request.
+ * @param domain
+ * The domain to authenticate within.
+ * @param nonce
+ * the 8 byte array the server sent.
+ * @return The type 3 message.
+ * @throws NTLMEngineException
+ * If {@link #Type3Message
+ * (String, String, String, String, byte[], int, String, byte[], Certificate, byte[], byte[])} fails.
+ */
+ static String getType3Message(final String user, final String password, final String host, final String domain,
+ final byte[] nonce, final int type2Flags, final String target, final byte[] targetInformation,
+ final Certificate peerServerCertificate, final byte[] type1Message, final byte[] type2Message)
+ throws NTLMEngineException {
+ return new Type3Message(domain, host, user, password, nonce, type2Flags, target,
+ targetInformation, peerServerCertificate, type1Message, type2Message).getResponse();
}
- private static int readULong(final byte[] src, final int index) throws NTLMEngineException {
+ private static int readULong(final byte[] src, final int index) {
if (src.length < index + 4) {
- throw new NTLMEngineException("NTLM authentication - buffer too small for DWORD");
+ return 0;
}
return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8)
| ((src[index + 2] & 0xff) << 16) | ((src[index + 3] & 0xff) << 24);
}
- private static int readUShort(final byte[] src, final int index) throws NTLMEngineException {
+ private static int readUShort(final byte[] src, final int index) {
if (src.length < index + 2) {
- throw new NTLMEngineException("NTLM authentication - buffer too small for WORD");
+ return 0;
}
return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8);
}
- private static byte[] readSecurityBuffer(final byte[] src, final int index) throws NTLMEngineException {
+ private static byte[] readSecurityBuffer(final byte[] src, final int index) {
final int length = readUShort(src, index);
final int offset = readULong(src, index + 4);
if (src.length < offset + length) {
- throw new NTLMEngineException(
- "NTLM authentication - buffer too small for data item");
+ return new byte[length];
}
final byte[] buffer = new byte[length];
System.arraycopy(src, offset, buffer, 0, length);
@@ -224,31 +239,28 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Calculate a challenge block */
- private static byte[] makeRandomChallenge() throws NTLMEngineException {
- if (RND_GEN == null) {
- throw new NTLMEngineException("Random generator not available");
- }
+ private static byte[] makeRandomChallenge(final Random random) {
final byte[] rval = new byte[8];
- synchronized (RND_GEN) {
- RND_GEN.nextBytes(rval);
+ synchronized (random) {
+ random.nextBytes(rval);
}
return rval;
}
/** Calculate a 16-byte secondary key */
- private static byte[] makeSecondaryKey() throws NTLMEngineException {
- if (RND_GEN == null) {
- throw new NTLMEngineException("Random generator not available");
- }
+ private static byte[] makeSecondaryKey(final Random random) {
final byte[] rval = new byte[16];
- synchronized (RND_GEN) {
- RND_GEN.nextBytes(rval);
+ synchronized (random) {
+ random.nextBytes(rval);
}
return rval;
}
protected static class CipherGen {
+ protected final Random random;
+ protected final long currentTime;
+
protected final String domain;
protected final String user;
protected final String password;
@@ -280,10 +292,28 @@ final class NTLMEngineImpl implements NTLMEngine {
protected byte[] ntlm2SessionResponseUserSessionKey = null;
protected byte[] lanManagerSessionKey = null;
+ /**
+ * @deprecated Use {@link CipherGen#CipherGen(Random, long, String, String, String, byte[], String, byte[], byte[], byte[], byte[], byte[])}
+ */
+ @Deprecated
public CipherGen(final String domain, final String user, final String password,
final byte[] challenge, final String target, final byte[] targetInformation,
final byte[] clientChallenge, final byte[] clientChallenge2,
final byte[] secondaryKey, final byte[] timestamp) {
+ this(RND_GEN, System.currentTimeMillis(),
+ domain, user, password, challenge, target, targetInformation,
+ clientChallenge, clientChallenge2,
+ secondaryKey, timestamp);
+ }
+
+ public CipherGen(final Random random, final long currentTime,
+ final String domain, final String user, final String password,
+ final byte[] challenge, final String target, final byte[] targetInformation,
+ final byte[] clientChallenge, final byte[] clientChallenge2,
+ final byte[] secondaryKey, final byte[] timestamp) {
+ this.random = random;
+ this.currentTime = currentTime;
+
this.domain = domain;
this.target = target;
this.user = user;
@@ -296,16 +326,34 @@ final class NTLMEngineImpl implements NTLMEngine {
this.timestamp = timestamp;
}
- public CipherGen(final String domain, final String user, final String password,
- final byte[] challenge, final String target, final byte[] targetInformation) {
- this(domain, user, password, challenge, target, targetInformation, null, null, null, null);
+ /**
+ * @deprecated Use {@link CipherGen#CipherGen(Random, long, String, String, String, byte[], String, byte[], byte[], byte[], byte[], byte[])}
+ */
+ @Deprecated
+ public CipherGen(final String domain,
+ final String user,
+ final String password,
+ final byte[] challenge,
+ final String target,
+ final byte[] targetInformation) {
+ this(RND_GEN, System.currentTimeMillis(), domain, user, password, challenge, target, targetInformation);
+ }
+
+ public CipherGen(final Random random, final long currentTime,
+ final String domain,
+ final String user,
+ final String password,
+ final byte[] challenge,
+ final String target,
+ final byte[] targetInformation) {
+ this(random, currentTime, domain, user, password, challenge, target, targetInformation, null, null, null, null);
}
/** Calculate and return client challenge */
public byte[] getClientChallenge()
throws NTLMEngineException {
if (clientChallenge == null) {
- clientChallenge = makeRandomChallenge();
+ clientChallenge = makeRandomChallenge(random);
}
return clientChallenge;
}
@@ -314,7 +362,7 @@ final class NTLMEngineImpl implements NTLMEngine {
public byte[] getClientChallenge2()
throws NTLMEngineException {
if (clientChallenge2 == null) {
- clientChallenge2 = makeRandomChallenge();
+ clientChallenge2 = makeRandomChallenge(random);
}
return clientChallenge2;
}
@@ -323,7 +371,7 @@ final class NTLMEngineImpl implements NTLMEngine {
public byte[] getSecondaryKey()
throws NTLMEngineException {
if (secondaryKey == null) {
- secondaryKey = makeSecondaryKey();
+ secondaryKey = makeSecondaryKey(random);
}
return secondaryKey;
}
@@ -385,7 +433,7 @@ final class NTLMEngineImpl implements NTLMEngine {
/** Calculate a timestamp */
public byte[] getTimestamp() {
if (timestamp == null) {
- long time = System.currentTimeMillis();
+ long time = this.currentTime;
time += 11644473600000l; // milliseconds from January 1, 1601 -> epoch.
time *= 10000; // tenths of a microsecond.
// convert to little-endian byte array.
@@ -553,7 +601,7 @@ final class NTLMEngineImpl implements NTLMEngine {
static byte[] ntlm2SessionResponse(final byte[] ntlmHash, final byte[] challenge,
final byte[] clientChallenge) throws NTLMEngineException {
try {
- final MessageDigest md5 = MessageDigest.getInstance("MD5");
+ final MessageDigest md5 = getMD5();
md5.update(challenge);
md5.update(clientChallenge);
final byte[] digest = md5.digest();
@@ -708,8 +756,7 @@ final class NTLMEngineImpl implements NTLMEngine {
* @return The response (either NTLMv2 or LMv2, depending on the client
* data).
*/
- private static byte[] lmv2Response(final byte[] hash, final byte[] challenge, final byte[] clientData)
- throws NTLMEngineException {
+ private static byte[] lmv2Response(final byte[] hash, final byte[] challenge, final byte[] clientData) {
final HMACMD5 hmacMD5 = new HMACMD5(hash);
hmacMD5.update(challenge);
hmacMD5.update(clientData);
@@ -720,6 +767,191 @@ final class NTLMEngineImpl implements NTLMEngine {
return lmv2Response;
}
+ static enum Mode
+ {
+ CLIENT, SERVER;
+ }
+
+ static class Handle
+ {
+ final private byte[] exportedSessionKey;
+ private byte[] signingKey;
+ private byte[] sealingKey;
+ private final Cipher rc4;
+ final Mode mode;
+ final private boolean isConnection;
+ int sequenceNumber = 0;
+
+
+ Handle( final byte[] exportedSessionKey, final Mode mode, final boolean isConnection )
+ throws NTLMEngineException
+ {
+ this.exportedSessionKey = exportedSessionKey;
+ this.isConnection = isConnection;
+ this.mode = mode;
+ try
+ {
+ final MessageDigest signMd5 = getMD5();
+ final MessageDigest sealMd5 = getMD5();
+ signMd5.update( exportedSessionKey );
+ sealMd5.update( exportedSessionKey );
+ if ( mode == Mode.CLIENT )
+ {
+ signMd5.update( SIGN_MAGIC_CLIENT );
+ sealMd5.update( SEAL_MAGIC_CLIENT );
+ }
+ else
+ {
+ signMd5.update( SIGN_MAGIC_SERVER );
+ sealMd5.update( SEAL_MAGIC_SERVER );
+ }
+ signingKey = signMd5.digest();
+ sealingKey = sealMd5.digest();
+ }
+ catch ( final Exception e )
+ {
+ throw new NTLMEngineException( e.getMessage(), e );
+ }
+ rc4 = initCipher();
+ }
+
+ public byte[] getSigningKey()
+ {
+ return signingKey;
+ }
+
+
+ public byte[] getSealingKey()
+ {
+ return sealingKey;
+ }
+
+ private Cipher initCipher() throws NTLMEngineException
+ {
+ final Cipher cipher;
+ try
+ {
+ cipher = Cipher.getInstance( "RC4" );
+ if ( mode == Mode.CLIENT )
+ {
+ cipher.init( Cipher.ENCRYPT_MODE, new SecretKeySpec( sealingKey, "RC4" ) );
+ }
+ else
+ {
+ cipher.init( Cipher.DECRYPT_MODE, new SecretKeySpec( sealingKey, "RC4" ) );
+ }
+ }
+ catch ( final Exception e )
+ {
+ throw new NTLMEngineException( e.getMessage(), e );
+ }
+ return cipher;
+ }
+
+
+ private void advanceMessageSequence() throws NTLMEngineException
+ {
+ if ( !isConnection )
+ {
+ final MessageDigest sealMd5 = getMD5();
+ sealMd5.update( sealingKey );
+ final byte[] seqNumBytes = new byte[4];
+ writeULong( seqNumBytes, sequenceNumber, 0 );
+ sealMd5.update( seqNumBytes );
+ sealingKey = sealMd5.digest();
+ initCipher();
+ }
+ sequenceNumber++;
+ }
+
+ private byte[] encrypt( final byte[] data )
+ {
+ return rc4.update( data );
+ }
+
+ private byte[] decrypt( final byte[] data )
+ {
+ return rc4.update( data );
+ }
+
+ private byte[] computeSignature( final byte[] message )
+ {
+ final byte[] sig = new byte[16];
+
+ // version
+ sig[0] = 0x01;
+ sig[1] = 0x00;
+ sig[2] = 0x00;
+ sig[3] = 0x00;
+
+ // HMAC (first 8 bytes)
+ final HMACMD5 hmacMD5 = new HMACMD5( signingKey );
+ hmacMD5.update( encodeLong( sequenceNumber ) );
+ hmacMD5.update( message );
+ final byte[] hmac = hmacMD5.getOutput();
+ final byte[] trimmedHmac = new byte[8];
+ System.arraycopy( hmac, 0, trimmedHmac, 0, 8 );
+ final byte[] encryptedHmac = encrypt( trimmedHmac );
+ System.arraycopy( encryptedHmac, 0, sig, 4, 8 );
+
+ // sequence number
+ encodeLong( sig, 12, sequenceNumber );
+
+ return sig;
+ }
+
+ private boolean validateSignature( final byte[] signature, final byte message[] )
+ {
+ final byte[] computedSignature = computeSignature( message );
+ // log.info( "SSSSS validateSignature("+seqNumber+")\n"
+ // + " received: " + DebugUtil.dump( signature ) + "\n"
+ // + " computed: " + DebugUtil.dump( computedSignature ) );
+ return Arrays.equals( signature, computedSignature );
+ }
+
+ public byte[] signAndEncryptMessage( final byte[] cleartextMessage ) throws NTLMEngineException
+ {
+ final byte[] encryptedMessage = encrypt( cleartextMessage );
+ final byte[] signature = computeSignature( cleartextMessage );
+ final byte[] outMessage = new byte[signature.length + encryptedMessage.length];
+ System.arraycopy( signature, 0, outMessage, 0, signature.length );
+ System.arraycopy( encryptedMessage, 0, outMessage, signature.length, encryptedMessage.length );
+ advanceMessageSequence();
+ return outMessage;
+ }
+
+ public byte[] decryptAndVerifySignedMessage( final byte[] inMessage ) throws NTLMEngineException
+ {
+ final byte[] signature = new byte[16];
+ System.arraycopy( inMessage, 0, signature, 0, signature.length );
+ final byte[] encryptedMessage = new byte[inMessage.length - 16];
+ System.arraycopy( inMessage, 16, encryptedMessage, 0, encryptedMessage.length );
+ final byte[] cleartextMessage = decrypt( encryptedMessage );
+ if ( !validateSignature( signature, cleartextMessage ) )
+ {
+ throw new NTLMEngineException( "Wrong signature" );
+ }
+ advanceMessageSequence();
+ return cleartextMessage;
+ }
+
+ }
+
+ private static byte[] encodeLong( final int value )
+ {
+ final byte[] enc = new byte[4];
+ encodeLong( enc, 0, value );
+ return enc;
+ }
+
+ private static void encodeLong( final byte[] buf, final int offset, final int value )
+ {
+ buf[offset + 0] = ( byte ) ( value & 0xff );
+ buf[offset + 1] = ( byte ) ( value >> 8 & 0xff );
+ buf[offset + 2] = ( byte ) ( value >> 16 & 0xff );
+ buf[offset + 3] = ( byte ) ( value >> 24 & 0xff );
+ }
+
/**
* Creates the NTLMv2 blob from the given target information block and
* client challenge.
@@ -803,21 +1035,64 @@ final class NTLMEngineImpl implements NTLMEngine {
}
}
+ /**
+ * Find the character set based on the flags.
+ * @param flags is the flags.
+ * @return the character set.
+ */
+ private static Charset getCharset(final int flags) throws NTLMEngineException
+ {
+ if ((flags & FLAG_REQUEST_UNICODE_ENCODING) == 0) {
+ return DEFAULT_CHARSET;
+ }
+ if (UNICODE_LITTLE_UNMARKED == null) {
+ throw new NTLMEngineException( "Unicode not supported" );
+ }
+ return UNICODE_LITTLE_UNMARKED;
+ }
+
+ /** Strip dot suffix from a name */
+ private static String stripDotSuffix(final String value) {
+ if (value == null) {
+ return null;
+ }
+ final int index = value.indexOf('.');
+ if (index != -1) {
+ return value.substring(0, index);
+ }
+ return value;
+ }
+
+ /** Convert host to standard form */
+ private static String convertHost(final String host) {
+ return stripDotSuffix(host);
+ }
+
+ /** Convert domain to standard form */
+ private static String convertDomain(final String domain) {
+ return stripDotSuffix(domain);
+ }
+
/** NTLM message generation, base class */
static class NTLMMessage {
/** The current response */
- private byte[] messageContents = null;
+ protected byte[] messageContents = null;
/** The current output position */
- private int currentOutputPosition = 0;
+ protected int currentOutputPosition = 0;
/** Constructor to use when message contents are not yet known */
NTLMMessage() {
}
- /** Constructor to use when message contents are known */
+ /** Constructor taking a string */
NTLMMessage(final String messageBody, final int expectedType) throws NTLMEngineException {
- messageContents = Base64.decodeBase64(messageBody.getBytes(DEFAULT_CHARSET));
+ this(Base64.decodeBase64(messageBody.getBytes(DEFAULT_CHARSET)), expectedType);
+ }
+
+ /** Constructor to use when message bytes are known */
+ NTLMMessage(final byte[] message, final int expectedType) throws NTLMEngineException {
+ messageContents = message;
// Look for NTLM message
if (messageContents.length < SIGNATURE.length) {
throw new NTLMEngineException("NTLM message decoding error - packet too short");
@@ -889,7 +1164,7 @@ final class NTLMEngineImpl implements NTLMEngine {
* Prepares the object to create a response of the given length.
*
* @param maxlength
- * the maximum length of the response to prepare, not
+ * the maximum length of the response to prepare,
* including the type and the signature (which this method
* adds).
*/
@@ -947,18 +1222,26 @@ final class NTLMEngineImpl implements NTLMEngine {
*
* @return The response as above.
*/
- String getResponse() {
+ public String getResponse() {
+ return new String(Base64.encodeBase64(getBytes()), Consts.ASCII);
+ }
+
+ public byte[] getBytes() {
+ if (messageContents == null) {
+ buildMessage();
+ }
final byte[] resp;
- if (messageContents.length > currentOutputPosition) {
+ if ( messageContents.length > currentOutputPosition ) {
final byte[] tmp = new byte[currentOutputPosition];
- System.arraycopy(messageContents, 0, tmp, 0, currentOutputPosition);
- resp = tmp;
- } else {
- resp = messageContents;
+ System.arraycopy( messageContents, 0, tmp, 0, currentOutputPosition );
+ messageContents = tmp;
}
- return EncodingUtils.getAsciiString(Base64.encodeBase64(resp));
+ return messageContents;
}
+ protected void buildMessage() {
+ throw new RuntimeException("Message builder not implemented for "+getClass().getName());
+ }
}
/** Type 1 message assembly class */
@@ -966,12 +1249,16 @@ final class NTLMEngineImpl implements NTLMEngine {
private final byte[] hostBytes;
private final byte[] domainBytes;
+ private final int flags;
Type1Message(final String domain, final String host) throws NTLMEngineException {
+ this(domain, host, null);
+ }
+
+ Type1Message(final String domain, final String host, final Integer flags) throws NTLMEngineException {
super();
- if (UNICODE_LITTLE_UNMARKED == null) {
- throw new NTLMEngineException("Unicode not supported");
- }
+ this.flags = ((flags == null)?getDefaultFlags():flags);
+
// Strip off domain name from the host!
final String unqualifiedHost = convertHost(host);
// Use only the base domain name!
@@ -987,56 +1274,72 @@ final class NTLMEngineImpl implements NTLMEngine {
super();
hostBytes = null;
domainBytes = null;
+ flags = getDefaultFlags();
}
+
+ private int getDefaultFlags() {
+ return
+ //FLAG_WORKSTATION_PRESENT |
+ //FLAG_DOMAIN_PRESENT |
+
+ // Required flags
+ //FLAG_REQUEST_LAN_MANAGER_KEY |
+ FLAG_REQUEST_NTLMv1 |
+ FLAG_REQUEST_NTLM2_SESSION |
+
+ // Protocol version request
+ FLAG_REQUEST_VERSION |
+
+ // Recommended privacy settings
+ FLAG_REQUEST_ALWAYS_SIGN |
+ //FLAG_REQUEST_SEAL |
+ //FLAG_REQUEST_SIGN |
+
+ // These must be set according to documentation, based on use of SEAL above
+ FLAG_REQUEST_128BIT_KEY_EXCH |
+ FLAG_REQUEST_56BIT_ENCRYPTION |
+ //FLAG_REQUEST_EXPLICIT_KEY_EXCH |
+
+ FLAG_REQUEST_UNICODE_ENCODING;
+
+ }
+
/**
* Getting the response involves building the message before returning
* it
*/
@Override
- String getResponse() {
+ protected void buildMessage() {
+ int domainBytesLength = 0;
+ if ( domainBytes != null ) {
+ domainBytesLength = domainBytes.length;
+ }
+ int hostBytesLength = 0;
+ if ( hostBytes != null ) {
+ hostBytesLength = hostBytes.length;
+ }
+
// Now, build the message. Calculate its length first, including
// signature or type.
- final int finalLength = 32 + 8 /*+ hostBytes.length + domainBytes.length */;
+ final int finalLength = 32 + 8 + hostBytesLength + domainBytesLength;
// Set up the response. This will initialize the signature, message
// type, and flags.
prepareResponse(finalLength, 1);
// Flags. These are the complete set of flags we support.
- addULong(
- //FLAG_WORKSTATION_PRESENT |
- //FLAG_DOMAIN_PRESENT |
-
- // Required flags
- //FLAG_REQUEST_LAN_MANAGER_KEY |
- FLAG_REQUEST_NTLMv1 |
- FLAG_REQUEST_NTLM2_SESSION |
-
- // Protocol version request
- FLAG_REQUEST_VERSION |
-
- // Recommended privacy settings
- FLAG_REQUEST_ALWAYS_SIGN |
- //FLAG_REQUEST_SEAL |
- //FLAG_REQUEST_SIGN |
-
- // These must be set according to documentation, based on use of SEAL above
- FLAG_REQUEST_128BIT_KEY_EXCH |
- FLAG_REQUEST_56BIT_ENCRYPTION |
- //FLAG_REQUEST_EXPLICIT_KEY_EXCH |
-
- FLAG_REQUEST_UNICODE_ENCODING);
+ addULong(flags);
// Domain length (two times).
- addUShort(/*domainBytes.length*/0);
- addUShort(/*domainBytes.length*/0);
+ addUShort(domainBytesLength);
+ addUShort(domainBytesLength);
// Domain offset.
- addULong(/*hostBytes.length +*/ 32 + 8);
+ addULong(hostBytesLength + 32 + 8);
// Host length (two times).
- addUShort(/*hostBytes.length*/0);
- addUShort(/*hostBytes.length*/0);
+ addUShort(hostBytesLength);
+ addUShort(hostBytesLength);
// Host offset (always 32 + 8).
addULong(32 + 8);
@@ -1056,20 +1359,22 @@ final class NTLMEngineImpl implements NTLMEngine {
if (domainBytes != null) {
addBytes(domainBytes);
}
-
- return super.getResponse();
}
}
/** Type 2 message class */
static class Type2Message extends NTLMMessage {
- protected byte[] challenge;
+ protected final byte[] challenge;
protected String target;
protected byte[] targetInfo;
- protected int flags;
+ protected final int flags;
- Type2Message(final String message) throws NTLMEngineException {
+ Type2Message(final String messageBody) throws NTLMEngineException {
+ this(Base64.decodeBase64(messageBody.getBytes(DEFAULT_CHARSET)));
+ }
+
+ Type2Message(final byte[] message) throws NTLMEngineException {
super(message, 2);
// Type 2 message is laid out as follows:
@@ -1092,12 +1397,6 @@ final class NTLMEngineImpl implements NTLMEngine {
flags = readULong(20);
- if ((flags & FLAG_REQUEST_UNICODE_ENCODING) == 0) {
- throw new NTLMEngineException(
- "NTLM type 2 message indicates no support for Unicode. Flags are: "
- + Integer.toString(flags));
- }
-
// Do the target!
target = null;
// The TARGET_DESIRED flag is said to not have understood semantics
@@ -1106,11 +1405,7 @@ final class NTLMEngineImpl implements NTLMEngine {
if (getMessageLength() >= 12 + 8) {
final byte[] bytes = readSecurityBuffer(12);
if (bytes.length != 0) {
- try {
- target = new String(bytes, "UnicodeLittleUnmarked");
- } catch (final UnsupportedEncodingException e) {
- throw new NTLMEngineException(e.getMessage(), e);
- }
+ target = new String(bytes, getCharset(flags));
}
}
@@ -1149,32 +1444,113 @@ final class NTLMEngineImpl implements NTLMEngine {
/** Type 3 message assembly class */
static class Type3Message extends NTLMMessage {
+ // For mic computation
+ protected final byte[] type1Message;
+ protected final byte[] type2Message;
// Response flags from the type2 message
- protected int type2Flags;
+ protected final int type2Flags;
- protected byte[] domainBytes;
- protected byte[] hostBytes;
- protected byte[] userBytes;
+ protected final byte[] domainBytes;
+ protected final byte[] hostBytes;
+ protected final byte[] userBytes;
protected byte[] lmResp;
protected byte[] ntResp;
- protected byte[] sessionKey;
+ protected final byte[] sessionKey;
+ protected final byte[] exportedSessionKey;
+
+ protected final boolean computeMic;
+
+ /** More primitive constructor: don't include cert or previous messages.
+ */
+ Type3Message(final String domain,
+ final String host,
+ final String user,
+ final String password,
+ final byte[] nonce,
+ final int type2Flags,
+ final String target,
+ final byte[] targetInformation)
+ throws NTLMEngineException {
+ this(domain, host, user, password, nonce, type2Flags, target, targetInformation, null, null, null);
+ }
+
+ /** More primitive constructor: don't include cert or previous messages.
+ */
+ Type3Message(final Random random, final long currentTime,
+ final String domain,
+ final String host,
+ final String user,
+ final String password,
+ final byte[] nonce,
+ final int type2Flags,
+ final String target,
+ final byte[] targetInformation)
+ throws NTLMEngineException {
+ this(random, currentTime, domain, host, user, password, nonce, type2Flags, target, targetInformation, null, null, null);
+ }
+ /** Constructor. Pass the arguments we will need */
+ Type3Message(final String domain,
+ final String host,
+ final String user,
+ final String password,
+ final byte[] nonce,
+ final int type2Flags,
+ final String target,
+ final byte[] targetInformation,
+ final Certificate peerServerCertificate,
+ final byte[] type1Message,
+ final byte[] type2Message)
+ throws NTLMEngineException {
+ this(RND_GEN, System.currentTimeMillis(), domain, host, user, password, nonce, type2Flags, target, targetInformation, peerServerCertificate, type1Message, type2Message);
+ }
/** Constructor. Pass the arguments we will need */
- Type3Message(final String domain, final String host, final String user, final String password, final byte[] nonce,
- final int type2Flags, final String target, final byte[] targetInformation)
- throws NTLMEngineException {
+ Type3Message(final Random random, final long currentTime,
+ final String domain,
+ final String host,
+ final String user,
+ final String password,
+ final byte[] nonce,
+ final int type2Flags,
+ final String target,
+ final byte[] targetInformation,
+ final Certificate peerServerCertificate,
+ final byte[] type1Message,
+ final byte[] type2Message)
+ throws NTLMEngineException {
+
+ if (random == null) {
+ throw new NTLMEngineException("Random generator not available");
+ }
+
// Save the flags
this.type2Flags = type2Flags;
+ this.type1Message = type1Message;
+ this.type2Message = type2Message;
// Strip off domain name from the host!
final String unqualifiedHost = convertHost(host);
// Use only the base domain name!
final String unqualifiedDomain = convertDomain(domain);
- // Create a cipher generator class. Use domain BEFORE it gets modified!
- final CipherGen gen = new CipherGen(unqualifiedDomain, user, password, nonce, target, targetInformation);
+ byte[] responseTargetInformation = targetInformation;
+ if (peerServerCertificate != null) {
+ responseTargetInformation = addGssMicAvsToTargetInfo(targetInformation, peerServerCertificate);
+ computeMic = true;
+ } else {
+ computeMic = false;
+ }
+
+ // Create a cipher generator class. Use domain BEFORE it gets modified!
+ final CipherGen gen = new CipherGen(random, currentTime,
+ unqualifiedDomain,
+ user,
+ password,
+ nonce,
+ target,
+ responseTargetInformation);
// Use the new code to calculate the responses, including v2 if that
// seems warranted.
@@ -1227,25 +1603,37 @@ final class NTLMEngineImpl implements NTLMEngine {
if ((type2Flags & FLAG_REQUEST_SIGN) != 0) {
if ((type2Flags & FLAG_REQUEST_EXPLICIT_KEY_EXCH) != 0) {
- sessionKey = RC4(gen.getSecondaryKey(), userSessionKey);
+ exportedSessionKey = gen.getSecondaryKey();
+ sessionKey = RC4(exportedSessionKey, userSessionKey);
} else {
sessionKey = userSessionKey;
+ exportedSessionKey = sessionKey;
}
} else {
+ if (computeMic) {
+ throw new NTLMEngineException("Cannot sign/seal: no exported session key");
+ }
sessionKey = null;
+ exportedSessionKey = null;
}
- if (UNICODE_LITTLE_UNMARKED == null) {
- throw new NTLMEngineException("Unicode not supported");
- }
- hostBytes = unqualifiedHost != null ? unqualifiedHost.getBytes(UNICODE_LITTLE_UNMARKED) : null;
- domainBytes = unqualifiedDomain != null ? unqualifiedDomain
- .toUpperCase(Locale.ROOT).getBytes(UNICODE_LITTLE_UNMARKED) : null;
- userBytes = user.getBytes(UNICODE_LITTLE_UNMARKED);
+ final Charset charset = getCharset(type2Flags);
+ hostBytes = unqualifiedHost != null ? unqualifiedHost.getBytes(charset) : null;
+ domainBytes = unqualifiedDomain != null ? unqualifiedDomain
+ .toUpperCase(Locale.ROOT).getBytes(charset) : null;
+ userBytes = user.getBytes(charset);
+ }
+
+ public byte[] getEncryptedRandomSessionKey() {
+ return sessionKey;
+ }
+
+ public byte[] getExportedSessionKey() {
+ return exportedSessionKey;
}
/** Assemble the response */
@Override
- String getResponse() {
+ protected void buildMessage() {
final int ntRespLen = ntResp.length;
final int lmRespLen = lmResp.length;
@@ -1260,7 +1648,8 @@ final class NTLMEngineImpl implements NTLMEngine {
}
// Calculate the layout within the packet
- final int lmRespOffset = 72; // allocate space for the version
+ final int lmRespOffset = 72 + // allocate space for the version
+ ( computeMic ? 16 : 0 ); // and MIC
final int ntRespOffset = lmRespOffset + lmRespLen;
final int domainOffset = ntRespOffset + ntRespLen;
final int userOffset = domainOffset + domainLen;
@@ -1315,6 +1704,7 @@ final class NTLMEngineImpl implements NTLMEngine {
// Flags.
addULong(
+ /*
//FLAG_WORKSTATION_PRESENT |
//FLAG_DOMAIN_PRESENT |
@@ -1339,6 +1729,8 @@ final class NTLMEngineImpl implements NTLMEngine {
(type2Flags & FLAG_TARGETINFO_PRESENT) |
(type2Flags & FLAG_REQUEST_UNICODE_ENCODING) |
(type2Flags & FLAG_REQUEST_TARGET)
+ */
+ type2Flags
);
// Version
@@ -1348,6 +1740,12 @@ final class NTLMEngineImpl implements NTLMEngine {
// NTLM revision
addUShort(0x0f00);
+ int micPosition = -1;
+ if ( computeMic ) {
+ micPosition = currentOutputPosition;
+ currentOutputPosition += 16;
+ }
+
// Add the actual data
addBytes(lmResp);
addBytes(ntResp);
@@ -1358,8 +1756,69 @@ final class NTLMEngineImpl implements NTLMEngine {
addBytes(sessionKey);
}
- return super.getResponse();
+ // Write the mic back into its slot in the message
+
+ if (computeMic) {
+ // Computation of message integrity code (MIC) as specified in [MS-NLMP] section 3.2.5.1.2.
+ final HMACMD5 hmacMD5 = new HMACMD5( exportedSessionKey );
+ hmacMD5.update( type1Message );
+ hmacMD5.update( type2Message );
+ hmacMD5.update( messageContents );
+ final byte[] mic = hmacMD5.getOutput();
+ System.arraycopy( mic, 0, messageContents, micPosition, mic.length );
+ }
}
+
+ /**
+ * Add GSS channel binding hash and MIC flag to the targetInfo.
+ * Looks like this is needed if we want to use exported session key for GSS wrapping.
+ */
+ private byte[] addGssMicAvsToTargetInfo( final byte[] originalTargetInfo,
+ final Certificate peerServerCertificate ) throws NTLMEngineException
+ {
+ final byte[] newTargetInfo = new byte[originalTargetInfo.length + 8 + 20];
+ final int appendLength = originalTargetInfo.length - 4; // last tag is MSV_AV_EOL, do not copy that
+ System.arraycopy( originalTargetInfo, 0, newTargetInfo, 0, appendLength );
+ writeUShort( newTargetInfo, MSV_AV_FLAGS, appendLength );
+ writeUShort( newTargetInfo, 4, appendLength + 2 );
+ writeULong( newTargetInfo, MSV_AV_FLAGS_MIC, appendLength + 4 );
+ writeUShort( newTargetInfo, MSV_AV_CHANNEL_BINDINGS, appendLength + 8 );
+ writeUShort( newTargetInfo, 16, appendLength + 10 );
+
+ final byte[] channelBindingsHash;
+ try
+ {
+ final byte[] certBytes = peerServerCertificate.getEncoded();
+ final MessageDigest sha256 = MessageDigest.getInstance( "SHA-256" );
+ final byte[] certHashBytes = sha256.digest( certBytes );
+ final byte[] channelBindingStruct = new byte[16 + 4 + MAGIC_TLS_SERVER_ENDPOINT.length
+ + certHashBytes.length];
+ writeULong( channelBindingStruct, 0x00000035, 16 );
+ System.arraycopy( MAGIC_TLS_SERVER_ENDPOINT, 0, channelBindingStruct, 20,
+ MAGIC_TLS_SERVER_ENDPOINT.length );
+ System.arraycopy( certHashBytes, 0, channelBindingStruct, 20 + MAGIC_TLS_SERVER_ENDPOINT.length,
+ certHashBytes.length );
+ final MessageDigest md5 = getMD5();
+ channelBindingsHash = md5.digest( channelBindingStruct );
+ }
+ catch ( final CertificateEncodingException e )
+ {
+ throw new NTLMEngineException( e.getMessage(), e );
+ }
+ catch ( final NoSuchAlgorithmException e )
+ {
+ throw new NTLMEngineException( e.getMessage(), e );
+ }
+
+ System.arraycopy( channelBindingsHash, 0, newTargetInfo, appendLength + 12, 16 );
+ return newTargetInfo;
+ }
+
+ }
+
+ static void writeUShort(final byte[] buffer, final int value, final int offset) {
+ buffer[offset] = ( byte ) ( value & 0xff );
+ buffer[offset + 1] = ( byte ) ( value >> 8 & 0xff );
}
static void writeULong(final byte[] buffer, final int value, final int offset) {
@@ -1385,6 +1844,14 @@ final class NTLMEngineImpl implements NTLMEngine {
return ((val << numbits) | (val >>> (32 - numbits)));
}
+ static MessageDigest getMD5() {
+ try {
+ return MessageDigest.getInstance("MD5");
+ } catch (final NoSuchAlgorithmException ex) {
+ throw new RuntimeException("MD5 message digest doesn't seem to exist - fatal error: "+ex.getMessage(), ex);
+ }
+ }
+
/**
* Cryptography support - MD4. The following class was based loosely on the
* RFC and on code found at http://www.cs.umd.edu/~harry/jotp/src/md.java.
@@ -1398,7 +1865,7 @@ final class NTLMEngineImpl implements NTLMEngine {
protected int C = 0x98badcfe;
protected int D = 0x10325476;
protected long count = 0L;
- protected byte[] dataBuffer = new byte[64];
+ protected final byte[] dataBuffer = new byte[64];
MD4() {
}
@@ -1557,20 +2024,13 @@ final class NTLMEngineImpl implements NTLMEngine {
* resources by Karl Wright
*/
static class HMACMD5 {
- protected byte[] ipad;
- protected byte[] opad;
- protected MessageDigest md5;
+ protected final byte[] ipad;
+ protected final byte[] opad;
+ protected final MessageDigest md5;
- HMACMD5(final byte[] input) throws NTLMEngineException {
+ HMACMD5(final byte[] input) {
byte[] key = input;
- try {
- md5 = MessageDigest.getInstance("MD5");
- } catch (final Exception ex) {
- // Umm, the algorithm doesn't exist - throw an
- // NTLMEngineException!
- throw new NTLMEngineException(
- "Error getting md5 message digest implementation: " + ex.getMessage(), ex);
- }
+ md5 = getMD5();
// Initialize the pad buffers with the key
ipad = new byte[64];
@@ -1595,7 +2055,7 @@ final class NTLMEngineImpl implements NTLMEngine {
i++;
}
- // Very important: update the digest with the ipad buffer
+ // Very important: processChallenge the digest with the ipad buffer
md5.reset();
md5.update(ipad);
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/AbstractResponseHandler.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/AbstractResponseHandler.java
index 3c99377c8..79d3bc147 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/AbstractResponseHandler.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/AbstractResponseHandler.java
@@ -34,8 +34,6 @@ import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.StatusLine;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.client.HttpClient;
-import com.fr.third.org.apache.http.client.methods.HttpUriRequest;
import com.fr.third.org.apache.http.client.HttpResponseException;
import com.fr.third.org.apache.http.client.ResponseHandler;
import com.fr.third.org.apache.http.util.EntityUtils;
@@ -46,8 +44,8 @@ import com.fr.third.org.apache.http.util.EntityUtils;
* body is consumed and an {@link HttpResponseException} is thrown.
*
* If this is used with
- * {@link HttpClient#execute(
- * HttpUriRequest, ResponseHandler)},
+ * {@link com.fr.third.org.apache.http.client.HttpClient#execute(
+ * com.fr.third.org.apache.http.client.methods.HttpUriRequest, ResponseHandler)},
* HttpClient may handle redirects (3xx responses) internally.
*
*
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/AuthenticationStrategyImpl.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/AuthenticationStrategyImpl.java
index 69fc3701e..e540844d1 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/AuthenticationStrategyImpl.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/AuthenticationStrategyImpl.java
@@ -73,9 +73,9 @@ abstract class AuthenticationStrategyImpl implements AuthenticationStrategy {
AuthSchemes.SPNEGO,
AuthSchemes.KERBEROS,
AuthSchemes.NTLM,
+ AuthSchemes.CREDSSP,
AuthSchemes.DIGEST,
AuthSchemes.BASIC));
-
private final int challengeCode;
private final String headerName;
@@ -190,8 +190,7 @@ abstract class AuthenticationStrategyImpl implements AuthenticationStrategy {
authScheme.processChallenge(challenge);
final AuthScope authScope = new AuthScope(
- authhost.getHostName(),
- authhost.getPort(),
+ authhost,
authScheme.getRealm(),
authScheme.getSchemeName());
@@ -237,8 +236,7 @@ abstract class AuthenticationStrategyImpl implements AuthenticationStrategy {
return false;
}
final String schemeName = authScheme.getSchemeName();
- return schemeName.equalsIgnoreCase(AuthSchemes.BASIC) ||
- schemeName.equalsIgnoreCase(AuthSchemes.DIGEST);
+ return schemeName.equalsIgnoreCase(AuthSchemes.BASIC);
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/BasicAuthCache.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/BasicAuthCache.java
index 9fbf05ff2..47671fd8b 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/BasicAuthCache.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/BasicAuthCache.java
@@ -48,8 +48,8 @@ import com.fr.third.org.apache.http.impl.conn.DefaultSchemePortResolver;
import com.fr.third.org.apache.http.util.Args;
/**
- * Default implementation of {@link AuthCache}. This implements
- * expects {@link AuthScheme} to be {@link java.io.Serializable}
+ * Default implementation of {@link com.fr.third.org.apache.http.client.AuthCache}. This implements
+ * expects {@link com.fr.third.org.apache.http.auth.AuthScheme} to be {@link Serializable}
* in order to be cacheable.
*
* Instances of this class are thread safe as of version 4.4.
@@ -90,9 +90,8 @@ public class BasicAuthCache implements AuthCache {
return host;
}
return new HttpHost(host.getHostName(), port, host.getSchemeName());
- } else {
- return host;
}
+ return host;
}
@Override
@@ -142,9 +141,8 @@ public class BasicAuthCache implements AuthCache {
}
return null;
}
- } else {
- return null;
}
+ return null;
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/BasicCookieStore.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/BasicCookieStore.java
index 8afe2e6ea..8f8081432 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/BasicCookieStore.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/BasicCookieStore.java
@@ -26,12 +26,16 @@
*/
package com.fr.third.org.apache.http.impl.client;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.TreeSet;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
@@ -51,10 +55,19 @@ public class BasicCookieStore implements CookieStore, Serializable {
private static final long serialVersionUID = -7581093305228232025L;
private final TreeSet cookies;
+ private transient ReadWriteLock lock;
public BasicCookieStore() {
super();
this.cookies = new TreeSet(new CookieIdentityComparator());
+ this.lock = new ReentrantReadWriteLock();
+ }
+
+ private void readObject(final ObjectInputStream stream) throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+
+ /* Reinstantiate transient fields. */
+ this.lock = new ReentrantReadWriteLock();
}
/**
@@ -68,12 +81,17 @@ public class BasicCookieStore implements CookieStore, Serializable {
*
*/
@Override
- public synchronized void addCookie(final Cookie cookie) {
+ public void addCookie(final Cookie cookie) {
if (cookie != null) {
- // first remove any old cookie that is equivalent
- cookies.remove(cookie);
- if (!cookie.isExpired(new Date())) {
- cookies.add(cookie);
+ lock.writeLock().lock();
+ try {
+ // first remove any old cookie that is equivalent
+ cookies.remove(cookie);
+ if (!cookie.isExpired(new Date())) {
+ cookies.add(cookie);
+ }
+ } finally {
+ lock.writeLock().unlock();
}
}
}
@@ -88,10 +106,10 @@ public class BasicCookieStore implements CookieStore, Serializable {
* @see #addCookie(Cookie)
*
*/
- public synchronized void addCookies(final Cookie[] cookies) {
+ public void addCookies(final Cookie[] cookies) {
if (cookies != null) {
- for (final Cookie cooky : cookies) {
- this.addCookie(cooky);
+ for (final Cookie cookie : cookies) {
+ this.addCookie(cookie);
}
}
}
@@ -103,45 +121,65 @@ public class BasicCookieStore implements CookieStore, Serializable {
* @return an array of {@link Cookie cookies}.
*/
@Override
- public synchronized List getCookies() {
- //create defensive copy so it won't be concurrently modified
- return new ArrayList(cookies);
+ public List getCookies() {
+ lock.readLock().lock();
+ try {
+ //create defensive copy so it won't be concurrently modified
+ return new ArrayList(cookies);
+ } finally {
+ lock.readLock().unlock();
+ }
}
/**
* Removes all of {@link Cookie cookies} in this HTTP state
- * that have expired by the specified {@link java.util.Date date}.
+ * that have expired by the specified {@link Date date}.
*
* @return true if any cookies were purged.
*
* @see Cookie#isExpired(Date)
*/
@Override
- public synchronized boolean clearExpired(final Date date) {
+ public boolean clearExpired(final Date date) {
if (date == null) {
return false;
}
- boolean removed = false;
- for (final Iterator it = cookies.iterator(); it.hasNext();) {
- if (it.next().isExpired(date)) {
- it.remove();
- removed = true;
+ lock.writeLock().lock();
+ try {
+ boolean removed = false;
+ for (final Iterator it = cookies.iterator(); it.hasNext(); ) {
+ if (it.next().isExpired(date)) {
+ it.remove();
+ removed = true;
+ }
}
+ return removed;
+ } finally {
+ lock.writeLock().unlock();
}
- return removed;
}
/**
* Clears all cookies.
*/
@Override
- public synchronized void clear() {
- cookies.clear();
+ public void clear() {
+ lock.writeLock().lock();
+ try {
+ cookies.clear();
+ } finally {
+ lock.writeLock().unlock();
+ }
}
@Override
- public synchronized String toString() {
- return cookies.toString();
+ public String toString() {
+ lock.readLock().lock();
+ try {
+ return cookies.toString();
+ } finally {
+ lock.readLock().unlock();
+ }
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/BasicResponseHandler.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/BasicResponseHandler.java
index 069f8144a..fb5445e74 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/BasicResponseHandler.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/BasicResponseHandler.java
@@ -33,20 +33,17 @@ import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.client.HttpClient;
-import com.fr.third.org.apache.http.client.ResponseHandler;
-import com.fr.third.org.apache.http.client.methods.HttpUriRequest;
import com.fr.third.org.apache.http.client.HttpResponseException;
import com.fr.third.org.apache.http.util.EntityUtils;
/**
- * A {@link ResponseHandler} that returns the response body as a String
+ * A {@link com.fr.third.org.apache.http.client.ResponseHandler} that returns the response body as a String
* for successful (2xx) responses. If the response code was >= 300, the response
- * body is consumed and an {@link HttpResponseException} is thrown.
+ * body is consumed and an {@link com.fr.third.org.apache.http.client.HttpResponseException} is thrown.
*
* If this is used with
- * {@link HttpClient#execute(
- * HttpUriRequest, ResponseHandler)},
+ * {@link com.fr.third.org.apache.http.client.HttpClient#execute(
+ * com.fr.third.org.apache.http.client.methods.HttpUriRequest, com.fr.third.org.apache.http.client.ResponseHandler)},
* HttpClient may handle redirects (3xx responses) internally.
*
*
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/DefaultBackoffStrategy.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/DefaultBackoffStrategy.java
index fcb5d4425..617fa8844 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/DefaultBackoffStrategy.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/DefaultBackoffStrategy.java
@@ -44,13 +44,13 @@ public class DefaultBackoffStrategy implements ConnectionBackoffStrategy {
@Override
public boolean shouldBackoff(final Throwable t) {
- return (t instanceof SocketTimeoutException
- || t instanceof ConnectException);
+ return t instanceof SocketTimeoutException || t instanceof ConnectException;
}
@Override
public boolean shouldBackoff(final HttpResponse resp) {
- return (resp.getStatusLine().getStatusCode() == HttpStatus.SC_SERVICE_UNAVAILABLE);
+ return resp.getStatusLine().getStatusCode() == 429 ||
+ resp.getStatusLine().getStatusCode() == HttpStatus.SC_SERVICE_UNAVAILABLE;
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
index 65dd001c1..454a48d07 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
@@ -138,11 +138,10 @@ public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler {
}
if (this.nonRetriableClasses.contains(exception.getClass())) {
return false;
- } else {
- for (final Class extends IOException> rejectException : this.nonRetriableClasses) {
- if (rejectException.isInstance(exception)) {
- return false;
- }
+ }
+ for (final Class extends IOException> rejectException : this.nonRetriableClasses) {
+ if (rejectException.isInstance(exception)) {
+ return false;
}
}
final HttpClientContext clientContext = HttpClientContext.adapt(context);
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/DefaultRedirectStrategy.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/DefaultRedirectStrategy.java
index 2ff1d51c3..a6c821b6b 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/DefaultRedirectStrategy.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/DefaultRedirectStrategy.java
@@ -29,7 +29,7 @@ package com.fr.third.org.apache.http.impl.client;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.Locale;
+import java.util.Arrays;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -49,12 +49,10 @@ import com.fr.third.org.apache.http.client.methods.HttpHead;
import com.fr.third.org.apache.http.client.methods.HttpUriRequest;
import com.fr.third.org.apache.http.client.methods.RequestBuilder;
import com.fr.third.org.apache.http.client.protocol.HttpClientContext;
-import com.fr.third.org.apache.http.client.utils.URIBuilder;
import com.fr.third.org.apache.http.client.utils.URIUtils;
import com.fr.third.org.apache.http.protocol.HttpContext;
import com.fr.third.org.apache.http.util.Args;
import com.fr.third.org.apache.http.util.Asserts;
-import com.fr.third.org.apache.http.util.TextUtils;
/**
* Default implementation of {@link RedirectStrategy}. This strategy honors the restrictions
@@ -76,24 +74,36 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
private final Log log = LogFactory.getLog(getClass());
+ public static final int SC_PERMANENT_REDIRECT = 308;
+
/**
- * @deprecated (4.3) use {@link HttpClientContext#REDIRECT_LOCATIONS}.
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.client.protocol.HttpClientContext#REDIRECT_LOCATIONS}.
*/
@Deprecated
public static final String REDIRECT_LOCATIONS = "http.protocol.redirect-locations";
public static final DefaultRedirectStrategy INSTANCE = new DefaultRedirectStrategy();
- /**
- * Redirectable methods.
- */
- private static final String[] REDIRECT_METHODS = new String[] {
- HttpGet.METHOD_NAME,
- HttpHead.METHOD_NAME
- };
+ private final String[] redirectMethods;
public DefaultRedirectStrategy() {
+ this(new String[] {
+ HttpGet.METHOD_NAME,
+ HttpHead.METHOD_NAME
+ });
+ }
+
+ /**
+ * Constructs a new instance to redirect the given HTTP methods.
+ *
+ * @param redirectMethods The methods to redirect.
+ * @since 4.5.10
+ */
+ public DefaultRedirectStrategy(final String[] redirectMethods) {
super();
+ final String[] tmp = redirectMethods.clone();
+ Arrays.sort(tmp);
+ this.redirectMethods = tmp;
}
@Override
@@ -112,6 +122,7 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
return isRedirectable(method) && locationHeader != null;
case HttpStatus.SC_MOVED_PERMANENTLY:
case HttpStatus.SC_TEMPORARY_REDIRECT:
+ case SC_PERMANENT_REDIRECT:
return isRedirectable(method);
case HttpStatus.SC_SEE_OTHER:
return true;
@@ -147,9 +158,13 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
URI uri = createLocationURI(location);
- // rfc2616 demands the location value be a complete URI
- // Location = "Location" ":" absoluteURI
try {
+ if (config.isNormalizeUri()) {
+ uri = URIUtils.normalizeSyntax(uri);
+ }
+
+ // rfc2616 demands the location value be a complete URI
+ // Location = "Location" ":" absoluteURI
if (!uri.isAbsolute()) {
if (!config.isRelativeRedirectsAllowed()) {
throw new ProtocolException("Relative redirect location '"
@@ -159,7 +174,8 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
final HttpHost target = clientContext.getTargetHost();
Asserts.notNull(target, "Target host");
final URI requestURI = new URI(request.getRequestLine().getUri());
- final URI absoluteRequestURI = URIUtils.rewriteURI(requestURI, target, false);
+ final URI absoluteRequestURI = URIUtils.rewriteURI(requestURI, target,
+ config.isNormalizeUri() ? URIUtils.NORMALIZE : URIUtils.NO_FLAGS);
uri = URIUtils.resolve(absoluteRequestURI, uri);
}
} catch (final URISyntaxException ex) {
@@ -186,16 +202,7 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
*/
protected URI createLocationURI(final String location) throws ProtocolException {
try {
- final URIBuilder b = new URIBuilder(new URI(location).normalize());
- final String host = b.getHost();
- if (host != null) {
- b.setHost(host.toLowerCase(Locale.ROOT));
- }
- final String path = b.getPath();
- if (TextUtils.isEmpty(path)) {
- b.setPath("/");
- }
- return b.build();
+ return new URI(location);
} catch (final URISyntaxException ex) {
throw new ProtocolException("Invalid redirect URI: " + location, ex);
}
@@ -205,12 +212,7 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
* @since 4.2
*/
protected boolean isRedirectable(final String method) {
- for (final String m: REDIRECT_METHODS) {
- if (m.equalsIgnoreCase(method)) {
- return true;
- }
- }
- return false;
+ return Arrays.binarySearch(redirectMethods, method) >= 0;
}
@Override
@@ -226,11 +228,9 @@ public class DefaultRedirectStrategy implements RedirectStrategy {
return new HttpGet(uri);
} else {
final int status = response.getStatusLine().getStatusCode();
- if (status == HttpStatus.SC_TEMPORARY_REDIRECT) {
- return RequestBuilder.copy(request).setUri(uri).build();
- } else {
- return new HttpGet(uri);
- }
+ return (status == HttpStatus.SC_TEMPORARY_REDIRECT || status == SC_PERMANENT_REDIRECT)
+ ? RequestBuilder.copy(request).setUri(uri).build()
+ : new HttpGet(uri);
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
index 4cbc7f2c0..d88a18a12 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
@@ -105,9 +105,9 @@ public class EntityEnclosingRequestWrapper extends RequestWrapper
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
+ public void writeTo(final OutputStream outStream) throws IOException {
consumed = true;
- super.writeTo(outstream);
+ super.writeTo(outStream);
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpClientBuilder.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpClientBuilder.java
index 23956c296..19704ca8a 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpClientBuilder.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpClientBuilder.java
@@ -47,7 +47,6 @@ import com.fr.third.org.apache.http.Header;
import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.HttpRequestInterceptor;
import com.fr.third.org.apache.http.HttpResponseInterceptor;
-import com.fr.third.org.apache.http.auth.AuthScheme;
import com.fr.third.org.apache.http.auth.AuthSchemeProvider;
import com.fr.third.org.apache.http.client.AuthenticationStrategy;
import com.fr.third.org.apache.http.client.BackoffManager;
@@ -86,7 +85,6 @@ import com.fr.third.org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import com.fr.third.org.apache.http.conn.ssl.X509HostnameVerifier;
import com.fr.third.org.apache.http.conn.util.PublicSuffixMatcher;
import com.fr.third.org.apache.http.conn.util.PublicSuffixMatcherLoader;
-import com.fr.third.org.apache.http.cookie.CookieSpec;
import com.fr.third.org.apache.http.cookie.CookieSpecProvider;
import com.fr.third.org.apache.http.impl.NoConnectionReuseStrategy;
import com.fr.third.org.apache.http.impl.auth.BasicSchemeFactory;
@@ -141,6 +139,8 @@ import com.fr.third.org.apache.http.util.VersionInfo;
*
https.cipherSuites
*
http.proxyHost
*
http.proxyPort
+ *
https.proxyHost
+ *
https.proxyPort
*
http.nonProxyHosts
*
http.keepAlive
*
http.maxConnections
@@ -205,6 +205,7 @@ public class HttpClientBuilder {
private boolean cookieManagementDisabled;
private boolean authCachingDisabled;
private boolean connectionStateDisabled;
+ private boolean defaultUserAgentDisabled;
private int maxConnTotal = 0;
private int maxConnPerRoute = 0;
@@ -236,8 +237,8 @@ public class HttpClientBuilder {
* Assigns {@link X509HostnameVerifier} instance.
*
* Please note this value can be overridden by the {@link #setConnectionManager(
- *HttpClientConnectionManager)} and the {@link #setSSLSocketFactory(
- *LayeredConnectionSocketFactory)} methods.
+ * com.fr.third.org.apache.http.conn.HttpClientConnectionManager)} and the {@link #setSSLSocketFactory(
+ * com.fr.third.org.apache.http.conn.socket.LayeredConnectionSocketFactory)} methods.
*
* Please note this value can be overridden by the {@link #setConnectionManager(
- *HttpClientConnectionManager)} and the {@link #setSSLSocketFactory(
- *LayeredConnectionSocketFactory)} methods.
+ * com.fr.third.org.apache.http.conn.HttpClientConnectionManager)} and the {@link #setSSLSocketFactory(
+ * com.fr.third.org.apache.http.conn.socket.LayeredConnectionSocketFactory)} methods.
*
*
* @since 4.4
@@ -265,10 +266,10 @@ public class HttpClientBuilder {
/**
* Assigns file containing public suffix matcher. Instances of this class can be created
- * with {@link PublicSuffixMatcherLoader}.
+ * with {@link com.fr.third.org.apache.http.conn.util.PublicSuffixMatcherLoader}.
*
- * @see PublicSuffixMatcher
- * @see PublicSuffixMatcherLoader
+ * @see com.fr.third.org.apache.http.conn.util.PublicSuffixMatcher
+ * @see com.fr.third.org.apache.http.conn.util.PublicSuffixMatcherLoader
*
* @since 4.4
*/
@@ -281,8 +282,8 @@ public class HttpClientBuilder {
* Assigns {@link SSLContext} instance.
*
* Please note this value can be overridden by the {@link #setConnectionManager(
- *HttpClientConnectionManager)} and the {@link #setSSLSocketFactory(
- *LayeredConnectionSocketFactory)} methods.
+ * com.fr.third.org.apache.http.conn.HttpClientConnectionManager)} and the {@link #setSSLSocketFactory(
+ * com.fr.third.org.apache.http.conn.socket.LayeredConnectionSocketFactory)} methods.
*
*
* @deprecated (4.5) use {@link #setSSLContext(SSLContext)}
@@ -296,8 +297,8 @@ public class HttpClientBuilder {
* Assigns {@link SSLContext} instance.
*
* Please note this value can be overridden by the {@link #setConnectionManager(
- *HttpClientConnectionManager)} and the {@link #setSSLSocketFactory(
- *LayeredConnectionSocketFactory)} methods.
+ * com.fr.third.org.apache.http.conn.HttpClientConnectionManager)} and the {@link #setSSLSocketFactory(
+ * com.fr.third.org.apache.http.conn.socket.LayeredConnectionSocketFactory)} methods.
*
*/
public final HttpClientBuilder setSSLContext(final SSLContext sslContext) {
@@ -309,7 +310,7 @@ public class HttpClientBuilder {
* Assigns {@link LayeredConnectionSocketFactory} instance.
*
* Please note this value can be overridden by the {@link #setConnectionManager(
- *HttpClientConnectionManager)} method.
+ * com.fr.third.org.apache.http.conn.HttpClientConnectionManager)} method.
*
*/
public final HttpClientBuilder setSSLSocketFactory(
@@ -322,7 +323,7 @@ public class HttpClientBuilder {
* Assigns maximum total connection value.
*
* Please note this value can be overridden by the {@link #setConnectionManager(
- *HttpClientConnectionManager)} method.
+ * com.fr.third.org.apache.http.conn.HttpClientConnectionManager)} method.
*
*/
public final HttpClientBuilder setMaxConnTotal(final int maxConnTotal) {
@@ -334,7 +335,7 @@ public class HttpClientBuilder {
* Assigns maximum connection per route value.
*
* Please note this value can be overridden by the {@link #setConnectionManager(
- *HttpClientConnectionManager)} method.
+ * com.fr.third.org.apache.http.conn.HttpClientConnectionManager)} method.
*
*/
public final HttpClientBuilder setMaxConnPerRoute(final int maxConnPerRoute) {
@@ -346,7 +347,7 @@ public class HttpClientBuilder {
* Assigns default {@link SocketConfig}.
*
* Please note this value can be overridden by the {@link #setConnectionManager(
- *HttpClientConnectionManager)} method.
+ * com.fr.third.org.apache.http.conn.HttpClientConnectionManager)} method.
*
*/
public final HttpClientBuilder setDefaultSocketConfig(final SocketConfig config) {
@@ -358,7 +359,7 @@ public class HttpClientBuilder {
* Assigns default {@link ConnectionConfig}.
*
* Please note this value can be overridden by the {@link #setConnectionManager(
- *HttpClientConnectionManager)} method.
+ * com.fr.third.org.apache.http.conn.HttpClientConnectionManager)} method.
*
*/
public final HttpClientBuilder setDefaultConnectionConfig(final ConnectionConfig config) {
@@ -370,7 +371,7 @@ public class HttpClientBuilder {
* Sets maximum time to live for persistent connections
*
* Please note this value can be overridden by the {@link #setConnectionManager(
- *HttpClientConnectionManager)} method.
+ * com.fr.third.org.apache.http.conn.HttpClientConnectionManager)} method.
*
*
* @since 4.4
@@ -481,7 +482,7 @@ public class HttpClientBuilder {
* Assigns {@code User-Agent} value.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*
*/
public final HttpClientBuilder setUserAgent(final String userAgent) {
@@ -493,7 +494,7 @@ public class HttpClientBuilder {
* Assigns default request header values.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*
*/
public final HttpClientBuilder setDefaultHeaders(final Collection extends Header> defaultHeaders) {
@@ -505,7 +506,7 @@ public class HttpClientBuilder {
* Adds this protocol interceptor to the head of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*
*/
public final HttpClientBuilder addInterceptorFirst(final HttpResponseInterceptor itcp) {
@@ -523,7 +524,7 @@ public class HttpClientBuilder {
* Adds this protocol interceptor to the tail of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*
*/
public final HttpClientBuilder addInterceptorLast(final HttpResponseInterceptor itcp) {
@@ -541,7 +542,7 @@ public class HttpClientBuilder {
* Adds this protocol interceptor to the head of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*/
public final HttpClientBuilder addInterceptorFirst(final HttpRequestInterceptor itcp) {
if (itcp == null) {
@@ -558,7 +559,7 @@ public class HttpClientBuilder {
* Adds this protocol interceptor to the tail of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*/
public final HttpClientBuilder addInterceptorLast(final HttpRequestInterceptor itcp) {
if (itcp == null) {
@@ -575,7 +576,7 @@ public class HttpClientBuilder {
* Disables state (cookie) management.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*/
public final HttpClientBuilder disableCookieManagement() {
this.cookieManagementDisabled = true;
@@ -586,7 +587,7 @@ public class HttpClientBuilder {
* Disables automatic content decompression.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*/
public final HttpClientBuilder disableContentCompression() {
contentCompressionDisabled = true;
@@ -597,7 +598,7 @@ public class HttpClientBuilder {
* Disables authentication scheme caching.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*/
public final HttpClientBuilder disableAuthCaching() {
this.authCachingDisabled = true;
@@ -645,7 +646,7 @@ public class HttpClientBuilder {
* Assigns default proxy value.
*
* Please note this value can be overridden by the {@link #setRoutePlanner(
- *HttpRoutePlanner)} method.
+ * com.fr.third.org.apache.http.conn.routing.HttpRoutePlanner)} method.
*/
public final HttpClientBuilder setProxy(final HttpHost proxy) {
this.proxy = proxy;
@@ -727,7 +728,7 @@ public class HttpClientBuilder {
}
/**
- * Assigns default {@link AuthScheme} registry which will
+ * Assigns default {@link com.fr.third.org.apache.http.auth.AuthScheme} registry which will
* be used for request execution if not explicitly set in the client execution
* context.
*/
@@ -738,11 +739,11 @@ public class HttpClientBuilder {
}
/**
- * Assigns default {@link CookieSpec} registry which will
+ * Assigns default {@link com.fr.third.org.apache.http.cookie.CookieSpec} registry which will
* be used for request execution if not explicitly set in the client execution
* context.
*
- * @see CookieSpecRegistries
+ * @see com.fr.third.org.apache.http.impl.client.CookieSpecRegistries
*
*/
public final HttpClientBuilder setDefaultCookieSpecRegistry(
@@ -753,7 +754,7 @@ public class HttpClientBuilder {
/**
- * Assigns a map of {@link InputStreamFactory}s
+ * Assigns a map of {@link com.fr.third.org.apache.http.client.entity.InputStreamFactory}s
* to be used for automatic content decompression.
*/
public final HttpClientBuilder setContentDecoderRegistry(
@@ -795,7 +796,7 @@ public class HttpClientBuilder {
* inside an EJB container.
*
* @see #setConnectionManagerShared(boolean)
- * @see HttpClientConnectionManager#closeExpiredConnections()
+ * @see com.fr.third.org.apache.http.conn.HttpClientConnectionManager#closeExpiredConnections()
*
* @since 4.4
*/
@@ -818,7 +819,7 @@ public class HttpClientBuilder {
* inside an EJB container.
*
* @see #setConnectionManagerShared(boolean)
- * @see HttpClientConnectionManager#closeExpiredConnections()
+ * @see com.fr.third.org.apache.http.conn.HttpClientConnectionManager#closeExpiredConnections()
*
* @param maxIdleTime maximum time persistent connections can stay idle while kept alive
* in the connection pool. Connections whose inactivity period exceeds this value will
@@ -848,7 +849,7 @@ public class HttpClientBuilder {
* inside an EJB container.
*
* @see #setConnectionManagerShared(boolean)
- * @see HttpClientConnectionManager#closeExpiredConnections()
+ * @see com.fr.third.org.apache.http.conn.HttpClientConnectionManager#closeExpiredConnections()
*
* @param maxIdleTime maximum time persistent connections can stay idle while kept alive
* in the connection pool. Connections whose inactivity period exceeds this value will
@@ -864,6 +865,16 @@ public class HttpClientBuilder {
return this;
}
+ /**
+ * Disables the default user agent set by this builder if none has been provided by the user.
+ *
+ * @since 4.5.7
+ */
+ public final HttpClientBuilder disableDefaultUserAgent() {
+ this.defaultUserAgentDisabled = true;
+ return this;
+ }
+
/**
* Produces an instance of {@link ClientExecChain} to be used as a main exec.
*
@@ -1042,7 +1053,7 @@ public class HttpClientBuilder {
if (systemProperties) {
userAgentCopy = System.getProperty("http.agent");
}
- if (userAgentCopy == null) {
+ if (userAgentCopy == null && !defaultUserAgentDisabled) {
userAgentCopy = VersionInfo.getUserAgent("Apache-HttpClient",
"org.apache.http.client", getClass());
}
@@ -1209,12 +1220,18 @@ public class HttpClientBuilder {
if (evictExpiredConnections || evictIdleConnections) {
final IdleConnectionEvictor connectionEvictor = new IdleConnectionEvictor(cm,
- maxIdleTime > 0 ? maxIdleTime : 10, maxIdleTimeUnit != null ? maxIdleTimeUnit : TimeUnit.SECONDS);
+ maxIdleTime > 0 ? maxIdleTime : 10, maxIdleTimeUnit != null ? maxIdleTimeUnit : TimeUnit.SECONDS,
+ maxIdleTime, maxIdleTimeUnit);
closeablesCopy.add(new Closeable() {
@Override
public void close() throws IOException {
connectionEvictor.shutdown();
+ try {
+ connectionEvictor.awaitTermination(1L, TimeUnit.SECONDS);
+ } catch (final InterruptedException interrupted) {
+ Thread.currentThread().interrupt();
+ }
}
});
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpClients.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpClients.java
index 789a6735c..d2c2e964f 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpClients.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpClients.java
@@ -58,7 +58,7 @@ public class HttpClients {
/**
* Creates {@link CloseableHttpClient} instance with default
- * configuration based on ssytem properties.
+ * configuration based on system properties.
*/
public static CloseableHttpClient createSystem() {
return HttpClientBuilder.create().useSystemProperties().build();
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpRequestFutureTask.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpRequestFutureTask.java
index 670d6bb6d..34be1d226 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpRequestFutureTask.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpRequestFutureTask.java
@@ -82,9 +82,8 @@ public class HttpRequestFutureTask extends FutureTask {
public long endedTime() {
if (isDone()) {
return callable.getEnded();
- } else {
- throw new IllegalStateException("Task is not done yet");
}
+ throw new IllegalStateException("Task is not done yet");
}
/**
@@ -94,9 +93,8 @@ public class HttpRequestFutureTask extends FutureTask {
public long requestDuration() {
if (isDone()) {
return endedTime() - startedTime();
- } else {
- throw new IllegalStateException("Task is not done yet");
}
+ throw new IllegalStateException("Task is not done yet");
}
/**
@@ -105,9 +103,8 @@ public class HttpRequestFutureTask extends FutureTask {
public long taskDuration() {
if (isDone()) {
return endedTime() - scheduledTime();
- } else {
- throw new IllegalStateException("Task is not done yet");
}
+ throw new IllegalStateException("Task is not done yet");
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpRequestTaskCallable.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpRequestTaskCallable.java
index 827302932..d762656ac 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpRequestTaskCallable.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/HttpRequestTaskCallable.java
@@ -106,9 +106,8 @@ class HttpRequestTaskCallable implements Callable {
metrics.getTasks().increment(started);
metrics.getActiveConnections().decrementAndGet();
}
- } else {
- throw new IllegalStateException("call has been cancelled for request " + request.getURI());
}
+ throw new IllegalStateException("call has been cancelled for request " + request.getURI());
}
public void cancel() {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/IdleConnectionEvictor.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/IdleConnectionEvictor.java
index c4a60e416..7da973c51 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/IdleConnectionEvictor.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/IdleConnectionEvictor.java
@@ -104,8 +104,8 @@ public final class IdleConnectionEvictor {
return thread.isAlive();
}
- public void awaitTermination(final long time, final TimeUnit tunit) throws InterruptedException {
- thread.join((tunit != null ? tunit : TimeUnit.MILLISECONDS).toMillis(time));
+ public void awaitTermination(final long time, final TimeUnit timeUnit) throws InterruptedException {
+ thread.join((timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS).toMillis(time));
}
static class DefaultThreadFactory implements ThreadFactory {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/InternalHttpClient.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/InternalHttpClient.java
index 322d010e3..374e6bdec 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/InternalHttpClient.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/InternalHttpClient.java
@@ -240,8 +240,8 @@ class InternalHttpClient extends CloseableHttpClient implements Configurable {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- connManager.closeIdleConnections(idletime, tunit);
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ connManager.closeIdleConnections(idletime, timeUnit);
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/LaxRedirectStrategy.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/LaxRedirectStrategy.java
index d791d0dae..9d6ab332b 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/LaxRedirectStrategy.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/LaxRedirectStrategy.java
@@ -29,14 +29,13 @@ package com.fr.third.org.apache.http.impl.client;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.client.RedirectStrategy;
import com.fr.third.org.apache.http.client.methods.HttpDelete;
import com.fr.third.org.apache.http.client.methods.HttpGet;
import com.fr.third.org.apache.http.client.methods.HttpHead;
import com.fr.third.org.apache.http.client.methods.HttpPost;
/**
- * Lax {@link RedirectStrategy} implementation
+ * Lax {@link com.fr.third.org.apache.http.client.RedirectStrategy} implementation
* that automatically redirects all HEAD, GET, POST, and DELETE requests.
* This strategy relaxes restrictions on automatic redirection of
* POST methods imposed by the HTTP specification.
@@ -48,24 +47,13 @@ public class LaxRedirectStrategy extends DefaultRedirectStrategy {
public static final LaxRedirectStrategy INSTANCE = new LaxRedirectStrategy();
- /**
- * Redirectable methods.
- */
- private static final String[] REDIRECT_METHODS = new String[] {
- HttpGet.METHOD_NAME,
- HttpPost.METHOD_NAME,
- HttpHead.METHOD_NAME,
- HttpDelete.METHOD_NAME
- };
-
- @Override
- protected boolean isRedirectable(final String method) {
- for (final String m: REDIRECT_METHODS) {
- if (m.equalsIgnoreCase(method)) {
- return true;
- }
- }
- return false;
+ public LaxRedirectStrategy() {
+ super(new String[] {
+ HttpGet.METHOD_NAME,
+ HttpPost.METHOD_NAME,
+ HttpHead.METHOD_NAME,
+ HttpDelete.METHOD_NAME
+ });
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/MinimalHttpClient.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/MinimalHttpClient.java
index 524b195ce..1c76196c8 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/MinimalHttpClient.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/MinimalHttpClient.java
@@ -150,8 +150,8 @@ class MinimalHttpClient extends CloseableHttpClient {
}
@Override
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- connManager.closeIdleConnections(idletime, tunit);
+ public void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ connManager.closeIdleConnections(idletime, timeUnit);
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/ProxyAuthenticationStrategy.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/ProxyAuthenticationStrategy.java
index d3bc7287a..df00d2f09 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/ProxyAuthenticationStrategy.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/ProxyAuthenticationStrategy.java
@@ -33,11 +33,10 @@ import com.fr.third.org.apache.http.HttpStatus;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.auth.AUTH;
-import com.fr.third.org.apache.http.client.AuthenticationStrategy;
import com.fr.third.org.apache.http.client.config.RequestConfig;
/**
- * Default {@link AuthenticationStrategy} implementation
+ * Default {@link com.fr.third.org.apache.http.client.AuthenticationStrategy} implementation
* for proxy host authentication.
*
* @since 4.2
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/RedirectLocations.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/RedirectLocations.java
index 0db15b9e4..d10905d0c 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/RedirectLocations.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/RedirectLocations.java
@@ -36,7 +36,7 @@ import java.util.List;
import java.util.Set;
/**
- * This class represents a collection of {@link java.net.URI}s used
+ * This class represents a collection of {@link URI}s used
* as redirect locations.
*
* @since 4.0
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java
index a29da9e33..d0747ab85 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java
@@ -34,10 +34,9 @@ import java.util.concurrent.ConcurrentHashMap;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.client.HttpRequestRetryHandler;
/**
- * {@link HttpRequestRetryHandler} which assumes
+ * {@link com.fr.third.org.apache.http.client.HttpRequestRetryHandler} which assumes
* that all requested HTTP methods which should be idempotent according
* to RFC-2616 are in fact idempotent and can be retried.
*
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
index 186d1ead4..7a0735015 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
@@ -87,17 +87,13 @@ public class SystemDefaultCredentialsProvider implements CredentialsProvider {
}
private static PasswordAuthentication getSystemCreds(
+ final String protocol,
final AuthScope authscope,
final Authenticator.RequestorType requestorType) {
- final String hostname = authscope.getHost();
- final int port = authscope.getPort();
- final HttpHost origin = authscope.getOrigin();
- final String protocol = origin != null ? origin.getSchemeName() :
- (port == 443 ? "https" : "http");
return Authenticator.requestPasswordAuthentication(
- hostname,
+ authscope.getHost(),
null,
- port,
+ authscope.getPort(),
protocol,
null,
translateScheme(authscope.getScheme()),
@@ -114,27 +110,20 @@ public class SystemDefaultCredentialsProvider implements CredentialsProvider {
}
final String host = authscope.getHost();
if (host != null) {
- PasswordAuthentication systemcreds = getSystemCreds(authscope, Authenticator.RequestorType.SERVER);
+ final HttpHost origin = authscope.getOrigin();
+ final String protocol = origin != null ? origin.getSchemeName() : (authscope.getPort() == 443 ? "https" : "http");
+ PasswordAuthentication systemcreds = getSystemCreds(protocol, authscope, Authenticator.RequestorType.SERVER);
if (systemcreds == null) {
- systemcreds = getSystemCreds(authscope, Authenticator.RequestorType.PROXY);
+ systemcreds = getSystemCreds(protocol, authscope, Authenticator.RequestorType.PROXY);
}
if (systemcreds == null) {
- final String proxyHost = System.getProperty("http.proxyHost");
- if (proxyHost != null) {
- final String proxyPort = System.getProperty("http.proxyPort");
- if (proxyPort != null) {
- try {
- final AuthScope systemScope = new AuthScope(proxyHost, Integer.parseInt(proxyPort));
- if (authscope.match(systemScope) >= 0) {
- final String proxyUser = System.getProperty("http.proxyUser");
- if (proxyUser != null) {
- final String proxyPassword = System.getProperty("http.proxyPassword");
- systemcreds = new PasswordAuthentication(proxyUser, proxyPassword != null ? proxyPassword.toCharArray() : new char[] {});
- }
- }
- } catch (NumberFormatException ex) {
- }
- }
+ // Look for values given using http.proxyUser/http.proxyPassword or
+ // https.proxyUser/https.proxyPassword. We cannot simply use the protocol from
+ // the origin since a proxy retrieved from https.proxyHost/https.proxyPort will
+ // still use http as protocol
+ systemcreds = getProxyCredentials("http", authscope);
+ if (systemcreds == null) {
+ systemcreds = getProxyCredentials("https", authscope);
}
}
if (systemcreds != null) {
@@ -144,24 +133,46 @@ public class SystemDefaultCredentialsProvider implements CredentialsProvider {
systemcreds.getUserName(),
new String(systemcreds.getPassword()),
null, domain);
- } else {
- if (AuthSchemes.NTLM.equalsIgnoreCase(authscope.getScheme())) {
- // Domain may be specified in a fully qualified user name
- return new NTCredentials(
- systemcreds.getUserName(),
- new String(systemcreds.getPassword()),
- null, null);
- } else {
- return new UsernamePasswordCredentials(
- systemcreds.getUserName(),
- new String(systemcreds.getPassword()));
- }
}
+ return AuthSchemes.NTLM.equalsIgnoreCase(authscope.getScheme())
+ // Domain may be specified in a fully qualified user name
+ ? new NTCredentials(systemcreds.getUserName(),
+ new String(systemcreds.getPassword()), null, null)
+ : new UsernamePasswordCredentials(systemcreds.getUserName(),
+ new String(systemcreds.getPassword()));
}
}
return null;
}
+ private static PasswordAuthentication getProxyCredentials(final String protocol, final AuthScope authscope) {
+ final String proxyHost = System.getProperty(protocol + ".proxyHost");
+ if (proxyHost == null) {
+ return null;
+ }
+ final String proxyPort = System.getProperty(protocol + ".proxyPort");
+ if (proxyPort == null) {
+ return null;
+ }
+
+ try {
+ final AuthScope systemScope = new AuthScope(proxyHost, Integer.parseInt(proxyPort));
+ if (authscope.match(systemScope) >= 0) {
+ final String proxyUser = System.getProperty(protocol + ".proxyUser");
+ if (proxyUser == null) {
+ return null;
+ }
+ final String proxyPassword = System.getProperty(protocol + ".proxyPassword");
+
+ return new PasswordAuthentication(proxyUser,
+ proxyPassword != null ? proxyPassword.toCharArray() : new char[] {});
+ }
+ } catch (final NumberFormatException ex) {
+ }
+
+ return null;
+ }
+
@Override
public void clear() {
internal.clear();
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/TargetAuthenticationStrategy.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/TargetAuthenticationStrategy.java
index 9fd015071..e767eb614 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/TargetAuthenticationStrategy.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/client/TargetAuthenticationStrategy.java
@@ -33,11 +33,10 @@ import com.fr.third.org.apache.http.HttpStatus;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.auth.AUTH;
-import com.fr.third.org.apache.http.client.AuthenticationStrategy;
import com.fr.third.org.apache.http.client.config.RequestConfig;
/**
- * Default {@link AuthenticationStrategy} implementation
+ * Default {@link com.fr.third.org.apache.http.client.AuthenticationStrategy} implementation
* for proxy host authentication.
*
* @since 4.2
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
index b0246a85b..4ccd36a71 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
@@ -157,7 +157,9 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
@Override
public void close() {
- shutdown();
+ if (this.isShutdown.compareAndSet(false, true)) {
+ closeConnection();
+ }
}
HttpRoute getRoute() {
@@ -198,7 +200,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
}
@Override
- public HttpClientConnection get(final long timeout, final TimeUnit tunit) {
+ public HttpClientConnection get(final long timeout, final TimeUnit timeUnit) {
return BasicHttpClientConnectionManager.this.getConnection(
route, state);
}
@@ -206,7 +208,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
};
}
- private void closeConnection() {
+ private synchronized void closeConnection() {
if (this.conn != null) {
this.log.debug("Closing connection");
try {
@@ -220,20 +222,6 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
}
}
- private void shutdownConnection() {
- if (this.conn != null) {
- this.log.debug("Shutting down connection");
- try {
- this.conn.shutdown();
- } catch (final IOException iox) {
- if (this.log.isDebugEnabled()) {
- this.log.debug("I/O exception shutting down connection", iox);
- }
- }
- this.conn = null;
- }
- }
-
private void checkExpiry() {
if (this.conn != null && System.currentTimeMillis() >= this.expiry) {
if (this.log.isDebugEnabled()) {
@@ -258,6 +246,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
if (this.conn == null) {
this.conn = this.connFactory.create(route, this.connConfig);
}
+ this.conn.setSocketTimeout(this.socketConfig.getSoTimeout());
this.leased = true;
return this.conn;
}
@@ -266,7 +255,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
public synchronized void releaseConnection(
final HttpClientConnection conn,
final Object state,
- final long keepalive, final TimeUnit tunit) {
+ final long keepalive, final TimeUnit timeUnit) {
Args.notNull(conn, "Connection");
Asserts.check(conn == this.conn, "Connection not obtained from this manager");
if (this.log.isDebugEnabled()) {
@@ -284,17 +273,18 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
this.expiry = Long.MAX_VALUE;
} else {
this.state = state;
+ this.conn.setSocketTimeout(0);
if (this.log.isDebugEnabled()) {
final String s;
if (keepalive > 0) {
- s = "for " + keepalive + " " + tunit;
+ s = "for " + keepalive + " " + timeUnit;
} else {
s = "indefinitely";
}
this.log.debug("Connection can be kept alive " + s);
}
if (keepalive > 0) {
- this.expiry = this.updated + tunit.toMillis(keepalive);
+ this.expiry = this.updated + timeUnit.toMillis(keepalive);
} else {
this.expiry = Long.MAX_VALUE;
}
@@ -353,13 +343,13 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
}
@Override
- public synchronized void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
+ public synchronized void closeIdleConnections(final long idletime, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
if (this.isShutdown.get()) {
return;
}
if (!this.leased) {
- long time = tunit.toMillis(idletime);
+ long time = timeUnit.toMillis(idletime);
if (time < 0) {
time = 0;
}
@@ -371,9 +361,19 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
}
@Override
- public synchronized void shutdown() {
+ public void shutdown() {
if (this.isShutdown.compareAndSet(false, true)) {
- shutdownConnection();
+ if (this.conn != null) {
+ this.log.debug("Shutting down connection");
+ try {
+ this.conn.shutdown();
+ } catch (final IOException iox) {
+ if (this.log.isDebugEnabled()) {
+ this.log.debug("I/O exception shutting down connection", iox);
+ }
+ }
+ this.conn = null;
+ }
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/CPool.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/CPool.java
index ec6ed3d47..6b34b6244 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/CPool.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/CPool.java
@@ -49,21 +49,21 @@ class CPool extends AbstractConnPool connFactory,
final int defaultMaxPerRoute, final int maxTotal,
- final long timeToLive, final TimeUnit tunit) {
+ final long timeToLive, final TimeUnit timeUnit) {
super(connFactory, defaultMaxPerRoute, maxTotal);
this.timeToLive = timeToLive;
- this.tunit = tunit;
+ this.timeUnit = timeUnit;
}
@Override
protected CPoolEntry createEntry(final HttpRoute route, final ManagedHttpClientConnection conn) {
final String id = Long.toString(COUNTER.getAndIncrement());
- return new CPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
+ return new CPoolEntry(this.log, id, route, conn, this.timeToLive, this.timeUnit);
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/CPoolEntry.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/CPoolEntry.java
index b6577c18c..5773dc7db 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/CPoolEntry.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/CPoolEntry.java
@@ -52,8 +52,8 @@ class CPoolEntry extends PoolEntry {
final String id,
final HttpRoute route,
final ManagedHttpClientConnection conn,
- final long timeToLive, final TimeUnit tunit) {
- super(id, route, conn, timeToLive, tunit);
+ final long timeToLive, final TimeUnit timeUnit) {
+ super(id, route, conn, timeToLive, timeUnit);
this.log = log;
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/CPoolProxy.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/CPoolProxy.java
index 91f3b47fb..7146eff07 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/CPoolProxy.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/CPoolProxy.java
@@ -98,21 +98,13 @@ class CPoolProxy implements ManagedHttpClientConnection, HttpContext {
@Override
public boolean isOpen() {
final CPoolEntry local = this.poolEntry;
- if (local != null) {
- return !local.isClosed();
- } else {
- return false;
- }
+ return local != null ? !local.isClosed() : false;
}
@Override
public boolean isStale() {
final HttpClientConnection conn = getConnection();
- if (conn != null) {
- return conn.isStale();
- } else {
- return true;
- }
+ return conn != null ? conn.isStale() : true;
}
@Override
@@ -203,11 +195,7 @@ class CPoolProxy implements ManagedHttpClientConnection, HttpContext {
@Override
public Object getAttribute(final String id) {
final ManagedHttpClientConnection conn = getValidConnection();
- if (conn instanceof HttpContext) {
- return ((HttpContext) conn).getAttribute(id);
- } else {
- return null;
- }
+ return conn instanceof HttpContext ? ((HttpContext) conn).getAttribute(id) : null;
}
@Override
@@ -221,11 +209,7 @@ class CPoolProxy implements ManagedHttpClientConnection, HttpContext {
@Override
public Object removeAttribute(final String id) {
final ManagedHttpClientConnection conn = getValidConnection();
- if (conn instanceof HttpContext) {
- return ((HttpContext) conn).removeAttribute(id);
- } else {
- return null;
- }
+ return conn instanceof HttpContext ? ((HttpContext) conn).removeAttribute(id) : null;
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
index e3150888f..fad3bbd92 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultHttpClientConnectionOperator.java
@@ -153,11 +153,9 @@ public class DefaultHttpClientConnectionOperator implements HttpClientConnection
} catch (final ConnectException ex) {
if (last) {
final String msg = ex.getMessage();
- if ("Connection timed out".equals(msg)) {
- throw new ConnectTimeoutException(ex, host, addresses);
- } else {
- throw new HttpHostConnectException(ex, host, addresses);
- }
+ throw "Connection timed out".equals(msg)
+ ? new ConnectTimeoutException(ex, host, addresses)
+ : new HttpHostConnectException(ex, host, addresses);
}
} catch (final NoRouteToHostException ex) {
if (last) {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultHttpResponseParser.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultHttpResponseParser.java
index 3d543f09b..829368e30 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultHttpResponseParser.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultHttpResponseParser.java
@@ -29,7 +29,6 @@ package com.fr.third.org.apache.http.impl.conn;
import java.io.IOException;
-import com.fr.third.org.apache.http.message.BasicLineParser;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.fr.third.org.apache.http.HttpException;
@@ -83,7 +82,7 @@ public class DefaultHttpResponseParser extends AbstractMessageParser requestWriterFactory,
final HttpMessageParserFactory responseParserFactory) {
- super(buffersize, fragmentSizeHint, chardecoder, charencoder,
+ super(bufferSize, fragmentSizeHint, charDecoder, charEncoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.id = id;
@@ -80,8 +80,8 @@ public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnec
public DefaultManagedHttpClientConnection(
final String id,
- final int buffersize) {
- this(id, buffersize, buffersize, null, null, null, null, null, null, null);
+ final int bufferSize) {
+ this(id, bufferSize, bufferSize, null, null, null, null, null, null, null);
}
@Override
@@ -128,11 +128,7 @@ public class DefaultManagedHttpClientConnection extends DefaultBHttpClientConnec
@Override
public SSLSession getSSLSession() {
final Socket socket = super.getSocket();
- if (socket instanceof SSLSocket) {
- return ((SSLSocket) socket).getSession();
- } else {
- return null;
- }
+ return socket instanceof SSLSocket ? ((SSLSocket) socket).getSession() : null;
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java
index eea037545..a077212fd 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java
@@ -32,13 +32,12 @@ import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.conn.routing.HttpRoutePlanner;
import com.fr.third.org.apache.http.conn.SchemePortResolver;
import com.fr.third.org.apache.http.protocol.HttpContext;
import com.fr.third.org.apache.http.util.Args;
/**
- * Implementation of an {@link HttpRoutePlanner}
+ * Implementation of an {@link com.fr.third.org.apache.http.conn.routing.HttpRoutePlanner}
* that routes requests through a default proxy.
*
* @since 4.3
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultRoutePlanner.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultRoutePlanner.java
index 94bb688aa..6eed1f2f9 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultRoutePlanner.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/DefaultRoutePlanner.java
@@ -92,11 +92,9 @@ public class DefaultRoutePlanner implements HttpRoutePlanner {
target = host;
}
final boolean secure = target.getSchemeName().equalsIgnoreCase("https");
- if (proxy == null) {
- return new HttpRoute(target, local, secure);
- } else {
- return new HttpRoute(target, local, proxy, secure);
- }
+ return proxy == null
+ ? new HttpRoute(target, local, secure)
+ : new HttpRoute(target, local, proxy, secure);
}
/**
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
index 3cc3845a7..1b9751d64 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
@@ -46,29 +46,29 @@ import com.fr.third.org.apache.http.io.HttpMessageWriterFactory;
class LoggingManagedHttpClientConnection extends DefaultManagedHttpClientConnection {
private final Log log;
- private final Log headerlog;
+ private final Log headerLog;
private final Wire wire;
public LoggingManagedHttpClientConnection(
final String id,
final Log log,
- final Log headerlog,
- final Log wirelog,
- final int buffersize,
+ final Log headerLog,
+ final Log wireLog,
+ final int bufferSize,
final int fragmentSizeHint,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory requestWriterFactory,
final HttpMessageParserFactory responseParserFactory) {
- super(id, buffersize, fragmentSizeHint, chardecoder, charencoder,
+ super(id, bufferSize, fragmentSizeHint, charDecoder, charEncoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
this.log = log;
- this.headerlog = headerlog;
- this.wire = new Wire(wirelog, id);
+ this.headerLog = headerLog;
+ this.wire = new Wire(wireLog, id);
}
@Override
@@ -118,22 +118,22 @@ class LoggingManagedHttpClientConnection extends DefaultManagedHttpClientConnect
@Override
protected void onResponseReceived(final HttpResponse response) {
- if (response != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(getId() + " << " + response.getStatusLine().toString());
+ if (response != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(getId() + " << " + response.getStatusLine().toString());
final Header[] headers = response.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(getId() + " << " + header.toString());
+ this.headerLog.debug(getId() + " << " + header.toString());
}
}
}
@Override
protected void onRequestSubmitted(final HttpRequest request) {
- if (request != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(getId() + " >> " + request.getRequestLine().toString());
+ if (request != null && this.headerLog.isDebugEnabled()) {
+ this.headerLog.debug(getId() + " >> " + request.getRequestLine().toString());
final Header[] headers = request.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(getId() + " >> " + header.toString());
+ this.headerLog.debug(getId() + " >> " + header.toString());
}
}
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
index 0f34b64ab..349031746 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
@@ -63,8 +63,8 @@ public class ManagedHttpClientConnectionFactory
public static final ManagedHttpClientConnectionFactory INSTANCE = new ManagedHttpClientConnectionFactory();
private final Log log = LogFactory.getLog(DefaultManagedHttpClientConnection.class);
- private final Log headerlog = LogFactory.getLog("org.apache.http.headers");
- private final Log wirelog = LogFactory.getLog("org.apache.http.wire");
+ private final Log headerLog = LogFactory.getLog("org.apache.http.headers");
+ private final Log wireLog = LogFactory.getLog("org.apache.http.wire");
private final HttpMessageWriterFactory requestWriterFactory;
private final HttpMessageParserFactory responseParserFactory;
@@ -108,31 +108,31 @@ public class ManagedHttpClientConnectionFactory
@Override
public ManagedHttpClientConnection create(final HttpRoute route, final ConnectionConfig config) {
final ConnectionConfig cconfig = config != null ? config : ConnectionConfig.DEFAULT;
- CharsetDecoder chardecoder = null;
- CharsetEncoder charencoder = null;
+ CharsetDecoder charDecoder = null;
+ CharsetEncoder charEncoder = null;
final Charset charset = cconfig.getCharset();
final CodingErrorAction malformedInputAction = cconfig.getMalformedInputAction() != null ?
cconfig.getMalformedInputAction() : CodingErrorAction.REPORT;
final CodingErrorAction unmappableInputAction = cconfig.getUnmappableInputAction() != null ?
cconfig.getUnmappableInputAction() : CodingErrorAction.REPORT;
if (charset != null) {
- chardecoder = charset.newDecoder();
- chardecoder.onMalformedInput(malformedInputAction);
- chardecoder.onUnmappableCharacter(unmappableInputAction);
- charencoder = charset.newEncoder();
- charencoder.onMalformedInput(malformedInputAction);
- charencoder.onUnmappableCharacter(unmappableInputAction);
+ charDecoder = charset.newDecoder();
+ charDecoder.onMalformedInput(malformedInputAction);
+ charDecoder.onUnmappableCharacter(unmappableInputAction);
+ charEncoder = charset.newEncoder();
+ charEncoder.onMalformedInput(malformedInputAction);
+ charEncoder.onUnmappableCharacter(unmappableInputAction);
}
final String id = "http-outgoing-" + Long.toString(COUNTER.getAndIncrement());
return new LoggingManagedHttpClientConnection(
id,
log,
- headerlog,
- wirelog,
+ headerLog,
+ wireLog,
cconfig.getBufferSize(),
cconfig.getFragmentSizeHint(),
- chardecoder,
- charencoder,
+ charDecoder,
+ charEncoder,
cconfig.getMessageConstraints(),
incomingContentStrategy,
outgoingContentStrategy,
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
index b7ee8185b..16a438d00 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
@@ -28,9 +28,9 @@ package com.fr.third.org.apache.http.impl.conn;
import java.io.Closeable;
import java.io.IOException;
-import java.net.InetSocketAddress;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.CancellationException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
@@ -63,6 +63,7 @@ import com.fr.third.org.apache.http.conn.socket.PlainConnectionSocketFactory;
import com.fr.third.org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import com.fr.third.org.apache.http.pool.ConnFactory;
import com.fr.third.org.apache.http.pool.ConnPoolControl;
+import com.fr.third.org.apache.http.pool.PoolEntry;
import com.fr.third.org.apache.http.pool.PoolEntryCallback;
import com.fr.third.org.apache.http.pool.PoolStats;
import com.fr.third.org.apache.http.protocol.HttpContext;
@@ -122,8 +123,8 @@ public class PoolingHttpClientConnectionManager
this(getDefaultRegistry());
}
- public PoolingHttpClientConnectionManager(final long timeToLive, final TimeUnit tunit) {
- this(getDefaultRegistry(), null, null ,null, timeToLive, tunit);
+ public PoolingHttpClientConnectionManager(final long timeToLive, final TimeUnit timeUnit) {
+ this(getDefaultRegistry(), null, null ,null, timeToLive, timeUnit);
}
public PoolingHttpClientConnectionManager(
@@ -160,11 +161,11 @@ public class PoolingHttpClientConnectionManager
final HttpConnectionFactory connFactory,
final SchemePortResolver schemePortResolver,
final DnsResolver dnsResolver,
- final long timeToLive, final TimeUnit tunit) {
+ final long timeToLive, final TimeUnit timeUnit) {
this(
new DefaultHttpClientConnectionOperator(socketFactoryRegistry, schemePortResolver, dnsResolver),
connFactory,
- timeToLive, tunit
+ timeToLive, timeUnit
);
}
@@ -174,11 +175,11 @@ public class PoolingHttpClientConnectionManager
public PoolingHttpClientConnectionManager(
final HttpClientConnectionOperator httpClientConnectionOperator,
final HttpConnectionFactory connFactory,
- final long timeToLive, final TimeUnit tunit) {
+ final long timeToLive, final TimeUnit timeUnit) {
super();
this.configData = new ConfigData();
this.pool = new CPool(new InternalConnectionFactory(
- this.configData, connFactory), 2, 20, timeToLive, tunit);
+ this.configData, connFactory), 2, 20, timeToLive, timeUnit);
this.pool.setValidateAfterInactivity(2000);
this.connectionOperator = Args.notNull(httpClientConnectionOperator, "HttpClientConnectionOperator");
this.isShutDown = new AtomicBoolean(false);
@@ -227,7 +228,7 @@ public class PoolingHttpClientConnectionManager
final StringBuilder buf = new StringBuilder();
final PoolStats totals = this.pool.getTotalStats();
final PoolStats stats = this.pool.getStats(route);
- buf.append("[total kept alive: ").append(totals.getAvailable()).append("; ");
+ buf.append("[total available: ").append(totals.getAvailable()).append("; ");
buf.append("route allocated: ").append(stats.getLeased() + stats.getAvailable());
buf.append(" of ").append(stats.getMax()).append("; ");
buf.append("total allocated: ").append(totals.getLeased() + totals.getAvailable());
@@ -246,6 +247,17 @@ public class PoolingHttpClientConnectionManager
return buf.toString();
}
+ private SocketConfig resolveSocketConfig(final HttpHost host) {
+ SocketConfig socketConfig = this.configData.getSocketConfig(host);
+ if (socketConfig == null) {
+ socketConfig = this.configData.getDefaultSocketConfig();
+ }
+ if (socketConfig == null) {
+ socketConfig = SocketConfig.DEFAULT;
+ }
+ return socketConfig;
+ }
+
@Override
public ConnectionRequest requestConnection(
final HttpRoute route,
@@ -254,6 +266,7 @@ public class PoolingHttpClientConnectionManager
if (this.log.isDebugEnabled()) {
this.log.debug("Connection request: " + format(route, state) + formatStats(route));
}
+ Asserts.check(!this.isShutDown.get(), "Connection pool shut down");
final Future future = this.pool.lease(route, state, null);
return new ConnectionRequest() {
@@ -265,8 +278,19 @@ public class PoolingHttpClientConnectionManager
@Override
public HttpClientConnection get(
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
- return leaseConnection(future, timeout, tunit);
+ final TimeUnit timeUnit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
+ final HttpClientConnection conn = leaseConnection(future, timeout, timeUnit);
+ if (conn.isOpen()) {
+ final HttpHost host;
+ if (route.getProxyHost() != null) {
+ host = route.getProxyHost();
+ } else {
+ host = route.getTargetHost();
+ }
+ final SocketConfig socketConfig = resolveSocketConfig(host);
+ conn.setSocketTimeout(socketConfig.getSoTimeout());
+ }
+ return conn;
}
};
@@ -276,12 +300,12 @@ public class PoolingHttpClientConnectionManager
protected HttpClientConnection leaseConnection(
final Future future,
final long timeout,
- final TimeUnit tunit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
+ final TimeUnit timeUnit) throws InterruptedException, ExecutionException, ConnectionPoolTimeoutException {
final CPoolEntry entry;
try {
- entry = future.get(timeout, tunit);
+ entry = future.get(timeout, timeUnit);
if (entry == null || future.isCancelled()) {
- throw new InterruptedException();
+ throw new ExecutionException(new CancellationException("Operation cancelled"));
}
Asserts.check(entry.getConnection() != null, "Pool entry with no connection");
if (this.log.isDebugEnabled()) {
@@ -297,7 +321,7 @@ public class PoolingHttpClientConnectionManager
public void releaseConnection(
final HttpClientConnection managedConn,
final Object state,
- final long keepalive, final TimeUnit tunit) {
+ final long keepalive, final TimeUnit timeUnit) {
Args.notNull(managedConn, "Managed connection");
synchronized (managedConn) {
final CPoolEntry entry = CPoolProxy.detach(managedConn);
@@ -307,7 +331,7 @@ public class PoolingHttpClientConnectionManager
final ManagedHttpClientConnection conn = entry.getConnection();
try {
if (conn.isOpen()) {
- final TimeUnit effectiveUnit = tunit != null ? tunit : TimeUnit.MILLISECONDS;
+ final TimeUnit effectiveUnit = timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS;
entry.setState(state);
entry.updateExpiry(keepalive, effectiveUnit);
if (this.log.isDebugEnabled()) {
@@ -319,6 +343,7 @@ public class PoolingHttpClientConnectionManager
}
this.log.debug("Connection " + format(entry) + " can be kept alive " + s);
}
+ conn.setSocketTimeout(0);
}
} finally {
this.pool.release(entry, conn.isOpen() && entry.isRouteComplete());
@@ -348,16 +373,8 @@ public class PoolingHttpClientConnectionManager
} else {
host = route.getTargetHost();
}
- final InetSocketAddress localAddress = route.getLocalSocketAddress();
- SocketConfig socketConfig = this.configData.getSocketConfig(host);
- if (socketConfig == null) {
- socketConfig = this.configData.getDefaultSocketConfig();
- }
- if (socketConfig == null) {
- socketConfig = SocketConfig.DEFAULT;
- }
this.connectionOperator.connect(
- conn, host, localAddress, connectTimeout, socketConfig, context);
+ conn, host, route.getLocalSocketAddress(), connectTimeout, resolveSocketConfig(host), context);
}
@Override
@@ -393,6 +410,23 @@ public class PoolingHttpClientConnectionManager
if (this.isShutDown.compareAndSet(false, true)) {
this.log.debug("Connection manager is shutting down");
try {
+ this.pool.enumLeased(new PoolEntryCallback() {
+
+ @Override
+ public void process(final PoolEntry entry) {
+ final ManagedHttpClientConnection connection = entry.getConnection();
+ if (connection != null) {
+ try {
+ connection.shutdown();
+ } catch (final IOException iox) {
+ if (log.isDebugEnabled()) {
+ log.debug("I/O exception shutting down connection", iox);
+ }
+ }
+ }
+ }
+
+ });
this.pool.shutdown();
} catch (final IOException ex) {
this.log.debug("I/O exception shutting down connection manager", ex);
@@ -402,11 +436,11 @@ public class PoolingHttpClientConnectionManager
}
@Override
- public void closeIdleConnections(final long idleTimeout, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idleTimeout, final TimeUnit timeUnit) {
if (this.log.isDebugEnabled()) {
- this.log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit);
+ this.log.debug("Closing connections idle longer than " + idleTimeout + " " + timeUnit);
}
- this.pool.closeIdle(idleTimeout, tunit);
+ this.pool.closeIdle(idleTimeout, timeUnit);
}
@Override
@@ -513,12 +547,12 @@ public class PoolingHttpClientConnectionManager
/**
* Defines period of inactivity in milliseconds after which persistent connections must
- * be re-validated prior to being {@link #leaseConnection(java.util.concurrent.Future,
- * long, java.util.concurrent.TimeUnit) leased} to the consumer. Non-positive value passed
+ * be re-validated prior to being {@link #leaseConnection(Future,
+ * long, TimeUnit) leased} to the consumer. Non-positive value passed
* to this method disables connection validation. This check helps detect connections
* that have become stale (half-closed) while kept inactive in the pool.
*
- * @see #leaseConnection(java.util.concurrent.Future, long, java.util.concurrent.TimeUnit)
+ * @see #leaseConnection(Future, long, TimeUnit)
*
* @since 4.4
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/SystemDefaultRoutePlanner.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/SystemDefaultRoutePlanner.java
index 3b3b32052..dce2bd8c3 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/SystemDefaultRoutePlanner.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/SystemDefaultRoutePlanner.java
@@ -39,12 +39,11 @@ import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.conn.routing.HttpRoutePlanner;
import com.fr.third.org.apache.http.conn.SchemePortResolver;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
- * {@link HttpRoutePlanner} implementation
+ * {@link com.fr.third.org.apache.http.conn.routing.HttpRoutePlanner} implementation
* based on {@link ProxySelector}. By default, this class will pick up
* the proxy settings of the JVM, either from system properties
* or from the browser running the application.
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/Wire.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/Wire.java
index 67c60c26f..73b43ca9a 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/Wire.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/conn/Wire.java
@@ -59,11 +59,11 @@ public class Wire {
this(log, "");
}
- private void wire(final String header, final InputStream instream)
+ private void wire(final String header, final InputStream inStream)
throws IOException {
final StringBuilder buffer = new StringBuilder();
int ch;
- while ((ch = instream.read()) != -1) {
+ while ((ch = inStream.read()) != -1) {
if (ch == 13) {
buffer.append("[\\r]");
} else if (ch == 10) {
@@ -93,16 +93,16 @@ public class Wire {
return log.isDebugEnabled();
}
- public void output(final InputStream outstream)
+ public void output(final InputStream outStream)
throws IOException {
- Args.notNull(outstream, "Output");
- wire(">> ", outstream);
+ Args.notNull(outStream, "Output");
+ wire(">> ", outStream);
}
- public void input(final InputStream instream)
+ public void input(final InputStream inStream)
throws IOException {
- Args.notNull(instream, "Input");
- wire("<< ", instream);
+ Args.notNull(inStream, "Input");
+ wire("<< ", inStream);
}
public void output(final byte[] b, final int off, final int len)
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/AbstractCookieSpec.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/AbstractCookieSpec.java
index d7d1992bf..30878403a 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/AbstractCookieSpec.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/AbstractCookieSpec.java
@@ -85,8 +85,8 @@ public abstract class AbstractCookieSpec implements CookieSpec {
}
/**
- * @deprecated (4.4) use {@link #AbstractCookieSpec(java.util.HashMap)} or
- * {@link #AbstractCookieSpec(CommonCookieAttributeHandler...)}
+ * @deprecated (4.4) use {@link #AbstractCookieSpec(HashMap)} or
+ * {@link #AbstractCookieSpec(org.apache.http.cookie.CommonCookieAttributeHandler...)}
* constructors instead.
*/
@Deprecated
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/BasicClientCookie.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/BasicClientCookie.java
index f81101341..7dfbbde95 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/BasicClientCookie.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/BasicClientCookie.java
@@ -134,7 +134,7 @@ public class BasicClientCookie implements SetCookie, ClientCookie, Cloneable, Se
* in undefined behaviour. Do so at your peril.
* @return Expiration {@link Date}, or {@code null}.
*
- * @see #setExpiryDate(java.util.Date)
+ * @see #setExpiryDate(Date)
*
*/
@Override
@@ -177,7 +177,7 @@ public class BasicClientCookie implements SetCookie, ClientCookie, Cloneable, Se
*
* @return the value of the domain attribute
*
- * @see #setDomain(java.lang.String)
+ * @see #setDomain(String)
*/
@Override
public String getDomain() {
@@ -206,7 +206,7 @@ public class BasicClientCookie implements SetCookie, ClientCookie, Cloneable, Se
*
* @return The value of the path attribute.
*
- * @see #setPath(java.lang.String)
+ * @see #setPath(String)
*/
@Override
public String getPath() {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/BasicExpiresHandler.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/BasicExpiresHandler.java
index d04c58abe..5ea90dc4f 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/BasicExpiresHandler.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/BasicExpiresHandler.java
@@ -45,11 +45,11 @@ import com.fr.third.org.apache.http.util.Args;
public class BasicExpiresHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
/** Valid date patterns */
- private final String[] datepatterns;
+ private final String[] datePatterns;
- public BasicExpiresHandler(final String[] datepatterns) {
- Args.notNull(datepatterns, "Array of date patterns");
- this.datepatterns = datepatterns;
+ public BasicExpiresHandler(final String[] datePatterns) {
+ Args.notNull(datePatterns, "Array of date patterns");
+ this.datePatterns = datePatterns.clone();
}
@Override
@@ -59,7 +59,7 @@ public class BasicExpiresHandler extends AbstractCookieAttributeHandler implemen
if (value == null) {
throw new MalformedCookieException("Missing value for 'expires' attribute");
}
- final Date expiry = DateUtils.parseDate(value, this.datepatterns);
+ final Date expiry = DateUtils.parseDate(value, this.datePatterns);
if (expiry == null) {
throw new MalformedCookieException("Invalid 'expires' attribute: "
+ value);
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/DefaultCookieSpec.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/DefaultCookieSpec.java
index 5856686fb..f90762354 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/DefaultCookieSpec.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/DefaultCookieSpec.java
@@ -105,14 +105,14 @@ public class DefaultCookieSpec implements CookieSpec {
final CookieOrigin origin) throws MalformedCookieException {
Args.notNull(header, "Header");
Args.notNull(origin, "Cookie origin");
- HeaderElement[] helems = header.getElements();
+ HeaderElement[] hElems = header.getElements();
boolean versioned = false;
boolean netscape = false;
- for (final HeaderElement helem: helems) {
- if (helem.getParameterByName("version") != null) {
+ for (final HeaderElement hElem: hElems) {
+ if (hElem.getParameterByName("version") != null) {
versioned = true;
}
- if (helem.getParameterByName("expires") != null) {
+ if (hElem.getParameterByName("expires") != null) {
netscape = true;
}
}
@@ -128,23 +128,20 @@ public class DefaultCookieSpec implements CookieSpec {
((FormattedHeader) header).getValuePos(),
buffer.length());
} else {
- final String s = header.getValue();
- if (s == null) {
+ final String hValue = header.getValue();
+ if (hValue == null) {
throw new MalformedCookieException("Header value is null");
}
- buffer = new CharArrayBuffer(s.length());
- buffer.append(s);
+ buffer = new CharArrayBuffer(hValue.length());
+ buffer.append(hValue);
cursor = new ParserCursor(0, buffer.length());
}
- helems = new HeaderElement[] { parser.parseHeader(buffer, cursor) };
- return netscapeDraft.parse(helems, origin);
- } else {
- if (SM.SET_COOKIE2.equals(header.getName())) {
- return strict.parse(helems, origin);
- } else {
- return obsoleteStrict.parse(helems, origin);
- }
+ hElems = new HeaderElement[] { parser.parseHeader(buffer, cursor) };
+ return netscapeDraft.parse(hElems, origin);
}
+ return SM.SET_COOKIE2.equals(header.getName())
+ ? strict.parse(hElems, origin)
+ : obsoleteStrict.parse(hElems, origin);
}
@Override
@@ -169,14 +166,11 @@ public class DefaultCookieSpec implements CookieSpec {
Args.notNull(cookie, "Cookie");
Args.notNull(origin, "Cookie origin");
if (cookie.getVersion() > 0) {
- if (cookie instanceof SetCookie2) {
- return strict.match(cookie, origin);
- } else {
- return obsoleteStrict.match(cookie, origin);
- }
- } else {
- return netscapeDraft.match(cookie, origin);
+ return cookie instanceof SetCookie2
+ ? strict.match(cookie, origin)
+ : obsoleteStrict.match(cookie, origin);
}
+ return netscapeDraft.match(cookie, origin);
}
@Override
@@ -193,14 +187,11 @@ public class DefaultCookieSpec implements CookieSpec {
}
}
if (version > 0) {
- if (isSetCookie2) {
- return strict.formatCookies(cookies);
- } else {
- return obsoleteStrict.formatCookies(cookies);
- }
- } else {
- return netscapeDraft.formatCookies(cookies);
+ return isSetCookie2
+ ? strict.formatCookies(cookies)
+ : obsoleteStrict.formatCookies(cookies);
}
+ return netscapeDraft.formatCookies(cookies);
}
@Override
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
index fee72e29e..ee3746919 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/DefaultCookieSpecProvider.java
@@ -38,8 +38,8 @@ import com.fr.third.org.apache.http.cookie.MalformedCookieException;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
- * {@link CookieSpecProvider} implementation that provides an instance of
- * {@link DefaultCookieSpec}. The instance returned by this factory can
+ * {@link com.fr.third.org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
+ * {@link com.fr.third.org.apache.http.impl.cookie.DefaultCookieSpec}. The instance returned by this factory can
* be shared by multiple threads.
*
* @since 4.4
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/IgnoreSpecProvider.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/IgnoreSpecProvider.java
index 1dd20b3b9..7d28d45cc 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/IgnoreSpecProvider.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/IgnoreSpecProvider.java
@@ -34,7 +34,7 @@ import com.fr.third.org.apache.http.cookie.CookieSpecProvider;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
- * {@link CookieSpecProvider} implementation that ignores all cookies.
+ * {@link com.fr.third.org.apache.http.cookie.CookieSpecProvider} implementation that ignores all cookies.
*
* @since 4.4
*/
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/LaxExpiresHandler.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/LaxExpiresHandler.java
index 961f2d23a..d15df808b 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/LaxExpiresHandler.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/LaxExpiresHandler.java
@@ -43,6 +43,7 @@ import com.fr.third.org.apache.http.cookie.MalformedCookieException;
import com.fr.third.org.apache.http.cookie.SetCookie;
import com.fr.third.org.apache.http.message.ParserCursor;
import com.fr.third.org.apache.http.util.Args;
+import com.fr.third.org.apache.http.util.TextUtils;
/**
*
@@ -105,6 +106,9 @@ public class LaxExpiresHandler extends AbstractCookieAttributeHandler implements
@Override
public void parse(final SetCookie cookie, final String value) throws MalformedCookieException {
Args.notNull(cookie, "Cookie");
+ if (TextUtils.isBlank(value)) {
+ return;
+ }
final ParserCursor cursor = new ParserCursor(0, value.length());
final StringBuilder content = new StringBuilder();
@@ -205,10 +209,9 @@ public class LaxExpiresHandler extends AbstractCookieAttributeHandler implements
final char current = buf.charAt(i);
if (DELIMS.get(current)) {
break;
- } else {
- pos++;
- dst.append(current);
}
+ pos++;
+ dst.append(current);
}
cursor.updatePos(pos);
}
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/NetscapeDraftSpec.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/NetscapeDraftSpec.java
index a4a986b2d..216af3e77 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/NetscapeDraftSpec.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/NetscapeDraftSpec.java
@@ -39,7 +39,6 @@ import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.cookie.CommonCookieAttributeHandler;
import com.fr.third.org.apache.http.cookie.Cookie;
import com.fr.third.org.apache.http.cookie.CookieOrigin;
-import com.fr.third.org.apache.http.cookie.CookieSpec;
import com.fr.third.org.apache.http.cookie.MalformedCookieException;
import com.fr.third.org.apache.http.cookie.SM;
import com.fr.third.org.apache.http.message.BufferedHeader;
@@ -48,15 +47,15 @@ import com.fr.third.org.apache.http.util.Args;
import com.fr.third.org.apache.http.util.CharArrayBuffer;
/**
- * This {@link CookieSpec} implementation conforms to
+ * This {@link com.fr.third.org.apache.http.cookie.CookieSpec} implementation conforms to
* the original draft specification published by Netscape Communications.
* It should be avoided unless absolutely necessary for compatibility with
* legacy applications.
*
- * Rendered obsolete by {@link RFC6265LaxSpec}.
+ * Rendered obsolete by {@link com.fr.third.org.apache.http.impl.cookie.RFC6265LaxSpec}.
*
* @since 4.0
- * @see RFC6265LaxSpec
+ * @see com.fr.third.org.apache.http.impl.cookie.RFC6265LaxSpec
*/
@Obsolete
@Contract(threading = ThreadingBehavior.SAFE)
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/NetscapeDraftSpecProvider.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/NetscapeDraftSpecProvider.java
index 2c87d1f43..8314e5ece 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/NetscapeDraftSpecProvider.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/NetscapeDraftSpecProvider.java
@@ -35,14 +35,14 @@ import com.fr.third.org.apache.http.cookie.CookieSpecProvider;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
- * {@link CookieSpecProvider} implementation that provides an instance of
+ * {@link com.fr.third.org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
* {@link NetscapeDraftSpec}. The instance returned by this factory
* can be shared by multiple threads.
*
- * Rendered obsolete by {@link RFC6265CookieSpecProvider}
+ * Rendered obsolete by {@link com.fr.third.org.apache.http.impl.cookie.RFC6265CookieSpecProvider}
*
* @since 4.4
- * @see RFC6265CookieSpecProvider
+ * @see com.fr.third.org.apache.http.impl.cookie.RFC6265CookieSpecProvider
*/
@Obsolete
@Contract(threading = ThreadingBehavior.IMMUTABLE)
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/PublicSuffixDomainFilter.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/PublicSuffixDomainFilter.java
index 4dba85693..d0c5cb5a8 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/PublicSuffixDomainFilter.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/PublicSuffixDomainFilter.java
@@ -35,20 +35,19 @@ import com.fr.third.org.apache.http.conn.util.PublicSuffixList;
import com.fr.third.org.apache.http.conn.util.PublicSuffixMatcher;
import com.fr.third.org.apache.http.cookie.CommonCookieAttributeHandler;
import com.fr.third.org.apache.http.cookie.Cookie;
-import com.fr.third.org.apache.http.cookie.CookieAttributeHandler;
import com.fr.third.org.apache.http.cookie.CookieOrigin;
import com.fr.third.org.apache.http.cookie.MalformedCookieException;
import com.fr.third.org.apache.http.cookie.SetCookie;
import com.fr.third.org.apache.http.util.Args;
/**
- * Wraps a {@link CookieAttributeHandler} and leverages its match method
+ * Wraps a {@link com.fr.third.org.apache.http.cookie.CookieAttributeHandler} and leverages its match method
* to never match a suffix from a black list. May be used to provide additional security for
* cross-site attack types by preventing cookies from apparent domains that are not publicly
* available.
*
- * @see PublicSuffixList
- * @see PublicSuffixMatcher
+ * @see com.fr.third.org.apache.http.conn.util.PublicSuffixList
+ * @see com.fr.third.org.apache.http.conn.util.PublicSuffixMatcher
*
* @since 4.4
*/
@@ -91,6 +90,9 @@ public class PublicSuffixDomainFilter implements CommonCookieAttributeHandler {
@Override
public boolean match(final Cookie cookie, final CookieOrigin origin) {
final String host = cookie.getDomain();
+ if (host == null) {
+ return false;
+ }
final int i = host.indexOf('.');
if (i >= 0) {
final String domain = host.substring(i);
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/RFC2109Spec.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/RFC2109Spec.java
index 651849df7..4f945c361 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/RFC2109Spec.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/RFC2109Spec.java
@@ -43,7 +43,6 @@ import com.fr.third.org.apache.http.cookie.Cookie;
import com.fr.third.org.apache.http.cookie.CookieOrigin;
import com.fr.third.org.apache.http.cookie.CookiePathComparator;
import com.fr.third.org.apache.http.cookie.CookieRestrictionViolationException;
-import com.fr.third.org.apache.http.cookie.CookieSpec;
import com.fr.third.org.apache.http.cookie.MalformedCookieException;
import com.fr.third.org.apache.http.cookie.SM;
import com.fr.third.org.apache.http.message.BufferedHeader;
@@ -51,12 +50,12 @@ import com.fr.third.org.apache.http.util.Args;
import com.fr.third.org.apache.http.util.CharArrayBuffer;
/**
- * RFC 2109 compliant {@link CookieSpec} implementation.
+ * RFC 2109 compliant {@link com.fr.third.org.apache.http.cookie.CookieSpec} implementation.
*
- * Rendered obsolete by {@link RFC6265StrictSpec}.
+ * Rendered obsolete by {@link com.fr.third.org.apache.http.impl.cookie.RFC6265StrictSpec}.
*
* @since 4.0
- * @see RFC6265StrictSpec
+ * @see com.fr.third.org.apache.http.impl.cookie.RFC6265StrictSpec
*/
@Obsolete
@Contract(threading = ThreadingBehavior.SAFE)
@@ -136,7 +135,7 @@ public class RFC2109Spec extends CookieSpecBase {
@Override
public List formatCookies(final List cookies) {
Args.notEmpty(cookies, "List of cookies");
- List cookieList;
+ final List cookieList;
if (cookies.size() > 1) {
// Create a mutable copy and sort the copy.
cookieList = new ArrayList(cookies);
@@ -144,11 +143,7 @@ public class RFC2109Spec extends CookieSpecBase {
} else {
cookieList = cookies;
}
- if (this.oneHeader) {
- return doFormatOneHeader(cookieList);
- } else {
- return doFormatManyHeaders(cookieList);
- }
+ return this.oneHeader ? doFormatOneHeader(cookieList) : doFormatManyHeaders(cookieList);
}
private List doFormatOneHeader(final List cookies) {
diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/RFC2109SpecProvider.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/RFC2109SpecProvider.java
index b4507952b..a6a562176 100644
--- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/RFC2109SpecProvider.java
+++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/impl/cookie/RFC2109SpecProvider.java
@@ -36,14 +36,14 @@ import com.fr.third.org.apache.http.cookie.CookieSpecProvider;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
- * {@link CookieSpecProvider} implementation that provides an instance of
+ * {@link com.fr.third.org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
* {@link RFC2109Spec}. The instance returned by this factory
* can be shared by multiple threads.
*
*
* @since 4.0
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java
index a3186849d..1f0113b29 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/AsyncNHttpServiceHandler.java
@@ -42,8 +42,8 @@ import com.fr.third.org.apache.http.MethodNotSupportedException;
import com.fr.third.org.apache.http.ProtocolException;
import com.fr.third.org.apache.http.ProtocolVersion;
import com.fr.third.org.apache.http.UnsupportedHttpVersionException;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.nio.ContentDecoder;
import com.fr.third.org.apache.http.nio.ContentEncoder;
import com.fr.third.org.apache.http.nio.IOControl;
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestExecutionHandler.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestExecutionHandler.java
index 5c895560a..aa5f50d8f 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestExecutionHandler.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestExecutionHandler.java
@@ -61,7 +61,7 @@ public class BasicAsyncRequestExecutionHandler implements HttpAsyncRequestExe
private final HttpAsyncResponseConsumer responseConsumer;
private final BasicFuture future;
private final HttpContext localContext;
- private final HttpProcessor httppocessor;
+ private final HttpProcessor httpPocessor;
private final ConnectionReuseStrategy reuseStrategy;
private volatile boolean requestSent;
@@ -71,21 +71,21 @@ public class BasicAsyncRequestExecutionHandler implements HttpAsyncRequestExe
final HttpAsyncResponseConsumer responseConsumer,
final FutureCallback callback,
final HttpContext localContext,
- final HttpProcessor httppocessor,
+ final HttpProcessor httpPocessor,
final ConnectionReuseStrategy reuseStrategy,
final HttpParams params) {
super();
Args.notNull(requestProducer, "Request producer");
Args.notNull(responseConsumer, "Response consumer");
Args.notNull(localContext, "HTTP context");
- Args.notNull(httppocessor, "HTTP processor");
+ Args.notNull(httpPocessor, "HTTP processor");
Args.notNull(reuseStrategy, "Connection reuse strategy");
Args.notNull(params, "HTTP parameters");
this.requestProducer = requestProducer;
this.responseConsumer = responseConsumer;
this.future = new BasicFuture(callback);
this.localContext = localContext;
- this.httppocessor = httppocessor;
+ this.httpPocessor = httpPocessor;
this.reuseStrategy = reuseStrategy;
}
@@ -93,10 +93,10 @@ public class BasicAsyncRequestExecutionHandler implements HttpAsyncRequestExe
final HttpAsyncRequestProducer requestProducer,
final HttpAsyncResponseConsumer responseConsumer,
final HttpContext localContext,
- final HttpProcessor httppocessor,
+ final HttpProcessor httpPocessor,
final ConnectionReuseStrategy reuseStrategy,
final HttpParams params) {
- this(requestProducer, responseConsumer, null, localContext, httppocessor, reuseStrategy, params);
+ this(requestProducer, responseConsumer, null, localContext, httpPocessor, reuseStrategy, params);
}
public Future getFuture() {
@@ -134,8 +134,8 @@ public class BasicAsyncRequestExecutionHandler implements HttpAsyncRequestExe
@Override
public void produceContent(
- final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
- this.requestProducer.produceContent(encoder, ioctrl);
+ final ContentEncoder encoder, final IOControl ioControl) throws IOException {
+ this.requestProducer.produceContent(encoder, ioControl);
}
@Override
@@ -160,8 +160,8 @@ public class BasicAsyncRequestExecutionHandler implements HttpAsyncRequestExe
@Override
public void consumeContent(
- final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
- this.responseConsumer.consumeContent(decoder, ioctrl);
+ final ContentDecoder decoder, final IOControl ioControl) throws IOException {
+ this.responseConsumer.consumeContent(decoder, ioControl);
}
@Override
@@ -228,7 +228,7 @@ public class BasicAsyncRequestExecutionHandler implements HttpAsyncRequestExe
@Override
public HttpProcessor getHttpProcessor() {
- return this.httppocessor;
+ return this.httpPocessor;
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/BufferingHttpClientHandler.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
index 92ec88b8e..c533c0f09 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/BufferingHttpClientHandler.java
@@ -30,12 +30,11 @@ package com.fr.third.org.apache.http.nio.protocol;
import java.io.IOException;
import com.fr.third.org.apache.http.ConnectionReuseStrategy;
-import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.nio.ContentDecoder;
import com.fr.third.org.apache.http.nio.ContentEncoder;
import com.fr.third.org.apache.http.nio.NHttpClientConnection;
@@ -57,7 +56,7 @@ import com.fr.third.org.apache.http.protocol.HttpProcessor;
* take place the main I/O thread and therefore
* {@link HttpRequestExecutionHandler} methods should not block indefinitely.
*
- * When using this protocol handler {@link HttpEntity}'s content
+ * When using this protocol handler {@link com.fr.third.org.apache.http.HttpEntity}'s content
* can be generated / consumed using standard {@link java.io.InputStream}/
* {@link java.io.OutputStream} classes.
*
- * When using this protocol handler {@link HttpEntity}'s content
+ * When using this protocol handler {@link com.fr.third.org.apache.http.HttpEntity}'s content
* can be generated / consumed using standard {@link java.io.InputStream}/
* {@link java.io.OutputStream} classes.
*
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestExecutionHandler.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestExecutionHandler.java
index 5eb728a8a..2e6165247 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestExecutionHandler.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestExecutionHandler.java
@@ -28,9 +28,6 @@
package com.fr.third.org.apache.http.nio.protocol;
import com.fr.third.org.apache.http.ConnectionReuseStrategy;
-import com.fr.third.org.apache.http.nio.protocol.HttpAsyncClientExchangeHandler;
-import com.fr.third.org.apache.http.nio.protocol.HttpAsyncRequestProducer;
-import com.fr.third.org.apache.http.nio.protocol.HttpAsyncResponseConsumer;
import com.fr.third.org.apache.http.protocol.HttpContext;
import com.fr.third.org.apache.http.protocol.HttpProcessor;
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestHandlerRegistry.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestHandlerRegistry.java
index 80d7b81cd..de16a4d4f 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestHandlerRegistry.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestHandlerRegistry.java
@@ -29,11 +29,8 @@ package com.fr.third.org.apache.http.nio.protocol;
import java.util.Map;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
-import com.fr.third.org.apache.http.nio.protocol.HttpAsyncRequestHandler;
-import com.fr.third.org.apache.http.nio.protocol.HttpAsyncRequestHandlerResolver;
-import com.fr.third.org.apache.http.nio.protocol.UriHttpAsyncRequestHandlerMapper;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.protocol.UriPatternMatcher;
/**
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/HttpRequestExecutionHandler.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/HttpRequestExecutionHandler.java
index a57f414d7..b7f141314 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/HttpRequestExecutionHandler.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/HttpRequestExecutionHandler.java
@@ -31,9 +31,6 @@ import java.io.IOException;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
-import com.fr.third.org.apache.http.nio.protocol.HttpAsyncRequestExecutor;
-import com.fr.third.org.apache.http.nio.protocol.HttpAsyncRequester;
-import com.fr.third.org.apache.http.nio.reactor.ConnectingIOReactor;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
@@ -57,7 +54,7 @@ public interface HttpRequestExecutionHandler {
* made. The attachment may optionally contain some state information
* required in order to correctly initialize the HTTP context.
*
- * @see ConnectingIOReactor#connect
+ * @see com.fr.third.org.apache.http.nio.reactor.ConnectingIOReactor#connect
*
* @param context the actual HTTP context
* @param attachment the object passed to the connecting I/O reactor
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/NHttpRequestExecutionHandler.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/NHttpRequestExecutionHandler.java
index 7243ad98d..f663c2a50 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/NHttpRequestExecutionHandler.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/NHttpRequestExecutionHandler.java
@@ -32,8 +32,6 @@ import java.io.IOException;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.nio.entity.ConsumingNHttpEntity;
-import com.fr.third.org.apache.http.nio.entity.ProducingNHttpEntity;
-import com.fr.third.org.apache.http.nio.reactor.ConnectingIOReactor;
import com.fr.third.org.apache.http.protocol.HttpContext;
/**
@@ -61,7 +59,7 @@ public interface NHttpRequestExecutionHandler {
* made. The attachment may optionally contain some state information
* required in order to correctly initalize the HTTP context.
*
- * @see ConnectingIOReactor#connect
+ * @see com.fr.third.org.apache.http.nio.reactor.ConnectingIOReactor#connect
*
* @param context the actual HTTP context
* @param attachment the object passed to the connecting I/O reactor
@@ -77,7 +75,7 @@ public interface NHttpRequestExecutionHandler {
* can be activated at a later point.
*
* If the request has an entity, the entity must be an
- * instance of {@link ProducingNHttpEntity}.
+ * instance of {@link com.fr.third.org.apache.http.nio.entity.ProducingNHttpEntity}.
*
* @param context the actual HTTP context
* @return an HTTP request to be sent or {@code null} if no
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/NHttpResponseTrigger.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/NHttpResponseTrigger.java
index ba1c83780..527af9446 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/NHttpResponseTrigger.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/NHttpResponseTrigger.java
@@ -29,15 +29,13 @@ package com.fr.third.org.apache.http.nio.protocol;
import java.io.IOException;
-import com.fr.third.org.apache.http.HttpRequest;
-import com.fr.third.org.apache.http.protocol.HttpContext;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpResponse;
/**
* Callback interface to submit HTTP responses asynchronously.
*
- * The {@link NHttpRequestHandler#handle(HttpRequest, HttpResponse, NHttpResponseTrigger, HttpContext)}
+ * The {@link NHttpRequestHandler#handle(org.apache.http.HttpRequest, HttpResponse, NHttpResponseTrigger, com.fr.third.org.apache.http.protocol.HttpContext)}
* method does not have to submit a response immediately. It can defer
* transmission of the HTTP response back to the client without blocking the
* I/O thread by delegating the process of handling the HTTP request to a worker
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/NullNHttpEntity.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/NullNHttpEntity.java
index ef4a09b32..be55e6861 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/NullNHttpEntity.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/NullNHttpEntity.java
@@ -69,7 +69,7 @@ class NullNHttpEntity extends HttpEntityWrapper implements ConsumingNHttpEntity
@Override
public void consumeContent(
final ContentDecoder decoder,
- final IOControl ioctrl) throws IOException {
+ final IOControl ioControl) throws IOException {
int lastRead;
do {
buffer.clear();
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/SimpleNHttpRequestHandler.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/SimpleNHttpRequestHandler.java
index 5b7b62595..a9c50badd 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/SimpleNHttpRequestHandler.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/SimpleNHttpRequestHandler.java
@@ -27,13 +27,13 @@
package com.fr.third.org.apache.http.nio.protocol;
+import java.io.IOException;
+
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.protocol.HttpContext;
-import java.io.IOException;
-
/**
* A simple implementation of {@link NHttpRequestHandler} that abstracts away
* the need to use {@link NHttpResponseTrigger}. Implementations need only to
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java
index 6c8d2c30b..99967bd0f 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java-deprecated/com/fr/third/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java
@@ -38,8 +38,8 @@ import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.HttpStatus;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.nio.ContentDecoder;
import com.fr.third.org.apache.http.nio.ContentEncoder;
import com.fr.third.org.apache.http.nio.IOControl;
@@ -90,8 +90,8 @@ import com.fr.third.org.apache.http.util.Args;
* The following parameters can be used to customize the behavior of this
* class:
*
*
* @since 4.0
@@ -588,12 +587,12 @@ public class ThrottlingHttpServiceHandler extends NHttpHandlerBase
if (response.getEntity() != null) {
final ContentOutputBuffer buffer = connState.getOutbuffer();
- final OutputStream outstream = new ContentOutputStream(buffer);
+ final OutputStream outStream = new ContentOutputStream(buffer);
final HttpEntity entity = response.getEntity();
- entity.writeTo(outstream);
- outstream.flush();
- outstream.close();
+ entity.writeTo(outStream);
+ outStream.flush();
+ outStream.close();
}
synchronized (connState) {
@@ -643,7 +642,7 @@ public class ThrottlingHttpServiceHandler extends NHttpHandlerBase
public static final int RESPONSE_BODY_DONE = 32;
public static final int RESPONSE_DONE = 32;
- private final SharedInputBuffer inbuffer;
+ private final SharedInputBuffer inBuffer;
private final SharedOutputBuffer outbuffer;
private volatile int inputState;
@@ -659,14 +658,14 @@ public class ThrottlingHttpServiceHandler extends NHttpHandlerBase
final IOControl ioControl,
final ByteBufferAllocator allocator) {
super();
- this.inbuffer = new SharedInputBuffer(bufsize, ioControl, allocator);
+ this.inBuffer = new SharedInputBuffer(bufsize, ioControl, allocator);
this.outbuffer = new SharedOutputBuffer(bufsize, ioControl, allocator);
this.inputState = READY;
this.outputState = READY;
}
public ContentInputBuffer getInbuffer() {
- return this.inbuffer;
+ return this.inBuffer;
}
public ContentOutputBuffer getOutbuffer() {
@@ -714,21 +713,21 @@ public class ThrottlingHttpServiceHandler extends NHttpHandlerBase
}
public void close() {
- this.inbuffer.close();
+ this.inBuffer.close();
this.outbuffer.close();
this.inputState = SHUTDOWN;
this.outputState = SHUTDOWN;
}
public void shutdown() {
- this.inbuffer.shutdown();
+ this.inBuffer.shutdown();
this.outbuffer.shutdown();
this.inputState = SHUTDOWN;
this.outputState = SHUTDOWN;
}
public void resetInput() {
- this.inbuffer.reset();
+ this.inBuffer.reset();
this.request = null;
this.inputState = READY;
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultHttpClientIODispatch.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultHttpClientIODispatch.java
index 5d39f8553..3ee048002 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultHttpClientIODispatch.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultHttpClientIODispatch.java
@@ -27,15 +27,13 @@
package com.fr.third.org.apache.http.impl.nio;
-import java.io.IOException;
-
import javax.net.ssl.SSLContext;
+import java.io.IOException;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.config.ConnectionConfig;
import com.fr.third.org.apache.http.impl.nio.reactor.AbstractIODispatch;
-import com.fr.third.org.apache.http.nio.reactor.IOEventDispatch;
import com.fr.third.org.apache.http.nio.NHttpClientEventHandler;
import com.fr.third.org.apache.http.nio.NHttpConnectionFactory;
import com.fr.third.org.apache.http.nio.reactor.IOSession;
@@ -44,19 +42,56 @@ import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
/**
- * Default {@link IOEventDispatch} implementation
+ * Default {@link com.fr.third.org.apache.http.nio.reactor.IOEventDispatch} implementation
* that supports both plain (non-encrypted) and SSL encrypted client side HTTP
* connections.
+ * @param an implementation of {@link NHttpClientEventHandler}.
*
* @since 4.2
*/
@SuppressWarnings("deprecation")
@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
-public class DefaultHttpClientIODispatch
+public class DefaultHttpClientIODispatch
extends AbstractIODispatch {
- private final NHttpClientEventHandler handler;
- private final NHttpConnectionFactory connFactory;
+ /**
+ * Creates a new instance of this class to be used for dispatching I/O event
+ * notifications to the given protocol handler.
+ *
+ * @param handler the client protocol handler.
+ * @param sslContext an SSLContext or null (for a plain text connection.)
+ * @param config a connection configuration
+ * @return a new instance
+ * @since 4.4.7
+ */
+ public static DefaultHttpClientIODispatch create(final T handler,
+ final SSLContext sslContext,
+ final ConnectionConfig config) {
+ return sslContext == null ? new DefaultHttpClientIODispatch(handler, config)
+ : new DefaultHttpClientIODispatch(handler, sslContext, config);
+ }
+
+ /**
+ * Creates a new instance of this class to be used for dispatching I/O event
+ * notifications to the given protocol handler.
+ *
+ * @param handler the client protocol handler.
+ * @param sslContext an SSLContext or null (for a plain text connection.)
+ * @param sslHandler customizes various aspects of the TLS/SSL protocol.
+ * @param config a connection configuration
+ * @return a new instance
+ * @since 4.4.7
+ */
+ public static DefaultHttpClientIODispatch create(final T handler,
+ final SSLContext sslContext,
+ final SSLSetupHandler sslHandler,
+ final ConnectionConfig config) {
+ return sslContext == null ? new DefaultHttpClientIODispatch(handler, config)
+ : new DefaultHttpClientIODispatch(handler, sslContext, sslHandler, config);
+ }
+
+ private final H handler;
+ private final NHttpConnectionFactory extends DefaultNHttpClientConnection> connectionFactory;
/**
* Creates a new instance of this class to be used for dispatching I/O event
@@ -66,11 +101,11 @@ public class DefaultHttpClientIODispatch
* @param connFactory HTTP client connection factory.
*/
public DefaultHttpClientIODispatch(
- final NHttpClientEventHandler handler,
- final NHttpConnectionFactory connFactory) {
+ final H handler,
+ final NHttpConnectionFactory extends DefaultNHttpClientConnection> connFactory) {
super();
this.handler = Args.notNull(handler, "HTTP client handler");
- this.connFactory = Args.notNull(connFactory, "HTTP client connection factory");
+ this.connectionFactory = Args.notNull(connFactory, "HTTP client connection factory");
}
/**
@@ -79,7 +114,7 @@ public class DefaultHttpClientIODispatch
*/
@Deprecated
public DefaultHttpClientIODispatch(
- final NHttpClientEventHandler handler,
+ final H handler,
final HttpParams params) {
this(handler, new DefaultNHttpClientConnectionFactory(params));
}
@@ -90,11 +125,11 @@ public class DefaultHttpClientIODispatch
*/
@Deprecated
public DefaultHttpClientIODispatch(
- final NHttpClientEventHandler handler,
- final SSLContext sslcontext,
+ final H handler,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final HttpParams params) {
- this(handler, new SSLNHttpClientConnectionFactory(sslcontext, sslHandler, params));
+ this(handler, new SSLNHttpClientConnectionFactory(sslContext, sslHandler, params));
}
/**
@@ -103,16 +138,16 @@ public class DefaultHttpClientIODispatch
*/
@Deprecated
public DefaultHttpClientIODispatch(
- final NHttpClientEventHandler handler,
- final SSLContext sslcontext,
+ final H handler,
+ final SSLContext sslContext,
final HttpParams params) {
- this(handler, sslcontext, null, params);
+ this(handler, sslContext, null, params);
}
/**
* @since 4.3
*/
- public DefaultHttpClientIODispatch(final NHttpClientEventHandler handler, final ConnectionConfig config) {
+ public DefaultHttpClientIODispatch(final H handler, final ConnectionConfig config) {
this(handler, new DefaultNHttpClientConnectionFactory(config));
}
@@ -120,26 +155,46 @@ public class DefaultHttpClientIODispatch
* @since 4.3
*/
public DefaultHttpClientIODispatch(
- final NHttpClientEventHandler handler,
- final SSLContext sslcontext,
+ final H handler,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final ConnectionConfig config) {
- this(handler, new SSLNHttpClientConnectionFactory(sslcontext, sslHandler, config));
+ this(handler, new SSLNHttpClientConnectionFactory(sslContext, sslHandler, config));
}
/**
* @since 4.3
*/
public DefaultHttpClientIODispatch(
- final NHttpClientEventHandler handler,
- final SSLContext sslcontext,
+ final H handler,
+ final SSLContext sslContext,
final ConnectionConfig config) {
- this(handler, new SSLNHttpClientConnectionFactory(sslcontext, null, config));
+ this(handler, new SSLNHttpClientConnectionFactory(sslContext, null, config));
}
@Override
protected DefaultNHttpClientConnection createConnection(final IOSession session) {
- return this.connFactory.createConnection(session);
+ return this.connectionFactory.createConnection(session);
+ }
+
+ /**
+ * Gets the connection factory used to construct this dispatch.
+ *
+ * @return the connection factory used to construct this dispatch.
+ * @since 4.4.9
+ */
+ public NHttpConnectionFactory extends DefaultNHttpClientConnection> getConnectionFactory() {
+ return connectionFactory;
+ }
+
+ /**
+ * Gets the handler used to construct this dispatch.
+ *
+ * @return the handler used to construct this dispatch.
+ * @since 4.4.9
+ */
+ public H getHandler() {
+ return handler;
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultHttpServerIODispatch.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultHttpServerIODispatch.java
index aa4d6bcf6..2eb762e41 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultHttpServerIODispatch.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultHttpServerIODispatch.java
@@ -27,16 +27,18 @@
package com.fr.third.org.apache.http.impl.nio;
-import java.io.IOException;
-
import javax.net.ssl.SSLContext;
+import java.io.IOException;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
+import com.fr.third.org.apache.http.HttpRequest;
+import com.fr.third.org.apache.http.HttpRequestFactory;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.config.ConnectionConfig;
+import com.fr.third.org.apache.http.impl.nio.codecs.DefaultHttpRequestParserFactory;
import com.fr.third.org.apache.http.impl.nio.reactor.AbstractIODispatch;
-import com.fr.third.org.apache.http.nio.reactor.IOEventDispatch;
import com.fr.third.org.apache.http.nio.NHttpConnectionFactory;
+import com.fr.third.org.apache.http.nio.NHttpMessageParserFactory;
import com.fr.third.org.apache.http.nio.NHttpServerEventHandler;
import com.fr.third.org.apache.http.nio.reactor.IOSession;
import com.fr.third.org.apache.http.nio.reactor.ssl.SSLSetupHandler;
@@ -44,26 +46,87 @@ import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
/**
- * Default {@link IOEventDispatch} implementation
+ * Default {@link com.fr.third.org.apache.http.nio.reactor.IOEventDispatch} implementation
* that supports both plain (non-encrypted) and SSL encrypted server side HTTP
* connections.
+ * @param an implementation of {@link NHttpServerEventHandler}.
*
* @since 4.2
*/
@SuppressWarnings("deprecation")
@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
-public class DefaultHttpServerIODispatch
+public class DefaultHttpServerIODispatch
extends AbstractIODispatch {
- private final NHttpServerEventHandler handler;
- private final NHttpConnectionFactory extends DefaultNHttpServerConnection> connFactory;
+ /**
+ * Creates a new instance of this class to be used for dispatching I/O event
+ * notifications to the given protocol handler.
+ *
+ * @param handler the server protocol handler.
+ * @param sslContext an SSLContext or null (for a plain text connection.)
+ * @param config a connection configuration
+ * @return a new instance
+ * @since 4.4.7
+ */
+ public static DefaultHttpServerIODispatch create(final T handler,
+ final SSLContext sslContext,
+ final ConnectionConfig config) {
+ return sslContext == null ? new DefaultHttpServerIODispatch(handler, config)
+ : new DefaultHttpServerIODispatch(handler, sslContext, config);
+ }
+
+ /**
+ * Creates a new instance of this class to be used for dispatching I/O event
+ * notifications to the given protocol handler.
+ *
+ * @param eventHandler the server protocol handler.
+ * @param sslContext an SSLContext or null (for a plain text connection.)
+ * @param config a connection configuration
+ * @param httpRequestFactory the request factory used by this object to generate {@link HttpRequest} instances.
+ * @return a new instance
+ * @since 4.4.10
+ */
+ public static DefaultHttpServerIODispatch create(final T eventHandler,
+ final SSLContext sslContext, final ConnectionConfig config, final HttpRequestFactory httpRequestFactory) {
+ final NHttpMessageParserFactory httpRequestParserFactory = new DefaultHttpRequestParserFactory(
+ null, httpRequestFactory);
+ // @formatter:off
+ return sslContext == null
+ ? new DefaultHttpServerIODispatch(eventHandler,
+ new DefaultNHttpServerConnectionFactory(null, httpRequestParserFactory, null, config))
+ : new DefaultHttpServerIODispatch(eventHandler,
+ new SSLNHttpServerConnectionFactory(sslContext, null, httpRequestParserFactory, null, config));
+ // @formatter:om
+ }
+
+ /**
+ * Creates a new instance of this class to be used for dispatching I/O event
+ * notifications to the given protocol handler.
+ *
+ * @param handler the server protocol handler.
+ * @param sslContext an SSLContext or null (for a plain text connection.)
+ * @param sslHandler customizes various aspects of the TLS/SSL protocol.
+ * @param config a connection configuration
+ * @return a new instance
+ * @since 4.4.7
+ */
+ public static DefaultHttpServerIODispatch create(final T handler,
+ final SSLContext sslContext,
+ final SSLSetupHandler sslHandler,
+ final ConnectionConfig config) {
+ return sslContext == null ? new DefaultHttpServerIODispatch(handler, config)
+ : new DefaultHttpServerIODispatch(handler, sslContext, sslHandler, config);
+ }
+
+ private final H handler;
+ private final NHttpConnectionFactory extends DefaultNHttpServerConnection> connectionFactory;
public DefaultHttpServerIODispatch(
- final NHttpServerEventHandler handler,
+ final H handler,
final NHttpConnectionFactory extends DefaultNHttpServerConnection> connFactory) {
super();
- this.handler = Args.notNull(handler, "HTTP client handler");
- this.connFactory = Args.notNull(connFactory, "HTTP server connection factory");
+ this.handler = Args.notNull(handler, "HTTP server handler");
+ this.connectionFactory = Args.notNull(connFactory, "HTTP server connection factory");
}
/**
@@ -72,7 +135,7 @@ public class DefaultHttpServerIODispatch
*/
@Deprecated
public DefaultHttpServerIODispatch(
- final NHttpServerEventHandler handler,
+ final H handler,
final HttpParams params) {
this(handler, new DefaultNHttpServerConnectionFactory(params));
}
@@ -83,11 +146,11 @@ public class DefaultHttpServerIODispatch
*/
@Deprecated
public DefaultHttpServerIODispatch(
- final NHttpServerEventHandler handler,
- final SSLContext sslcontext,
+ final H handler,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final HttpParams params) {
- this(handler, new SSLNHttpServerConnectionFactory(sslcontext, sslHandler, params));
+ this(handler, new SSLNHttpServerConnectionFactory(sslContext, sslHandler, params));
}
/**
@@ -96,16 +159,16 @@ public class DefaultHttpServerIODispatch
*/
@Deprecated
public DefaultHttpServerIODispatch(
- final NHttpServerEventHandler handler,
- final SSLContext sslcontext,
+ final H handler,
+ final SSLContext sslContext,
final HttpParams params) {
- this(handler, sslcontext, null, params);
+ this(handler, sslContext, null, params);
}
/**
* @since 4.3
*/
- public DefaultHttpServerIODispatch(final NHttpServerEventHandler handler, final ConnectionConfig config) {
+ public DefaultHttpServerIODispatch(final H handler, final ConnectionConfig config) {
this(handler, new DefaultNHttpServerConnectionFactory(config));
}
@@ -113,26 +176,46 @@ public class DefaultHttpServerIODispatch
* @since 4.3
*/
public DefaultHttpServerIODispatch(
- final NHttpServerEventHandler handler,
- final SSLContext sslcontext,
+ final H handler,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final ConnectionConfig config) {
- this(handler, new SSLNHttpServerConnectionFactory(sslcontext, sslHandler, config));
+ this(handler, new SSLNHttpServerConnectionFactory(sslContext, sslHandler, config));
}
/**
* @since 4.3
*/
public DefaultHttpServerIODispatch(
- final NHttpServerEventHandler handler,
- final SSLContext sslcontext,
+ final H handler,
+ final SSLContext sslContext,
final ConnectionConfig config) {
- this(handler, new SSLNHttpServerConnectionFactory(sslcontext, null, config));
+ this(handler, new SSLNHttpServerConnectionFactory(sslContext, null, config));
}
@Override
protected DefaultNHttpServerConnection createConnection(final IOSession session) {
- return this.connFactory.createConnection(session);
+ return this.connectionFactory.createConnection(session);
+ }
+
+ /**
+ * Gets the connection factory used to construct this dispatch.
+ *
+ * @return the connection factory used to construct this dispatch.
+ * @since 4.4.9
+ */
+ public NHttpConnectionFactory extends DefaultNHttpServerConnection> getConnectionFactory() {
+ return connectionFactory;
+ }
+
+ /**
+ * Gets the handler used to construct this dispatch.
+ *
+ * @return the handler used to construct this dispatch.
+ * @since 4.4.9
+ */
+ public H getHandler() {
+ return handler;
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpClientConnection.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
index 4525ca6c6..586bd296e 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpClientConnection.java
@@ -32,8 +32,6 @@ import java.nio.channels.SelectionKey;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
-import com.fr.third.org.apache.http.impl.entity.LaxContentLengthStrategy;
-import com.fr.third.org.apache.http.impl.entity.StrictContentLengthStrategy;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpEntityEnclosingRequest;
import com.fr.third.org.apache.http.HttpException;
@@ -46,8 +44,6 @@ import com.fr.third.org.apache.http.impl.nio.codecs.DefaultHttpRequestWriter;
import com.fr.third.org.apache.http.impl.nio.codecs.DefaultHttpRequestWriterFactory;
import com.fr.third.org.apache.http.impl.nio.codecs.DefaultHttpResponseParser;
import com.fr.third.org.apache.http.impl.nio.codecs.DefaultHttpResponseParserFactory;
-import com.fr.third.org.apache.http.nio.NHttpClientConnection;
-import com.fr.third.org.apache.http.nio.util.HeapByteBufferAllocator;
import com.fr.third.org.apache.http.nio.NHttpClientEventHandler;
import com.fr.third.org.apache.http.nio.NHttpClientHandler;
import com.fr.third.org.apache.http.nio.NHttpClientIOTarget;
@@ -65,7 +61,7 @@ import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
/**
- * Default implementation of the {@link NHttpClientConnection}
+ * Default implementation of the {@link com.fr.third.org.apache.http.nio.NHttpClientConnection}
* interface.
*
* @since 4.0
@@ -109,37 +105,37 @@ public class DefaultNHttpClientConnection
* Creates new instance DefaultNHttpClientConnection given the underlying I/O session.
*
* @param session the underlying I/O session.
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param allocator memory allocator.
- * If {@code null} {@link HeapByteBufferAllocator#INSTANCE}
+ * If {@code null} {@link com.fr.third.org.apache.http.nio.util.HeapByteBufferAllocator#INSTANCE}
* will be used.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
* @param incomingContentStrategy incoming content length strategy. If {@code null}
- * {@link LaxContentLengthStrategy#INSTANCE} will be used.
+ * {@link com.fr.third.org.apache.http.impl.entity.LaxContentLengthStrategy#INSTANCE} will be used.
* @param outgoingContentStrategy outgoing content length strategy. If {@code null}
- * {@link StrictContentLengthStrategy#INSTANCE} will be used.
+ * {@link com.fr.third.org.apache.http.impl.entity.StrictContentLengthStrategy#INSTANCE} will be used.
*
* @since 4.3
*/
public DefaultNHttpClientConnection(
final IOSession session,
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
final ByteBufferAllocator allocator,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final NHttpMessageWriterFactory requestWriterFactory,
final NHttpMessageParserFactory responseParserFactory) {
- super(session, buffersize, fragmentSizeHint, allocator, chardecoder, charencoder,
+ super(session, bufferSize, fragmentSizeHint, allocator, charDecoder, charEncoder,
constraints, incomingContentStrategy, outgoingContentStrategy);
this.requestWriter = (requestWriterFactory != null ? requestWriterFactory :
DefaultHttpRequestWriterFactory.INSTANCE).create(this.outbuf);
@@ -152,19 +148,19 @@ public class DefaultNHttpClientConnection
*/
public DefaultNHttpClientConnection(
final IOSession session,
- final int buffersize,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final int bufferSize,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints) {
- this(session, buffersize, buffersize, null, chardecoder, charencoder, constraints,
+ this(session, bufferSize, bufferSize, null, charDecoder, charEncoder, constraints,
null, null, null, null);
}
/**
* @since 4.3
*/
- public DefaultNHttpClientConnection(final IOSession session, final int buffersize) {
- this(session, buffersize, buffersize, null, null, null, null, null, null, null, null);
+ public DefaultNHttpClientConnection(final IOSession session, final int bufferSize) {
+ this(session, bufferSize, bufferSize, null, null, null, null, null, null, null, null);
}
/**
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpClientConnectionFactory.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpClientConnectionFactory.java
index 9d3352989..27aeb568e 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpClientConnectionFactory.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpClientConnectionFactory.java
@@ -29,14 +29,13 @@ package com.fr.third.org.apache.http.impl.nio;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.HttpResponseFactory;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.config.ConnectionConfig;
import com.fr.third.org.apache.http.entity.ContentLengthStrategy;
import com.fr.third.org.apache.http.impl.ConnSupport;
import com.fr.third.org.apache.http.impl.DefaultHttpResponseFactory;
import com.fr.third.org.apache.http.impl.nio.codecs.DefaultHttpResponseParserFactory;
-import com.fr.third.org.apache.http.nio.NHttpClientConnection;
import com.fr.third.org.apache.http.nio.NHttpConnectionFactory;
import com.fr.third.org.apache.http.nio.NHttpMessageParserFactory;
import com.fr.third.org.apache.http.nio.NHttpMessageWriterFactory;
@@ -49,7 +48,7 @@ import com.fr.third.org.apache.http.util.Args;
/**
* Default factory for plain (non-encrypted), non-blocking
- * {@link NHttpClientConnection}s.
+ * {@link com.fr.third.org.apache.http.nio.NHttpClientConnection}s.
*
* @since 4.2
*/
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpServerConnection.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
index ae8cb31e0..0ddfc74f3 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpServerConnection.java
@@ -47,8 +47,6 @@ import com.fr.third.org.apache.http.impl.nio.codecs.DefaultHttpRequestParser;
import com.fr.third.org.apache.http.impl.nio.codecs.DefaultHttpRequestParserFactory;
import com.fr.third.org.apache.http.impl.nio.codecs.DefaultHttpResponseWriter;
import com.fr.third.org.apache.http.impl.nio.codecs.DefaultHttpResponseWriterFactory;
-import com.fr.third.org.apache.http.nio.NHttpServerConnection;
-import com.fr.third.org.apache.http.nio.util.HeapByteBufferAllocator;
import com.fr.third.org.apache.http.nio.NHttpMessageParser;
import com.fr.third.org.apache.http.nio.NHttpMessageParserFactory;
import com.fr.third.org.apache.http.nio.NHttpMessageWriter;
@@ -66,7 +64,7 @@ import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
/**
- * Default implementation of the {@link NHttpServerConnection}
+ * Default implementation of the {@link com.fr.third.org.apache.http.nio.NHttpServerConnection}
* interface.
*
* @since 4.0
@@ -107,14 +105,14 @@ public class DefaultNHttpServerConnection
* Creates new instance DefaultNHttpServerConnection given the underlying I/O session.
*
* @param session the underlying I/O session.
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param allocator memory allocator.
- * If {@code null} {@link HeapByteBufferAllocator#INSTANCE}
+ * If {@code null} {@link com.fr.third.org.apache.http.nio.util.HeapByteBufferAllocator#INSTANCE}
* will be used.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -131,17 +129,17 @@ public class DefaultNHttpServerConnection
*/
public DefaultNHttpServerConnection(
final IOSession session,
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
final ByteBufferAllocator allocator,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final NHttpMessageParserFactory requestParserFactory,
final NHttpMessageWriterFactory responseWriterFactory) {
- super(session, buffersize, fragmentSizeHint, allocator, chardecoder, charencoder,
+ super(session, bufferSize, fragmentSizeHint, allocator, charDecoder, charEncoder,
constraints,
incomingContentStrategy != null ? incomingContentStrategy :
DisallowIdentityContentLengthStrategy.INSTANCE,
@@ -158,19 +156,19 @@ public class DefaultNHttpServerConnection
*/
public DefaultNHttpServerConnection(
final IOSession session,
- final int buffersize,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final int bufferSize,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints) {
- this(session, buffersize, buffersize, null, chardecoder, charencoder, constraints,
+ this(session, bufferSize, bufferSize, null, charDecoder, charEncoder, constraints,
null, null, null, null);
}
/**
* @since 4.3
*/
- public DefaultNHttpServerConnection(final IOSession session, final int buffersize) {
- this(session, buffersize, buffersize, null, null, null, null, null, null, null, null);
+ public DefaultNHttpServerConnection(final IOSession session, final int bufferSize) {
+ this(session, bufferSize, bufferSize, null, null, null, null, null, null, null, null);
}
/**
@@ -292,7 +290,6 @@ public class DefaultNHttpServerConnection
}
}
} catch (final HttpException ex) {
- resetInput();
handler.exception(this, ex);
} catch (final Exception ex) {
handler.exception(this, ex);
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpServerConnectionFactory.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpServerConnectionFactory.java
index 7d88969ef..8abc14cbf 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpServerConnectionFactory.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/DefaultNHttpServerConnectionFactory.java
@@ -29,8 +29,8 @@ package com.fr.third.org.apache.http.impl.nio;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpRequestFactory;
import com.fr.third.org.apache.http.HttpResponse;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.config.ConnectionConfig;
import com.fr.third.org.apache.http.entity.ContentLengthStrategy;
import com.fr.third.org.apache.http.impl.ConnSupport;
@@ -39,7 +39,6 @@ import com.fr.third.org.apache.http.impl.nio.codecs.DefaultHttpRequestParserFact
import com.fr.third.org.apache.http.nio.NHttpConnectionFactory;
import com.fr.third.org.apache.http.nio.NHttpMessageParserFactory;
import com.fr.third.org.apache.http.nio.NHttpMessageWriterFactory;
-import com.fr.third.org.apache.http.nio.NHttpServerConnection;
import com.fr.third.org.apache.http.nio.reactor.IOSession;
import com.fr.third.org.apache.http.nio.util.ByteBufferAllocator;
import com.fr.third.org.apache.http.nio.util.HeapByteBufferAllocator;
@@ -49,7 +48,7 @@ import com.fr.third.org.apache.http.util.Args;
/**
* Default factory for plain (non-encrypted), non-blocking
- * {@link NHttpServerConnection}s.
+ * {@link com.fr.third.org.apache.http.nio.NHttpServerConnection}s.
*
* @since 4.2
*/
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/NHttpClientEventHandlerAdaptor.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/NHttpClientEventHandlerAdaptor.java
index f54afe07b..b10a6eba1 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/NHttpClientEventHandlerAdaptor.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/NHttpClientEventHandlerAdaptor.java
@@ -89,9 +89,8 @@ class NHttpClientEventHandlerAdaptor implements NHttpClientEventHandler {
} else {
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
- } else {
- throw new Error("Unexpected exception: ", ex);
}
+ throw new Error("Unexpected exception: ", ex);
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/NHttpConnectionBase.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/NHttpConnectionBase.java
index 1e882c963..91e30adab 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/NHttpConnectionBase.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/NHttpConnectionBase.java
@@ -65,7 +65,6 @@ import com.fr.third.org.apache.http.impl.nio.codecs.LengthDelimitedEncoder;
import com.fr.third.org.apache.http.impl.nio.reactor.SessionInputBufferImpl;
import com.fr.third.org.apache.http.impl.nio.reactor.SessionOutputBufferImpl;
import com.fr.third.org.apache.http.io.HttpTransportMetrics;
-import com.fr.third.org.apache.http.nio.util.HeapByteBufferAllocator;
import com.fr.third.org.apache.http.nio.ContentDecoder;
import com.fr.third.org.apache.http.nio.ContentEncoder;
import com.fr.third.org.apache.http.nio.NHttpConnection;
@@ -139,13 +138,13 @@ public class NHttpConnectionBase
Args.notNull(session, "I/O session");
Args.notNull(params, "HTTP params");
- int buffersize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
- if (buffersize <= 0) {
- buffersize = 4096;
+ int bufferSize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
+ if (bufferSize <= 0) {
+ bufferSize = 4096;
}
- int linebuffersize = buffersize;
- if (linebuffersize > 512) {
- linebuffersize = 512;
+ int lineBufferSize = bufferSize;
+ if (lineBufferSize > 512) {
+ lineBufferSize = 512;
}
CharsetDecoder decoder = null;
@@ -163,9 +162,9 @@ public class NHttpConnectionBase
decoder.onMalformedInput(malformedCharAction).onUnmappableCharacter(unmappableCharAction);
encoder.onMalformedInput(malformedCharAction).onUnmappableCharacter(unmappableCharAction);
}
- this.inbuf = new SessionInputBufferImpl(buffersize, linebuffersize, decoder, allocator);
- this.outbuf = new SessionOutputBufferImpl(buffersize, linebuffersize, encoder, allocator);
- this.fragmentSizeHint = buffersize;
+ this.inbuf = new SessionInputBufferImpl(bufferSize, lineBufferSize, decoder, allocator);
+ this.outbuf = new SessionOutputBufferImpl(bufferSize, lineBufferSize, encoder, allocator);
+ this.fragmentSizeHint = bufferSize;
this.constraints = MessageConstraints.DEFAULT;
this.incomingContentStrategy = createIncomingContentStrategy();
@@ -185,14 +184,14 @@ public class NHttpConnectionBase
* Creates new instance NHttpConnectionBase given the underlying I/O session.
*
* @param session the underlying I/O session.
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param allocator memory allocator.
- * If {@code null} {@link HeapByteBufferAllocator#INSTANCE}
+ * If {@code null} {@link com.fr.third.org.apache.http.nio.util.HeapByteBufferAllocator#INSTANCE}
* will be used.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -205,23 +204,23 @@ public class NHttpConnectionBase
*/
protected NHttpConnectionBase(
final IOSession session,
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
final ByteBufferAllocator allocator,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
Args.notNull(session, "I/O session");
- Args.positive(buffersize, "Buffer size");
- int linebuffersize = buffersize;
- if (linebuffersize > 512) {
- linebuffersize = 512;
+ Args.positive(bufferSize, "Buffer size");
+ int lineBufferSize = bufferSize;
+ if (lineBufferSize > 512) {
+ lineBufferSize = 512;
}
- this.inbuf = new SessionInputBufferImpl(buffersize, linebuffersize, chardecoder, allocator);
- this.outbuf = new SessionOutputBufferImpl(buffersize, linebuffersize, charencoder, allocator);
- this.fragmentSizeHint = fragmentSizeHint >= 0 ? fragmentSizeHint : buffersize;
+ this.inbuf = new SessionInputBufferImpl(bufferSize, lineBufferSize, charDecoder, allocator);
+ this.outbuf = new SessionOutputBufferImpl(bufferSize, lineBufferSize, charEncoder, allocator);
+ this.fragmentSizeHint = fragmentSizeHint >= 0 ? fragmentSizeHint : bufferSize;
this.inTransportMetrics = new HttpTransportMetricsImpl();
this.outTransportMetrics = new HttpTransportMetricsImpl();
@@ -240,14 +239,14 @@ public class NHttpConnectionBase
* Creates new instance NHttpConnectionBase given the underlying I/O session.
*
* @param session the underlying I/O session.
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
* @param allocator memory allocator.
- * If {@code null} {@link HeapByteBufferAllocator#INSTANCE}
+ * If {@code null} {@link com.fr.third.org.apache.http.nio.util.HeapByteBufferAllocator#INSTANCE}
* will be used.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param incomingContentStrategy incoming content length strategy. If {@code null}
* {@link LaxContentLengthStrategy#INSTANCE} will be used.
@@ -258,14 +257,14 @@ public class NHttpConnectionBase
*/
protected NHttpConnectionBase(
final IOSession session,
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
final ByteBufferAllocator allocator,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
- this(session, buffersize, fragmentSizeHint, allocator, chardecoder, charencoder,
+ this(session, bufferSize, fragmentSizeHint, allocator, charDecoder, charEncoder,
null, incomingContentStrategy, outgoingContentStrategy);
}
@@ -366,7 +365,11 @@ public class NHttpConnectionBase
@Override
public void suspendOutput() {
- this.session.clearEvent(EventMask.WRITE);
+ synchronized (this.session) {
+ if (!this.outbuf.hasData()) {
+ this.session.clearEvent(EventMask.WRITE);
+ }
+ }
}
/**
@@ -496,7 +499,7 @@ public class NHttpConnectionBase
*/
protected void assertNotClosed() throws ConnectionClosedException {
if (this.status != ACTIVE) {
- throw new ConnectionClosedException("Connection is closed");
+ throw new ConnectionClosedException();
}
}
@@ -506,6 +509,8 @@ public class NHttpConnectionBase
return;
}
this.status = CLOSING;
+ this.inbuf.clear();
+ this.hasBufferedInput = false;
if (this.outbuf.hasData()) {
this.session.setEvent(EventMask.WRITE);
} else {
@@ -527,41 +532,25 @@ public class NHttpConnectionBase
@Override
public InetAddress getLocalAddress() {
final SocketAddress address = this.session.getLocalAddress();
- if (address instanceof InetSocketAddress) {
- return ((InetSocketAddress) address).getAddress();
- } else {
- return null;
- }
+ return address instanceof InetSocketAddress ? ((InetSocketAddress) address).getAddress() : null;
}
@Override
public int getLocalPort() {
final SocketAddress address = this.session.getLocalAddress();
- if (address instanceof InetSocketAddress) {
- return ((InetSocketAddress) address).getPort();
- } else {
- return -1;
- }
+ return address instanceof InetSocketAddress ? ((InetSocketAddress) address).getPort() : -1;
}
@Override
public InetAddress getRemoteAddress() {
final SocketAddress address = this.session.getRemoteAddress();
- if (address instanceof InetSocketAddress) {
- return ((InetSocketAddress) address).getAddress();
- } else {
- return null;
- }
+ return address instanceof InetSocketAddress ? ((InetSocketAddress) address).getAddress() : null;
}
@Override
public int getRemotePort() {
final SocketAddress address = this.session.getRemoteAddress();
- if (address instanceof InetSocketAddress) {
- return ((InetSocketAddress) address).getPort();
- } else {
- return -1;
- }
+ return address instanceof InetSocketAddress ? ((InetSocketAddress) address).getPort() : -1;
}
@Override
@@ -595,18 +584,13 @@ public class NHttpConnectionBase
buffer.append("<->");
NetUtils.formatAddress(buffer, remoteAddress);
return buffer.toString();
- } else {
- return "[Not bound]";
}
+ return "[Not bound]";
}
@Override
public Socket getSocket() {
- if (this.session instanceof SocketAccessor) {
- return ((SocketAccessor) this.session).getSocket();
- } else {
- return null;
- }
+ return this.session instanceof SocketAccessor ? ((SocketAccessor) this.session).getSocket() : null;
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/NHttpServerEventHandlerAdaptor.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/NHttpServerEventHandlerAdaptor.java
index c9630557d..4318b7723 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/NHttpServerEventHandlerAdaptor.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/NHttpServerEventHandlerAdaptor.java
@@ -89,9 +89,8 @@ class NHttpServerEventHandlerAdaptor implements NHttpServerEventHandler {
} else {
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
- } else {
- throw new Error("Unexpected exception: ", ex);
}
+ throw new Error("Unexpected exception: ", ex);
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SSLContextUtils.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SSLContextUtils.java
index c82194a6b..9c4aea089 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SSLContextUtils.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SSLContextUtils.java
@@ -33,18 +33,18 @@ import java.security.NoSuchAlgorithmException;
class SSLContextUtils {
static SSLContext getDefault() {
- SSLContext sslcontext;
+ SSLContext sslContext;
try {
try {
- sslcontext = SSLContext.getInstance("Default");
+ sslContext = SSLContext.getInstance("Default");
} catch (final NoSuchAlgorithmException ex) {
- sslcontext = SSLContext.getInstance("TLS");
+ sslContext = SSLContext.getInstance("TLS");
}
- sslcontext.init(null, null, null);
+ sslContext.init(null, null, null);
} catch (final Exception ex) {
throw new IllegalStateException("Failure initializing default SSL context", ex);
}
- return sslcontext;
+ return sslContext;
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SSLNHttpClientConnectionFactory.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SSLNHttpClientConnectionFactory.java
index 6ed9bad95..10b1f461a 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SSLNHttpClientConnectionFactory.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SSLNHttpClientConnectionFactory.java
@@ -28,17 +28,17 @@ package com.fr.third.org.apache.http.impl.nio;
import javax.net.ssl.SSLContext;
+import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.HttpResponseFactory;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.config.ConnectionConfig;
import com.fr.third.org.apache.http.entity.ContentLengthStrategy;
import com.fr.third.org.apache.http.impl.ConnSupport;
import com.fr.third.org.apache.http.impl.DefaultHttpResponseFactory;
import com.fr.third.org.apache.http.impl.nio.codecs.DefaultHttpResponseParserFactory;
-import com.fr.third.org.apache.http.nio.NHttpClientConnection;
import com.fr.third.org.apache.http.nio.NHttpConnectionFactory;
import com.fr.third.org.apache.http.nio.NHttpMessageParserFactory;
import com.fr.third.org.apache.http.nio.NHttpMessageWriterFactory;
@@ -55,7 +55,7 @@ import com.fr.third.org.apache.http.util.Args;
/**
* Default factory for SSL encrypted, non-blocking
- * {@link NHttpClientConnection}s.
+ * {@link com.fr.third.org.apache.http.nio.NHttpClientConnection}s.
*
* @since 4.2
*/
@@ -71,7 +71,7 @@ public class SSLNHttpClientConnectionFactory
private final NHttpMessageParserFactory responseParserFactory;
private final NHttpMessageWriterFactory requestWriterFactory;
private final ByteBufferAllocator allocator;
- private final SSLContext sslcontext;
+ private final SSLContext sslContext;
private final SSLSetupHandler sslHandler;
private final ConnectionConfig cconfig;
@@ -83,7 +83,7 @@ public class SSLNHttpClientConnectionFactory
*/
@Deprecated
public SSLNHttpClientConnectionFactory(
- final SSLContext sslcontext,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final HttpResponseFactory responseFactory,
final ByteBufferAllocator allocator,
@@ -92,7 +92,7 @@ public class SSLNHttpClientConnectionFactory
Args.notNull(responseFactory, "HTTP response factory");
Args.notNull(allocator, "Byte buffer allocator");
Args.notNull(params, "HTTP parameters");
- this.sslcontext = sslcontext != null ? sslcontext : SSLContexts.createSystemDefault();
+ this.sslContext = sslContext != null ? sslContext : SSLContexts.createSystemDefault();
this.sslHandler = sslHandler;
this.allocator = allocator;
this.incomingContentStrategy = null;
@@ -109,10 +109,10 @@ public class SSLNHttpClientConnectionFactory
*/
@Deprecated
public SSLNHttpClientConnectionFactory(
- final SSLContext sslcontext,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final HttpParams params) {
- this(sslcontext, sslHandler, DefaultHttpResponseFactory.INSTANCE,
+ this(sslContext, sslHandler, DefaultHttpResponseFactory.INSTANCE,
HeapByteBufferAllocator.INSTANCE, params);
}
@@ -129,7 +129,7 @@ public class SSLNHttpClientConnectionFactory
* @since 4.3
*/
public SSLNHttpClientConnectionFactory(
- final SSLContext sslcontext,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
@@ -138,7 +138,7 @@ public class SSLNHttpClientConnectionFactory
final ByteBufferAllocator allocator,
final ConnectionConfig cconfig) {
super();
- this.sslcontext = sslcontext != null ? sslcontext : SSLContexts.createSystemDefault();
+ this.sslContext = sslContext != null ? sslContext : SSLContexts.createSystemDefault();
this.sslHandler = sslHandler;
this.incomingContentStrategy = incomingContentStrategy;
this.outgoingContentStrategy = outgoingContentStrategy;
@@ -152,13 +152,13 @@ public class SSLNHttpClientConnectionFactory
* @since 4.3
*/
public SSLNHttpClientConnectionFactory(
- final SSLContext sslcontext,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final NHttpMessageParserFactory responseParserFactory,
final NHttpMessageWriterFactory requestWriterFactory,
final ByteBufferAllocator allocator,
final ConnectionConfig cconfig) {
- this(sslcontext, sslHandler,
+ this(sslContext, sslHandler,
null, null, responseParserFactory, requestWriterFactory, allocator, cconfig);
}
@@ -166,12 +166,12 @@ public class SSLNHttpClientConnectionFactory
* @since 4.3
*/
public SSLNHttpClientConnectionFactory(
- final SSLContext sslcontext,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final NHttpMessageParserFactory responseParserFactory,
final NHttpMessageWriterFactory requestWriterFactory,
final ConnectionConfig cconfig) {
- this(sslcontext, sslHandler,
+ this(sslContext, sslHandler,
null, null, responseParserFactory, requestWriterFactory, null, cconfig);
}
@@ -179,10 +179,10 @@ public class SSLNHttpClientConnectionFactory
* @since 4.3
*/
public SSLNHttpClientConnectionFactory(
- final SSLContext sslcontext,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final ConnectionConfig config) {
- this(sslcontext, sslHandler, null, null, null, null, null, config);
+ this(sslContext, sslHandler, null, null, null, null, null, config);
}
/**
@@ -215,20 +215,21 @@ public class SSLNHttpClientConnectionFactory
* @since 4.3
*/
protected SSLIOSession createSSLIOSession(
- final IOSession iosession,
- final SSLContext sslcontext,
+ final IOSession ioSession,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler) {
- final SSLIOSession ssliosession = new SSLIOSession(iosession, SSLMode.CLIENT,
- sslcontext, sslHandler);
- return ssliosession;
+ final Object attachment = ioSession.getAttribute(IOSession.ATTACHMENT_KEY);
+ return new SSLIOSession(ioSession, SSLMode.CLIENT,
+ attachment instanceof HttpHost ? (HttpHost) attachment : null,
+ sslContext, sslHandler);
}
@Override
- public DefaultNHttpClientConnection createConnection(final IOSession iosession) {
- final SSLIOSession ssliosession = createSSLIOSession(iosession, this.sslcontext, this.sslHandler);
- iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
+ public DefaultNHttpClientConnection createConnection(final IOSession ioSession) {
+ final SSLIOSession sslioSession = createSSLIOSession(ioSession, this.sslContext, this.sslHandler);
+ ioSession.setAttribute(SSLIOSession.SESSION_KEY, sslioSession);
return new DefaultNHttpClientConnection(
- ssliosession,
+ sslioSession,
this.cconfig.getBufferSize(),
this.cconfig.getFragmentSizeHint(),
this.allocator,
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SSLNHttpServerConnectionFactory.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SSLNHttpServerConnectionFactory.java
index 57405d12f..ee558eddf 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SSLNHttpServerConnectionFactory.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SSLNHttpServerConnectionFactory.java
@@ -31,8 +31,8 @@ import javax.net.ssl.SSLContext;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpRequestFactory;
import com.fr.third.org.apache.http.HttpResponse;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.config.ConnectionConfig;
import com.fr.third.org.apache.http.entity.ContentLengthStrategy;
import com.fr.third.org.apache.http.impl.ConnSupport;
@@ -41,7 +41,6 @@ import com.fr.third.org.apache.http.impl.nio.codecs.DefaultHttpRequestParserFact
import com.fr.third.org.apache.http.nio.NHttpConnectionFactory;
import com.fr.third.org.apache.http.nio.NHttpMessageParserFactory;
import com.fr.third.org.apache.http.nio.NHttpMessageWriterFactory;
-import com.fr.third.org.apache.http.nio.NHttpServerConnection;
import com.fr.third.org.apache.http.nio.reactor.IOSession;
import com.fr.third.org.apache.http.nio.reactor.ssl.SSLIOSession;
import com.fr.third.org.apache.http.nio.reactor.ssl.SSLMode;
@@ -55,7 +54,7 @@ import com.fr.third.org.apache.http.util.Args;
/**
* Default factory for SSL encrypted, non-blocking
- * {@link NHttpServerConnection}s.
+ * {@link com.fr.third.org.apache.http.nio.NHttpServerConnection}s.
*
* @since 4.2
*/
@@ -64,7 +63,7 @@ import com.fr.third.org.apache.http.util.Args;
public class SSLNHttpServerConnectionFactory
implements NHttpConnectionFactory {
- private final SSLContext sslcontext;
+ private final SSLContext sslContext;
private final SSLSetupHandler sslHandler;
private final ContentLengthStrategy incomingContentStrategy;
private final ContentLengthStrategy outgoingContentStrategy;
@@ -81,7 +80,7 @@ public class SSLNHttpServerConnectionFactory
*/
@Deprecated
public SSLNHttpServerConnectionFactory(
- final SSLContext sslcontext,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final HttpRequestFactory requestFactory,
final ByteBufferAllocator allocator,
@@ -90,7 +89,7 @@ public class SSLNHttpServerConnectionFactory
Args.notNull(requestFactory, "HTTP request factory");
Args.notNull(allocator, "Byte buffer allocator");
Args.notNull(params, "HTTP parameters");
- this.sslcontext = sslcontext != null ? sslcontext : SSLContexts.createSystemDefault();
+ this.sslContext = sslContext != null ? sslContext : SSLContexts.createSystemDefault();
this.sslHandler = sslHandler;
this.incomingContentStrategy = null;
this.outgoingContentStrategy = null;
@@ -107,10 +106,10 @@ public class SSLNHttpServerConnectionFactory
*/
@Deprecated
public SSLNHttpServerConnectionFactory(
- final SSLContext sslcontext,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final HttpParams params) {
- this(sslcontext, sslHandler, DefaultHttpRequestFactory.INSTANCE,
+ this(sslContext, sslHandler, DefaultHttpRequestFactory.INSTANCE,
HeapByteBufferAllocator.INSTANCE, params);
}
@@ -127,7 +126,7 @@ public class SSLNHttpServerConnectionFactory
* @since 4.3
*/
public SSLNHttpServerConnectionFactory(
- final SSLContext sslcontext,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
@@ -136,7 +135,7 @@ public class SSLNHttpServerConnectionFactory
final ByteBufferAllocator allocator,
final ConnectionConfig cconfig) {
super();
- this.sslcontext = sslcontext != null ? sslcontext : SSLContexts.createSystemDefault();
+ this.sslContext = sslContext != null ? sslContext : SSLContexts.createSystemDefault();
this.sslHandler = sslHandler;
this.incomingContentStrategy = incomingContentStrategy;
this.outgoingContentStrategy = outgoingContentStrategy;
@@ -150,13 +149,13 @@ public class SSLNHttpServerConnectionFactory
* @since 4.3
*/
public SSLNHttpServerConnectionFactory(
- final SSLContext sslcontext,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final NHttpMessageParserFactory requestParserFactory,
final NHttpMessageWriterFactory responseWriterFactory,
final ByteBufferAllocator allocator,
final ConnectionConfig cconfig) {
- this(sslcontext, sslHandler,
+ this(sslContext, sslHandler,
null, null, requestParserFactory, responseWriterFactory, allocator, cconfig);
}
@@ -164,12 +163,12 @@ public class SSLNHttpServerConnectionFactory
* @since 4.3
*/
public SSLNHttpServerConnectionFactory(
- final SSLContext sslcontext,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final NHttpMessageParserFactory requestParserFactory,
final NHttpMessageWriterFactory responseWriterFactory,
final ConnectionConfig cconfig) {
- this(sslcontext, sslHandler,
+ this(sslContext, sslHandler,
null, null, requestParserFactory, responseWriterFactory, null, cconfig);
}
@@ -177,10 +176,10 @@ public class SSLNHttpServerConnectionFactory
* @since 4.3
*/
public SSLNHttpServerConnectionFactory(
- final SSLContext sslcontext,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler,
final ConnectionConfig config) {
- this(sslcontext, sslHandler, null, null, null, null, null, config);
+ this(sslContext, sslHandler, null, null, null, null, null, config);
}
/**
@@ -213,19 +212,19 @@ public class SSLNHttpServerConnectionFactory
* @since 4.3
*/
protected SSLIOSession createSSLIOSession(
- final IOSession iosession,
- final SSLContext sslcontext,
+ final IOSession ioSession,
+ final SSLContext sslContext,
final SSLSetupHandler sslHandler) {
- final SSLIOSession ssliosession = new SSLIOSession(iosession, SSLMode.SERVER,
- sslcontext, sslHandler);
- return ssliosession;
+ final SSLIOSession sslioSession = new SSLIOSession(ioSession, SSLMode.SERVER,
+ sslContext, sslHandler);
+ return sslioSession;
}
@Override
- public DefaultNHttpServerConnection createConnection(final IOSession iosession) {
- final SSLIOSession ssliosession = createSSLIOSession(iosession, this.sslcontext, this.sslHandler);
- iosession.setAttribute(SSLIOSession.SESSION_KEY, ssliosession);
- return new DefaultNHttpServerConnection(ssliosession,
+ public DefaultNHttpServerConnection createConnection(final IOSession ioSession) {
+ final SSLIOSession sslioSession = createSSLIOSession(ioSession, this.sslContext, this.sslHandler);
+ ioSession.setAttribute(SSLIOSession.SESSION_KEY, sslioSession);
+ return new DefaultNHttpServerConnection(sslioSession,
this.cconfig.getBufferSize(),
this.cconfig.getFragmentSizeHint(),
this.allocator,
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SessionHttpContext.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SessionHttpContext.java
index cca0c3185..9f1546df7 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SessionHttpContext.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/SessionHttpContext.java
@@ -32,26 +32,38 @@ import com.fr.third.org.apache.http.protocol.HttpContext;
class SessionHttpContext implements HttpContext {
- private final IOSession iosession;
+ private final IOSession ioSession;
- public SessionHttpContext(final IOSession iosession) {
+ public SessionHttpContext(final IOSession ioSession) {
super();
- this.iosession = iosession;
+ this.ioSession = ioSession;
}
@Override
public Object getAttribute(final String id) {
- return this.iosession.getAttribute(id);
+ return this.ioSession.getAttribute(id);
}
@Override
public Object removeAttribute(final String id) {
- return this.iosession.removeAttribute(id);
+ return this.ioSession.removeAttribute(id);
}
@Override
public void setAttribute(final String id, final Object obj) {
- this.iosession.setAttribute(id, obj);
+ this.ioSession.setAttribute(id, obj);
+ }
+
+ /**
+ * @since 4.4.7
+ */
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("[ioSession=");
+ sb.append(ioSession);
+ sb.append("]");
+ return sb.toString();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/bootstrap/ServerBootstrap.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/bootstrap/ServerBootstrap.java
index 2a95c4a82..2fd8b3fd6 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/bootstrap/ServerBootstrap.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/bootstrap/ServerBootstrap.java
@@ -26,13 +26,12 @@
*/
package com.fr.third.org.apache.http.impl.nio.bootstrap;
+import javax.net.ssl.SSLContext;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
-import javax.net.ssl.SSLContext;
-
import com.fr.third.org.apache.http.ConnectionReuseStrategy;
import com.fr.third.org.apache.http.ExceptionLogger;
import com.fr.third.org.apache.http.HttpRequestInterceptor;
@@ -119,7 +118,7 @@ public class ServerBootstrap {
* Sets connection configuration.
*
* Please note this value can be overridden by the {@link #setConnectionFactory(
- *NHttpConnectionFactory)} method.
+ * com.fr.third.org.apache.http.nio.NHttpConnectionFactory)} method.
*/
public final ServerBootstrap setConnectionConfig(final ConnectionConfig connectionConfig) {
this.connectionConfig = connectionConfig;
@@ -127,7 +126,7 @@ public class ServerBootstrap {
}
/**
- * Assigns {@link HttpProcessor} instance.
+ * Assigns {@link com.fr.third.org.apache.http.protocol.HttpProcessor} instance.
*/
public final ServerBootstrap setHttpProcessor(final HttpProcessor httpProcessor) {
this.httpProcessor = httpProcessor;
@@ -138,7 +137,7 @@ public class ServerBootstrap {
* Adds this protocol interceptor to the head of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*/
public final ServerBootstrap addInterceptorFirst(final HttpResponseInterceptor itcp) {
if (itcp == null) {
@@ -155,7 +154,7 @@ public class ServerBootstrap {
* Adds this protocol interceptor to the tail of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*/
public final ServerBootstrap addInterceptorLast(final HttpResponseInterceptor itcp) {
if (itcp == null) {
@@ -172,7 +171,7 @@ public class ServerBootstrap {
* Adds this protocol interceptor to the head of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*/
public final ServerBootstrap addInterceptorFirst(final HttpRequestInterceptor itcp) {
if (itcp == null) {
@@ -189,7 +188,7 @@ public class ServerBootstrap {
* Adds this protocol interceptor to the tail of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*/
public final ServerBootstrap addInterceptorLast(final HttpRequestInterceptor itcp) {
if (itcp == null) {
@@ -206,7 +205,7 @@ public class ServerBootstrap {
* Assigns {@code Server} response header value.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
*/
public final ServerBootstrap setServerInfo(final String serverInfo) {
this.serverInfo = serverInfo;
@@ -214,7 +213,7 @@ public class ServerBootstrap {
}
/**
- * Assigns {@link ConnectionReuseStrategy} instance.
+ * Assigns {@link com.fr.third.org.apache.http.ConnectionReuseStrategy} instance.
*/
public final ServerBootstrap setConnectionReuseStrategy(final ConnectionReuseStrategy connStrategy) {
this.connStrategy = connStrategy;
@@ -222,7 +221,7 @@ public class ServerBootstrap {
}
/**
- * Assigns {@link HttpResponseFactory} instance.
+ * Assigns {@link com.fr.third.org.apache.http.HttpResponseFactory} instance.
*/
public final ServerBootstrap setResponseFactory(final HttpResponseFactory responseFactory) {
this.responseFactory = responseFactory;
@@ -230,7 +229,7 @@ public class ServerBootstrap {
}
/**
- * Assigns {@link HttpAsyncRequestHandlerMapper} instance.
+ * Assigns {@link com.fr.third.org.apache.http.nio.protocol.HttpAsyncRequestHandlerMapper} instance.
*/
public final ServerBootstrap setHandlerMapper(final HttpAsyncRequestHandlerMapper handlerMapper) {
this.handlerMapper = handlerMapper;
@@ -238,11 +237,11 @@ public class ServerBootstrap {
}
/**
- * Registers the given {@link HttpAsyncRequestHandler}
+ * Registers the given {@link com.fr.third.org.apache.http.nio.protocol.HttpAsyncRequestHandler}
* as a handler for URIs matching the given pattern.
*
* Please note this value can be overridden by the {@link #setHandlerMapper(
- *HttpAsyncRequestHandlerMapper)} )} method.
+ * com.fr.third.org.apache.http.nio.protocol.HttpAsyncRequestHandlerMapper)} )} method.
*
* @param pattern the pattern to register the handler for.
* @param handler the handler.
@@ -259,7 +258,7 @@ public class ServerBootstrap {
}
/**
- * Assigns {@link HttpAsyncExpectationVerifier} instance.
+ * Assigns {@link com.fr.third.org.apache.http.nio.protocol.HttpAsyncExpectationVerifier} instance.
*/
public final ServerBootstrap setExpectationVerifier(final HttpAsyncExpectationVerifier expectationVerifier) {
this.expectationVerifier = expectationVerifier;
@@ -267,7 +266,7 @@ public class ServerBootstrap {
}
/**
- * Assigns {@link NHttpConnectionFactory} instance.
+ * Assigns {@link com.fr.third.org.apache.http.nio.NHttpConnectionFactory} instance.
*/
public final ServerBootstrap setConnectionFactory(
final NHttpConnectionFactory extends DefaultNHttpServerConnection> connectionFactory) {
@@ -276,10 +275,10 @@ public class ServerBootstrap {
}
/**
- * Assigns {@link javax.net.ssl.SSLContext} instance.
+ * Assigns {@link SSLContext} instance.
*
* Please note this value can be overridden by the {@link #setConnectionFactory(
- *NHttpConnectionFactory)} method.
+ * com.fr.third.org.apache.http.nio.NHttpConnectionFactory)} method.
*/
public final ServerBootstrap setSslContext(final SSLContext sslContext) {
this.sslContext = sslContext;
@@ -287,10 +286,10 @@ public class ServerBootstrap {
}
/**
- * Assigns {@link SSLSetupHandler} instance.
+ * Assigns {@link com.fr.third.org.apache.http.nio.reactor.ssl.SSLSetupHandler} instance.
*
* Please note this value can be overridden by the {@link #setConnectionFactory(
- *NHttpConnectionFactory)} method.
+ * com.fr.third.org.apache.http.nio.NHttpConnectionFactory)} method.
*/
public ServerBootstrap setSslSetupHandler(final SSLSetupHandler sslSetupHandler) {
this.sslSetupHandler = sslSetupHandler;
@@ -298,7 +297,7 @@ public class ServerBootstrap {
}
/**
- * Assigns {@link ExceptionLogger} instance.
+ * Assigns {@link com.fr.third.org.apache.http.ExceptionLogger} instance.
*/
public final ServerBootstrap setExceptionLogger(final ExceptionLogger exceptionLogger) {
this.exceptionLogger = exceptionLogger;
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
index 1ed96f24e..ee09a0ab8 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/AbstractContentDecoder.java
@@ -76,6 +76,33 @@ public abstract class AbstractContentDecoder implements ContentDecoder {
return this.completed;
}
+ /**
+ * Sets the completed status of this decoder. Normally this is not necessary
+ * (the decoder will automatically complete when the underlying channel
+ * returns EOF). It is useful to mark the decoder as completed if you have
+ * some other means to know all the necessary data has been read and want to
+ * reuse the underlying connection for more messages.
+ *
+ * @param completed the completed status of this decoder.
+ * @since 4.4.11
+ */
+ public void setCompleted(final boolean completed) {
+ this.completed = completed;
+ }
+
+ /**
+ * Sets the completed status of this decoder to true. Normally this is not necessary
+ * (the decoder will automatically complete when the underlying channel
+ * returns EOF). It is useful to mark the decoder as completed if you have
+ * some other means to know all the necessary data has been read and want to
+ * reuse the underlying connection for more messages.
+ *
+ * @since 4.4.11
+ */
+ protected void setCompleted() {
+ this.completed = true;
+ }
+
/**
* Reads from the channel to the destination.
*
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java
index c8850e620..1af2bbfc2 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/AbstractContentEncoder.java
@@ -173,11 +173,10 @@ public abstract class AbstractContentEncoder implements ContentEncoder {
this.metrics.incrementBytesTransferred(bytesWritten);
}
return bytesWritten;
- } else {
- final int chunk = src.remaining();
- this.buffer.write(src);
- return chunk;
}
+ final int chunk = src.remaining();
+ this.buffer.write(src);
+ return chunk;
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/AbstractMessageParser.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/AbstractMessageParser.java
index dc38b1b9e..0ab9f9b6c 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/AbstractMessageParser.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/AbstractMessageParser.java
@@ -236,9 +236,8 @@ public abstract class AbstractMessageParser implements NH
}
}
return this.message;
- } else {
- return null;
}
+ return null;
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/ChunkDecoder.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/ChunkDecoder.java
index 43657afe7..0b7da60b3 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/ChunkDecoder.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/ChunkDecoder.java
@@ -135,8 +135,8 @@ public class ChunkDecoder extends AbstractContentDecoder {
}
this.pos = 0L;
} else if (this.endOfStream) {
- throw new ConnectionClosedException("Premature end of chunk coded message body: " +
- "closing chunk expected");
+ throw new ConnectionClosedException(
+ "Premature end of chunk coded message body: closing chunk expected");
}
}
@@ -174,7 +174,7 @@ public class ChunkDecoder extends AbstractContentDecoder {
try {
this.footers[i] = new BufferedHeader(this.trailerBufs.get(i));
} catch (final ParseException ex) {
- throw new IOException(ex.getMessage());
+ throw new IOException(ex);
}
}
}
@@ -222,10 +222,10 @@ public class ChunkDecoder extends AbstractContentDecoder {
} else {
if (!this.buffer.hasData() && this.endOfStream) {
this.state = COMPLETED;
- this.completed = true;
- throw new TruncatedChunkException("Truncated chunk "
- + "( expected size: " + this.chunkSize
- + "; actual size: " + this.pos + ")");
+ setCompleted();
+ throw new TruncatedChunkException(
+ "Truncated chunk (expected size: %,d; actual size: %,d)",
+ chunkSize, pos);
}
}
@@ -247,7 +247,7 @@ public class ChunkDecoder extends AbstractContentDecoder {
// Unable to read a footer
if (this.endOfStream) {
this.state = COMPLETED;
- this.completed = true;
+ setCompleted();
}
return totalRead;
}
@@ -259,7 +259,7 @@ public class ChunkDecoder extends AbstractContentDecoder {
parseHeader();
} else {
this.state = COMPLETED;
- this.completed = true;
+ setCompleted();
processFooters();
}
break;
@@ -270,11 +270,7 @@ public class ChunkDecoder extends AbstractContentDecoder {
}
public Header[] getFooters() {
- if (this.footers != null) {
- return this.footers.clone();
- } else {
- return new Header[] {};
- }
+ return this.footers != null ? this.footers.clone() : new Header[] {};
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestParser.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestParser.java
index 043402b89..84f82928a 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestParser.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestParser.java
@@ -27,7 +27,6 @@
package com.fr.third.org.apache.http.impl.nio.codecs;
-import com.fr.third.org.apache.http.message.BasicLineParser;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpRequestFactory;
@@ -37,14 +36,13 @@ import com.fr.third.org.apache.http.config.MessageConstraints;
import com.fr.third.org.apache.http.impl.DefaultHttpRequestFactory;
import com.fr.third.org.apache.http.message.LineParser;
import com.fr.third.org.apache.http.message.ParserCursor;
-import com.fr.third.org.apache.http.nio.NHttpMessageParser;
import com.fr.third.org.apache.http.nio.reactor.SessionInputBuffer;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
import com.fr.third.org.apache.http.util.CharArrayBuffer;
/**
- * Default {@link NHttpMessageParser} implementation
+ * Default {@link com.fr.third.org.apache.http.nio.NHttpMessageParser} implementation
* for {@link HttpRequest}s.
*
* @since 4.1
@@ -81,7 +79,7 @@ public class DefaultHttpRequestParser extends AbstractMessageParser
*
* @param buffer the session input buffer.
* @param parser the line parser. If {@code null}
- * {@link BasicLineParser#INSTANCE} will be used.
+ * {@link com.fr.third.org.apache.http.message.BasicLineParser#INSTANCE} will be used.
* @param requestFactory the request factory. If {@code null}
* {@link DefaultHttpRequestFactory#INSTANCE} will be used.
* @param constraints Message constraints. If {@code null}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestParserFactory.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestParserFactory.java
index 040c285d1..22db6918d 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestParserFactory.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestParserFactory.java
@@ -29,8 +29,8 @@ package com.fr.third.org.apache.http.impl.nio.codecs;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpRequestFactory;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.config.MessageConstraints;
import com.fr.third.org.apache.http.impl.DefaultHttpRequestFactory;
import com.fr.third.org.apache.http.message.BasicLineParser;
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestWriter.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestWriter.java
index bfc19e669..4d0c724ad 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestWriter.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestWriter.java
@@ -29,16 +29,14 @@ package com.fr.third.org.apache.http.impl.nio.codecs;
import java.io.IOException;
-import com.fr.third.org.apache.http.message.BasicLineFormatter;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.message.LineFormatter;
-import com.fr.third.org.apache.http.nio.NHttpMessageWriter;
import com.fr.third.org.apache.http.nio.reactor.SessionOutputBuffer;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.CharArrayBuffer;
/**
- * Default {@link NHttpMessageWriter} implementation
+ * Default {@link com.fr.third.org.apache.http.nio.NHttpMessageWriter} implementation
* for {@link HttpRequest}s.
*
* @since 4.1
@@ -62,7 +60,7 @@ public class DefaultHttpRequestWriter extends AbstractMessageWriter
*
* @param buffer the session output buffer.
* @param formatter the line formatter If {@code null}
- * {@link BasicLineFormatter#INSTANCE} will be used.
+ * {@link com.fr.third.org.apache.http.message.BasicLineFormatter#INSTANCE} will be used.
*
* @since 4.3
*/
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestWriterFactory.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestWriterFactory.java
index 80310fee7..5107fc87a 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestWriterFactory.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpRequestWriterFactory.java
@@ -28,8 +28,8 @@
package com.fr.third.org.apache.http.impl.nio.codecs;
import com.fr.third.org.apache.http.HttpRequest;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.message.BasicLineFormatter;
import com.fr.third.org.apache.http.message.LineFormatter;
import com.fr.third.org.apache.http.nio.NHttpMessageWriter;
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpResponseParser.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpResponseParser.java
index eb75fe910..dee9e5375 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpResponseParser.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/DefaultHttpResponseParser.java
@@ -27,7 +27,6 @@
package com.fr.third.org.apache.http.impl.nio.codecs;
-import com.fr.third.org.apache.http.message.BasicLineParser;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.HttpResponseFactory;
@@ -37,14 +36,13 @@ import com.fr.third.org.apache.http.config.MessageConstraints;
import com.fr.third.org.apache.http.impl.DefaultHttpResponseFactory;
import com.fr.third.org.apache.http.message.LineParser;
import com.fr.third.org.apache.http.message.ParserCursor;
-import com.fr.third.org.apache.http.nio.NHttpMessageParser;
import com.fr.third.org.apache.http.nio.reactor.SessionInputBuffer;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
import com.fr.third.org.apache.http.util.CharArrayBuffer;
/**
- * Default {@link NHttpMessageParser} implementation
+ * Default {@link com.fr.third.org.apache.http.nio.NHttpMessageParser} implementation
* for {@link HttpResponse}s.
*
* @since 4.1
@@ -75,7 +73,7 @@ public class DefaultHttpResponseParser extends AbstractMessageParser dst.size()) {
- throw new IOException("Position past end of file [" + position +
- " > " + dst.size() + "]");
+ throw new IOException(String.format("Position past end of file [%,d > %,d]",
+ position, dst.size()));
}
bytesRead = dst.transferFrom(this.channel, position, count);
if (count > 0 && bytesRead == 0) {
@@ -124,7 +114,7 @@ public class IdentityDecoder extends AbstractContentDecoder
}
}
if (bytesRead == -1) {
- this.completed = true;
+ setCompleted();
}
return bytesRead;
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
index 9d6f36bb7..77668a42b 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/codecs/LengthDelimitedDecoder.java
@@ -71,7 +71,7 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
@Override
public int read(final ByteBuffer dst) throws IOException {
Args.notNull(dst, "Byte buffer");
- if (this.completed) {
+ if (isCompleted()) {
return -1;
}
final int chunk = (int) Math.min((this.contentLength - this.len), Integer.MAX_VALUE);
@@ -84,22 +84,18 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
bytesRead = readFromChannel(dst, chunk);
}
if (bytesRead == -1) {
- this.completed = true;
+ setCompleted();
if (this.len < this.contentLength) {
throw new ConnectionClosedException(
- "Premature end of Content-Length delimited message body (expected: "
- + this.contentLength + "; received: " + this.len);
+ "Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
+ contentLength, len);
}
}
this.len += bytesRead;
if (this.len >= this.contentLength) {
- this.completed = true;
- }
- if (this.completed && bytesRead == 0) {
- return -1;
- } else {
- return bytesRead;
+ setCompleted();
}
+ return isCompleted() && bytesRead == 0 ? -1 : bytesRead;
}
@Override
@@ -111,7 +107,7 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
if (dst == null) {
return 0;
}
- if (this.completed) {
+ if (isCompleted()) {
return -1;
}
@@ -121,12 +117,12 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
if (this.buffer.hasData()) {
final int maxLen = Math.min(chunk, this.buffer.length());
dst.position(position);
- bytesRead = this.buffer.read(dst, maxLen);
+ bytesRead = this.buffer.read(dst, count < maxLen ? (int)count : maxLen);
} else {
if (this.channel.isOpen()) {
if (position > dst.size()) {
- throw new IOException("Position past end of file [" + position +
- " > " + dst.size() + "]");
+ throw new IOException(String.format("Position past end of file [%,d > %,d]",
+ position, dst.size()));
}
bytesRead = dst.transferFrom(this.channel, position, count < chunk ? count : chunk);
} else {
@@ -137,16 +133,16 @@ public class LengthDelimitedDecoder extends AbstractContentDecoder
}
}
if (bytesRead == -1) {
- this.completed = true;
+ setCompleted();
if (this.len < this.contentLength) {
throw new ConnectionClosedException(
- "Premature end of Content-Length delimited message body (expected: "
- + this.contentLength + "; received: " + this.len);
+ "Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
+ contentLength, len);
}
}
this.len += bytesRead;
if (this.len >= this.contentLength) {
- this.completed = true;
+ setCompleted();
}
return bytesRead;
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/pool/BasicNIOConnFactory.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/pool/BasicNIOConnFactory.java
index e19133988..87f9e1492 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/pool/BasicNIOConnFactory.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/pool/BasicNIOConnFactory.java
@@ -26,16 +26,15 @@
*/
package com.fr.third.org.apache.http.impl.nio.pool;
-import java.io.IOException;
-
import javax.net.ssl.SSLContext;
+import java.io.IOException;
import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.HttpResponseFactory;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.config.ConnectionConfig;
import com.fr.third.org.apache.http.impl.DefaultHttpResponseFactory;
import com.fr.third.org.apache.http.impl.nio.DefaultNHttpClientConnectionFactory;
@@ -87,7 +86,7 @@ public class BasicNIOConnFactory implements NIOConnFactory responseParserFactory,
final NHttpMessageWriterFactory requestWriterFactory,
@@ -132,7 +131,7 @@ public class BasicNIOConnFactory implements NIOConnFactory connFactory,
final HttpParams params) {
- super(ioreactor, connFactory, 2, 20);
+ super(ioReactor, connFactory, 2, 20);
Args.notNull(params, "HTTP parameters");
this.connectTimeout = params.getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 0);
}
@@ -107,18 +106,18 @@ public class BasicNIOConnPool extends AbstractNIOConnPool connFactory,
final int connectTimeout) {
- super(ioreactor, connFactory, new BasicAddressResolver(), 2, 20);
+ super(ioReactor, connFactory, new BasicAddressResolver(), 2, 20);
this.connectTimeout = connectTimeout;
}
@@ -126,26 +125,26 @@ public class BasicNIOConnPool extends AbstractNIOConnPool 1000) {
+ connection.setSocketTimeout(1000);
+ }
+ connection.close();
+ } catch (final IOException ex) {
+ connection.shutdown();
+ }
} catch (final IOException ignore) {
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/AbstractIODispatch.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/AbstractIODispatch.java
index eac8e5a66..c4fac41ef 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/AbstractIODispatch.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/AbstractIODispatch.java
@@ -71,18 +71,18 @@ public abstract class AbstractIODispatch implements IOEventDispatch {
session.setAttribute(IOEventDispatch.CONNECTION_KEY, conn);
}
onConnected(conn);
- final SSLIOSession ssliosession = (SSLIOSession) session.getAttribute(
+ final SSLIOSession sslioSession = (SSLIOSession) session.getAttribute(
SSLIOSession.SESSION_KEY);
- if (ssliosession != null) {
+ if (sslioSession != null) {
try {
- synchronized (ssliosession) {
- if (!ssliosession.isInitialized()) {
- ssliosession.initialize();
+ synchronized (sslioSession) {
+ if (!sslioSession.isInitialized()) {
+ sslioSession.initialize();
}
}
} catch (final IOException ex) {
onException(conn, ex);
- ssliosession.shutdown();
+ sslioSession.shutdown();
}
}
} catch (final RuntimeException ex) {
@@ -108,22 +108,22 @@ public abstract class AbstractIODispatch implements IOEventDispatch {
T conn = (T) session.getAttribute(IOEventDispatch.CONNECTION_KEY);
try {
ensureNotNull(conn);
- final SSLIOSession ssliosession = (SSLIOSession) session.getAttribute(
+ final SSLIOSession sslioSession = (SSLIOSession) session.getAttribute(
SSLIOSession.SESSION_KEY);
- if (ssliosession == null) {
+ if (sslioSession == null) {
onInputReady(conn);
} else {
try {
- if (!ssliosession.isInitialized()) {
- ssliosession.initialize();
+ if (!sslioSession.isInitialized()) {
+ sslioSession.initialize();
}
- if (ssliosession.isAppInputReady()) {
+ if (sslioSession.isAppInputReady()) {
onInputReady(conn);
}
- ssliosession.inboundTransport();
+ sslioSession.inboundTransport();
} catch (final IOException ex) {
onException(conn, ex);
- ssliosession.shutdown();
+ sslioSession.shutdown();
}
}
} catch (final RuntimeException ex) {
@@ -139,22 +139,22 @@ public abstract class AbstractIODispatch implements IOEventDispatch {
T conn = (T) session.getAttribute(IOEventDispatch.CONNECTION_KEY);
try {
ensureNotNull(conn);
- final SSLIOSession ssliosession = (SSLIOSession) session.getAttribute(
+ final SSLIOSession sslioSession = (SSLIOSession) session.getAttribute(
SSLIOSession.SESSION_KEY);
- if (ssliosession == null) {
+ if (sslioSession == null) {
onOutputReady(conn);
} else {
try {
- if (!ssliosession.isInitialized()) {
- ssliosession.initialize();
+ if (!sslioSession.isInitialized()) {
+ sslioSession.initialize();
}
- if (ssliosession.isAppOutputReady()) {
+ if (sslioSession.isAppOutputReady()) {
onOutputReady(conn);
}
- ssliosession.outboundTransport();
+ sslioSession.outboundTransport();
} catch (final IOException ex) {
onException(conn, ex);
- ssliosession.shutdown();
+ sslioSession.shutdown();
}
}
} catch (final RuntimeException ex) {
@@ -169,15 +169,15 @@ public abstract class AbstractIODispatch implements IOEventDispatch {
final
T conn = (T) session.getAttribute(IOEventDispatch.CONNECTION_KEY);
try {
- final SSLIOSession ssliosession = (SSLIOSession) session.getAttribute(
+ final SSLIOSession sslioSession = (SSLIOSession) session.getAttribute(
SSLIOSession.SESSION_KEY);
ensureNotNull(conn);
onTimeout(conn);
- if (ssliosession != null) {
- synchronized (ssliosession) {
- if (ssliosession.isOutboundDone() && !ssliosession.isInboundDone()) {
+ if (sslioSession != null) {
+ synchronized (sslioSession) {
+ if (sslioSession.isOutboundDone() && !sslioSession.isInboundDone()) {
// The session failed to terminate cleanly
- ssliosession.shutdown();
+ sslioSession.shutdown();
}
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/AbstractIOReactor.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
index 74599554c..43ab56710 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
@@ -419,14 +419,23 @@ public abstract class AbstractIOReactor implements IOReactor {
}
try {
this.sessions.add(session);
+ key.attach(session);
final SessionRequestImpl sessionRequest = entry.getSessionRequest();
if (sessionRequest != null) {
- sessionRequest.completed(session);
+ if (!sessionRequest.isTerminated()) {
+ sessionRequest.completed(session);
+ }
+ if (!sessionRequest.isTerminated() && !session.isClosed()) {
+ sessionCreated(key, session);
+ }
+ if (sessionRequest.isTerminated()) {
+ throw new CancelledKeyException();
+ }
+ } else {
+ sessionCreated(key, session);
}
- key.attach(session);
- sessionCreated(key, session);
} catch (final CancelledKeyException ex) {
- queueClosedSession(session);
+ session.close();
key.attach(null);
}
}
@@ -456,7 +465,11 @@ public abstract class AbstractIOReactor implements IOReactor {
final SelectionKey key = entry.getSelectionKey();
final int eventMask = entry.getEventMask();
if (key.isValid()) {
- key.interestOps(eventMask);
+ try {
+ key.interestOps(eventMask);
+ } catch (final CancelledKeyException ex) {
+ // ignore and move on
+ }
}
}
}
@@ -489,7 +502,12 @@ public abstract class AbstractIOReactor implements IOReactor {
final int timeout = session.getSocketTimeout();
if (timeout > 0) {
if (session.getLastAccessTime() + timeout < now) {
- sessionTimedOut(session);
+ try {
+ sessionTimedOut(session);
+ } catch (final CancelledKeyException ex) {
+ session.close();
+ key.attach(null);
+ }
}
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
index 7a299b601..c8fa4c47f 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
@@ -56,9 +56,9 @@ import com.fr.third.org.apache.http.util.Asserts;
/**
* Generic implementation of {@link IOReactor} that can run multiple
- * {@link BaseIOReactor} instance in separate worker threads and distribute
- * newly created I/O session equally across those I/O reactors for a more
- * optimal resource utilization and a better I/O performance. Usually it is
+ * {@link BaseIOReactor} instances in separate worker threads and distribute
+ * newly created I/O sessions equally across those I/O reactors for more
+ * optimal resource utilization and better I/O performance. Usually it is
* recommended to have one worker I/O reactor per physical CPU core.
*
* Important note about exception handling
@@ -170,6 +170,9 @@ public abstract class AbstractMultiworkerIOReactor implements IOReactor {
this(null, null);
}
+ /**
+ * @deprecated Do not use.
+ */
@Deprecated
static IOReactorConfig convert(final int workerCount, final HttpParams params) {
Args.notNull(params, "HTTP parameters");
@@ -351,7 +354,7 @@ public abstract class AbstractMultiworkerIOReactor implements IOReactor {
// Verify I/O dispatchers
for (int i = 0; i < this.workerCount; i++) {
final Worker worker = this.workers[i];
- final Exception ex = worker.getException();
+ final Throwable ex = worker.getThrowable();
if (ex != null) {
throw new IOReactorException(
"I/O dispatch worker terminated abnormally", ex);
@@ -574,7 +577,7 @@ public abstract class AbstractMultiworkerIOReactor implements IOReactor {
final BaseIOReactor dispatcher;
final IOEventDispatch eventDispatch;
- private volatile Exception exception;
+ private volatile Throwable exception;
public Worker(final BaseIOReactor dispatcher, final IOEventDispatch eventDispatch) {
super();
@@ -586,12 +589,15 @@ public abstract class AbstractMultiworkerIOReactor implements IOReactor {
public void run() {
try {
this.dispatcher.execute(this.eventDispatch);
+ } catch (final Error ex) {
+ this.exception = ex;
+ throw ex;
} catch (final Exception ex) {
this.exception = ex;
}
}
- public Exception getException() {
+ public Throwable getThrowable() {
return this.exception;
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/BaseIOReactor.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/BaseIOReactor.java
index 928517c03..6033bc5c8 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/BaseIOReactor.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/BaseIOReactor.java
@@ -36,7 +36,6 @@ import java.util.Set;
import com.fr.third.org.apache.http.nio.reactor.EventMask;
import com.fr.third.org.apache.http.nio.reactor.IOEventDispatch;
-import com.fr.third.org.apache.http.nio.reactor.IOReactor;
import com.fr.third.org.apache.http.nio.reactor.IOReactorException;
import com.fr.third.org.apache.http.nio.reactor.IOReactorExceptionHandler;
import com.fr.third.org.apache.http.nio.reactor.IOSession;
@@ -44,7 +43,7 @@ import com.fr.third.org.apache.http.util.Args;
/**
* Default implementation of {@link AbstractIOReactor} that serves as a base
- * for more advanced {@link IOReactor}
+ * for more advanced {@link com.fr.third.org.apache.http.nio.reactor.IOReactor}
* implementations. This class adds support for the I/O event dispatching
* using {@link IOEventDispatch}, management of buffering sessions, and
* session timeout handling.
@@ -170,8 +169,7 @@ public class BaseIOReactor extends AbstractIOReactor {
this.bufferingSessions.add(session);
}
} catch (final CancelledKeyException ex) {
- queueClosedSession(session);
- key.attach(null);
+ throw ex;
} catch (final RuntimeException ex) {
handleRuntimeException(ex);
}
@@ -188,8 +186,7 @@ public class BaseIOReactor extends AbstractIOReactor {
try {
this.eventDispatch.outputReady(session);
} catch (final CancelledKeyException ex) {
- queueClosedSession(session);
- key.attach(null);
+ throw ex;
} catch (final RuntimeException ex) {
handleRuntimeException(ex);
}
@@ -231,7 +228,7 @@ public class BaseIOReactor extends AbstractIOReactor {
}
} catch (final CancelledKeyException ex) {
it.remove();
- queueClosedSession(session);
+ session.close();
} catch (final RuntimeException ex) {
handleRuntimeException(ex);
}
@@ -248,7 +245,7 @@ public class BaseIOReactor extends AbstractIOReactor {
try {
this.eventDispatch.connected(session);
} catch (final CancelledKeyException ex) {
- queueClosedSession(session);
+ throw ex;
} catch (final RuntimeException ex) {
handleRuntimeException(ex);
}
@@ -263,7 +260,7 @@ public class BaseIOReactor extends AbstractIOReactor {
try {
this.eventDispatch.timeout(session);
} catch (final CancelledKeyException ex) {
- queueClosedSession(session);
+ throw ex;
} catch (final RuntimeException ex) {
handleRuntimeException(ex);
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/ChannelEntry.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/ChannelEntry.java
index 489bcc363..19a14ac97 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/ChannelEntry.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/ChannelEntry.java
@@ -85,11 +85,7 @@ public class ChannelEntry {
* {@code null} otherwise.
*/
public Object getAttachment() {
- if (this.sessionRequest != null) {
- return this.sessionRequest.getAttachment();
- } else {
- return null;
- }
+ return this.sessionRequest != null ? this.sessionRequest.getAttachment() : null;
}
/**
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
index 45a7b3465..4c408257e 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
@@ -35,6 +35,9 @@ import java.net.UnknownHostException;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -270,7 +273,25 @@ public class DefaultConnectingIOReactor extends AbstractMultiworkerIOReactor
sock.setReuseAddress(this.config.isSoReuseAddress());
sock.bind(request.getLocalAddress());
}
- final boolean connected = socketChannel.connect(request.getRemoteAddress());
+
+ final SocketAddress targetAddress = request.getRemoteAddress();
+ // Run this under a doPrivileged to support lib users that run under a SecurityManager this allows granting connect
+ // permissions only to this library
+ final boolean connected;
+ try {
+ connected = AccessController.doPrivileged(
+ new PrivilegedExceptionAction() {
+ @Override
+ public Boolean run() throws IOException {
+ return socketChannel.connect(targetAddress);
+ }
+ });
+ } catch (final PrivilegedActionException e) {
+ Asserts.check(e.getCause() instanceof IOException,
+ "method contract violation only checked exceptions are wrapped: " + e.getCause());
+ // only checked exceptions are wrapped - error and RTExceptions are rethrown by doPrivileged
+ throw (IOException) e.getCause();
+ }
if (connected) {
final ChannelEntry entry = new ChannelEntry(socketChannel, request);
addChannel(entry);
@@ -280,6 +301,10 @@ public class DefaultConnectingIOReactor extends AbstractMultiworkerIOReactor
closeChannel(socketChannel);
request.failed(ex);
return;
+ } catch (final SecurityException ex) {
+ closeChannel(socketChannel);
+ request.failed(new IOException(ex));
+ return;
}
final SessionRequestHandle requestHandle = new SessionRequestHandle(request);
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
index d178ff45f..36b0bf60c 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
@@ -247,9 +247,8 @@ public class DefaultListeningIOReactor extends AbstractMultiworkerIOReactor
if (this.exceptionHandler == null || !this.exceptionHandler.handle(ex)) {
throw new IOReactorException("Failure binding socket to address "
+ address, ex);
- } else {
- return;
}
+ return;
}
try {
final SelectionKey key = serverChannel.register(this.selector, SelectionKey.OP_ACCEPT);
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/ExceptionEvent.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/ExceptionEvent.java
index cd44f055e..22c4e8efc 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/ExceptionEvent.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/ExceptionEvent.java
@@ -27,11 +27,11 @@
package com.fr.third.org.apache.http.impl.nio.reactor;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
-import com.fr.third.org.apache.http.annotation.Contract;
-
import java.util.Date;
+import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
+
/**
* A {@link Throwable} instance along with a time stamp.
*
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/IOReactorConfig.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/IOReactorConfig.java
index 65af9acae..d57498598 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/IOReactorConfig.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/IOReactorConfig.java
@@ -36,8 +36,6 @@ import com.fr.third.org.apache.http.util.Args;
*/
public final class IOReactorConfig implements Cloneable {
- private static final int AVAIL_PROCS = Runtime.getRuntime().availableProcessors();
-
public static final IOReactorConfig DEFAULT = new Builder().build();
// TODO: make final
@@ -55,13 +53,16 @@ public final class IOReactorConfig implements Cloneable {
private int rcvBufSize;
private final int backlogSize;
+ /**
+ * @deprecated Use {@link Builder}.
+ */
@Deprecated
public IOReactorConfig() {
super();
this.selectInterval = 1000;
this.shutdownGracePeriod = 500;
this.interestOpQueued = false;
- this.ioThreadCount = AVAIL_PROCS;
+ this.ioThreadCount = Builder.getDefaultMaxIoThreadCount();
this.soTimeout = 0;
this.soReuseAddress = false;
this.soLinger = -1;
@@ -91,7 +92,7 @@ public final class IOReactorConfig implements Cloneable {
this.selectInterval = selectInterval;
this.shutdownGracePeriod = shutdownGracePeriod;
this.interestOpQueued = interestOpQueued;
- this.ioThreadCount = ioThreadCount;
+ this.ioThreadCount = Args.positive(ioThreadCount, "ioThreadCount");
this.soTimeout = soTimeout;
this.soReuseAddress = soReuseAddress;
this.soLinger = soLinger;
@@ -378,6 +379,33 @@ public final class IOReactorConfig implements Cloneable {
public static class Builder {
+ private static int DefaultMaxIoThreadCount = -1;
+
+ /**
+ * Gets the default value for {@code ioThreadCount}. Returns
+ * {@link Runtime#availableProcessors()} if
+ * {@link #setDefaultMaxIoThreadCount(int)} was called with a value <=0.
+ *
+ * @return the default value for ioThreadCount.
+ * @since 4.4.10
+ */
+ public static int getDefaultMaxIoThreadCount() {
+ return DefaultMaxIoThreadCount > 0 ? DefaultMaxIoThreadCount : Runtime.getRuntime().availableProcessors();
+ }
+
+ /**
+ * Sets the default value for {@code ioThreadCount}. Use a value <= 0 to
+ * cause {@link #getDefaultMaxIoThreadCount()} to return
+ * {@link Runtime#availableProcessors()}.
+ *
+ * @param defaultMaxIoThreadCount
+ * the default value for ioThreadCount.
+ * @since 4.4.10
+ */
+ public static void setDefaultMaxIoThreadCount(final int defaultMaxIoThreadCount) {
+ DefaultMaxIoThreadCount = defaultMaxIoThreadCount;
+ }
+
private long selectInterval;
private long shutdownGracePeriod;
private boolean interestOpQueued;
@@ -396,7 +424,7 @@ public final class IOReactorConfig implements Cloneable {
this.selectInterval = 1000;
this.shutdownGracePeriod = 500;
this.interestOpQueued = false;
- this.ioThreadCount = AVAIL_PROCS;
+ this.ioThreadCount = getDefaultMaxIoThreadCount();
this.soTimeout = 0;
this.soReuseAddress = false;
this.soLinger = -1;
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/IOSessionImpl.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/IOSessionImpl.java
index 3eca8c3c8..adfe6171e 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/IOSessionImpl.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/IOSessionImpl.java
@@ -38,8 +38,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.nio.reactor.IOSession;
import com.fr.third.org.apache.http.nio.reactor.SessionBufferStatus;
import com.fr.third.org.apache.http.nio.reactor.SocketAccessor;
@@ -119,20 +119,16 @@ public class IOSessionImpl implements IOSession, SocketAccessor {
@Override
public SocketAddress getLocalAddress() {
- if (this.channel instanceof SocketChannel) {
- return ((SocketChannel)this.channel).socket().getLocalSocketAddress();
- } else {
- return null;
- }
+ return this.channel instanceof SocketChannel
+ ? ((SocketChannel) this.channel).socket().getLocalSocketAddress()
+ : null;
}
@Override
public SocketAddress getRemoteAddress() {
- if (this.channel instanceof SocketChannel) {
- return ((SocketChannel)this.channel).socket().getRemoteSocketAddress();
- } else {
- return null;
- }
+ return this.channel instanceof SocketChannel
+ ? ((SocketChannel) this.channel).socket().getRemoteSocketAddress()
+ : null;
}
@Override
@@ -220,8 +216,6 @@ public class IOSessionImpl implements IOSession, SocketAccessor {
return;
}
this.status = CLOSED;
- }
- synchronized (this.key) {
this.key.cancel();
try {
this.key.channel().close();
@@ -379,11 +373,7 @@ public class IOSessionImpl implements IOSession, SocketAccessor {
@Override
public Socket getSocket() {
- if (this.channel instanceof SocketChannel) {
- return ((SocketChannel) this.channel).socket();
- } else {
- return null;
- }
+ return this.channel instanceof SocketChannel ? ((SocketChannel) this.channel).socket() : null;
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/InterestOpEntry.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/InterestOpEntry.java
index 5b0886d7a..3ff0ae0fd 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/InterestOpEntry.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/InterestOpEntry.java
@@ -32,7 +32,7 @@ import java.nio.channels.SelectionKey;
import com.fr.third.org.apache.http.util.Args;
/**
- * Helper class, representing an entry on an {@link java.nio.channels.SelectionKey#interestOps(int)
+ * Helper class, representing an entry on an {@link SelectionKey#interestOps(int)
* interestOps(int)} queue.
*
* @since 4.1
@@ -62,12 +62,7 @@ class InterestOpEntry {
if (this == obj) {
return true;
}
- if (obj instanceof InterestOpEntry) {
- final InterestOpEntry that = (InterestOpEntry) obj;
- return this.key.equals(that.key);
- } else {
- return false;
- }
+ return obj instanceof InterestOpEntry ? this.key.equals(((InterestOpEntry) obj).key) : false;
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/ListenerEndpointImpl.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/ListenerEndpointImpl.java
index 44874ee46..f34573909 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/ListenerEndpointImpl.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/ListenerEndpointImpl.java
@@ -32,8 +32,8 @@ import java.net.SocketAddress;
import java.nio.channels.Channel;
import java.nio.channels.SelectionKey;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.nio.reactor.ListenerEndpoint;
import com.fr.third.org.apache.http.util.Args;
@@ -156,4 +156,10 @@ public class ListenerEndpointImpl implements ListenerEndpoint {
}
}
+ @Override
+ public String toString() {
+ return "[address=" + address + ", key=" + key + ", closed=" + closed + ", completed="
+ + completed + ", exception=" + exception + ", callback=" + callback + "]";
+ }
+
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
index 3a5c0f007..75e14fc2f 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionInputBufferImpl.java
@@ -60,19 +60,19 @@ import com.fr.third.org.apache.http.util.CharsetUtils;
@SuppressWarnings("deprecation")
public class SessionInputBufferImpl extends ExpandableBuffer implements SessionInputBuffer {
- private final CharsetDecoder chardecoder;
+ private final CharsetDecoder charDecoder;
private final MessageConstraints constraints;
- private final int lineBuffersize;
+ private final int lineBufferSize;
- private CharBuffer charbuffer;
+ private CharBuffer charBuffer;
/**
* Creates SessionInputBufferImpl instance.
*
- * @param buffersize input buffer size
- * @param lineBuffersize buffer size for line operations. Has effect only if
- * {@code chardecoder} is not {@code null}.
- * @param chardecoder chardecoder to be used for decoding HTTP protocol elements.
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations. Has effect only if
+ * {@code charDecoder} is not {@code null}.
+ * @param charDecoder CharDecoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
* @param constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -82,24 +82,24 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
* @since 4.4
*/
public SessionInputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final MessageConstraints constraints,
- final CharsetDecoder chardecoder,
+ final CharsetDecoder charDecoder,
final ByteBufferAllocator allocator) {
- super(buffersize, allocator != null ? allocator : HeapByteBufferAllocator.INSTANCE);
- this.lineBuffersize = Args.positive(lineBuffersize, "Line buffer size");
+ super(bufferSize, allocator != null ? allocator : HeapByteBufferAllocator.INSTANCE);
+ this.lineBufferSize = Args.positive(lineBufferSize, "Line buffer size");
this.constraints = constraints != null ? constraints : MessageConstraints.DEFAULT;
- this.chardecoder = chardecoder;
+ this.charDecoder = charDecoder;
}
/**
* Creates SessionInputBufferImpl instance.
*
- * @param buffersize input buffer size
- * @param lineBuffersize buffer size for line operations. Has effect only if
- * {@code chardecoder} is not {@code null}.
- * @param chardecoder chardecoder to be used for decoding HTTP protocol elements.
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations. Has effect only if
+ * {@code charDecoder} is not {@code null}.
+ * @param charDecoder CharDecoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
* @param allocator memory allocator.
* If {@code null} {@link HeapByteBufferAllocator#INSTANCE} will be used.
@@ -107,11 +107,11 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
* @since 4.3
*/
public SessionInputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
- final CharsetDecoder chardecoder,
+ final int bufferSize,
+ final int lineBufferSize,
+ final CharsetDecoder charDecoder,
final ByteBufferAllocator allocator) {
- this(buffersize, lineBuffersize, null, chardecoder, allocator);
+ this(bufferSize, lineBufferSize, null, charDecoder, allocator);
}
/**
@@ -121,24 +121,24 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
*/
@Deprecated
public SessionInputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final ByteBufferAllocator allocator,
final HttpParams params) {
- super(buffersize, allocator);
- this.lineBuffersize = Args.positive(lineBuffersize, "Line buffer size");
+ super(bufferSize, allocator);
+ this.lineBufferSize = Args.positive(lineBufferSize, "Line buffer size");
final String charsetName = (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
final Charset charset = CharsetUtils.lookup(charsetName);
if (charset != null) {
- this.chardecoder = charset.newDecoder();
+ this.charDecoder = charset.newDecoder();
final CodingErrorAction a1 = (CodingErrorAction) params.getParameter(
CoreProtocolPNames.HTTP_MALFORMED_INPUT_ACTION);
- this.chardecoder.onMalformedInput(a1 != null ? a1 : CodingErrorAction.REPORT);
+ this.charDecoder.onMalformedInput(a1 != null ? a1 : CodingErrorAction.REPORT);
final CodingErrorAction a2 = (CodingErrorAction) params.getParameter(
CoreProtocolPNames.HTTP_UNMAPPABLE_INPUT_ACTION);
- this.chardecoder.onUnmappableCharacter(a2 != null? a2 : CodingErrorAction.REPORT);
+ this.charDecoder.onUnmappableCharacter(a2 != null? a2 : CodingErrorAction.REPORT);
} else {
- this.chardecoder = null;
+ this.charDecoder = null;
}
this.constraints = MessageConstraints.DEFAULT;
}
@@ -149,49 +149,76 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
*/
@Deprecated
public SessionInputBufferImpl(
- final int buffersize,
- final int linebuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final HttpParams params) {
- this(buffersize, linebuffersize, HeapByteBufferAllocator.INSTANCE, params);
+ this(bufferSize, lineBufferSize, HeapByteBufferAllocator.INSTANCE, params);
}
/**
+ * Creates SessionInputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations. Has effect only if
+ * {@code charset} is not {@code null}.
+ * @param charset Charset to be used for decoding HTTP protocol elements.
+ * If {@code null} simple type cast will be used for byte to char conversion.
+ *
* @since 4.3
*/
public SessionInputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final Charset charset) {
- this(buffersize, lineBuffersize, null,
+ this(bufferSize, lineBufferSize, null,
charset != null ? charset.newDecoder() : null, HeapByteBufferAllocator.INSTANCE);
}
/**
+ * Creates SessionInputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations. Has effect only if
+ * {@code charset} is not {@code null}.
+ * @param charset Charset to be used for decoding HTTP protocol elements.
+ * If {@code null} simple type cast will be used for byte to char conversion.
+ * @param constraints Message constraints. If {@code null}
+ * {@link MessageConstraints#DEFAULT} will be used.
+ *
* @since 4.3
*/
public SessionInputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final MessageConstraints constraints,
final Charset charset) {
- this(buffersize, lineBuffersize, constraints,
+ this(bufferSize, lineBufferSize, constraints,
charset != null ? charset.newDecoder() : null, HeapByteBufferAllocator.INSTANCE);
}
/**
+ * Creates SessionInputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations.
+ *
* @since 4.3
*/
public SessionInputBufferImpl(
- final int buffersize,
- final int lineBuffersize) {
- this(buffersize, lineBuffersize, null, null, HeapByteBufferAllocator.INSTANCE);
+ final int bufferSize,
+ final int lineBufferSize) {
+ this(bufferSize, lineBufferSize, null, null, HeapByteBufferAllocator.INSTANCE);
}
/**
+ * Creates SessionInputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
+ *
* @since 4.3
*/
- public SessionInputBufferImpl(final int buffersize) {
- this(buffersize, 256, null, null, HeapByteBufferAllocator.INSTANCE);
+ public SessionInputBufferImpl(final int bufferSize) {
+ this(bufferSize, 256, null, null, HeapByteBufferAllocator.INSTANCE);
}
@Override
@@ -225,9 +252,8 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
dst.put(this.buffer);
this.buffer.limit(oldLimit);
return len;
- } else {
- dst.put(this.buffer);
}
+ dst.put(this.buffer);
return chunk;
}
@@ -269,7 +295,7 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
@Override
public boolean readLine(
- final CharArrayBuffer linebuffer,
+ final CharArrayBuffer lineBuffer,
final boolean endOfStream) throws CharacterCodingException {
setOutputMode();
@@ -306,41 +332,41 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
final int requiredCapacity = this.buffer.limit() - this.buffer.position();
// Ensure capacity of len assuming ASCII as the most likely charset
- linebuffer.ensureCapacity(requiredCapacity);
+ lineBuffer.ensureCapacity(requiredCapacity);
- if (this.chardecoder == null) {
+ if (this.charDecoder == null) {
if (this.buffer.hasArray()) {
final byte[] b = this.buffer.array();
final int off = this.buffer.position();
final int len = this.buffer.remaining();
- linebuffer.append(b, off, len);
+ lineBuffer.append(b, off, len);
this.buffer.position(off + len);
} else {
while (this.buffer.hasRemaining()) {
- linebuffer.append((char) (this.buffer.get() & 0xff));
+ lineBuffer.append((char) (this.buffer.get() & 0xff));
}
}
} else {
- if (this.charbuffer == null) {
- this.charbuffer = CharBuffer.allocate(this.lineBuffersize);
+ if (this.charBuffer == null) {
+ this.charBuffer = CharBuffer.allocate(this.lineBufferSize);
}
- this.chardecoder.reset();
+ this.charDecoder.reset();
for (;;) {
- final CoderResult result = this.chardecoder.decode(
+ final CoderResult result = this.charDecoder.decode(
this.buffer,
- this.charbuffer,
+ this.charBuffer,
true);
if (result.isError()) {
result.throwException();
}
if (result.isOverflow()) {
- this.charbuffer.flip();
- linebuffer.append(
- this.charbuffer.array(),
- this.charbuffer.position(),
- this.charbuffer.remaining());
- this.charbuffer.clear();
+ this.charBuffer.flip();
+ lineBuffer.append(
+ this.charBuffer.array(),
+ this.charBuffer.position(),
+ this.charBuffer.remaining());
+ this.charBuffer.clear();
}
if (result.isUnderflow()) {
break;
@@ -348,31 +374,31 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
}
// flush the decoder
- this.chardecoder.flush(this.charbuffer);
- this.charbuffer.flip();
+ this.charDecoder.flush(this.charBuffer);
+ this.charBuffer.flip();
// append the decoded content to the line buffer
- if (this.charbuffer.hasRemaining()) {
- linebuffer.append(
- this.charbuffer.array(),
- this.charbuffer.position(),
- this.charbuffer.remaining());
+ if (this.charBuffer.hasRemaining()) {
+ lineBuffer.append(
+ this.charBuffer.array(),
+ this.charBuffer.position(),
+ this.charBuffer.remaining());
}
}
this.buffer.limit(origLimit);
// discard LF if found
- int l = linebuffer.length();
- if (l > 0) {
- if (linebuffer.charAt(l - 1) == HTTP.LF) {
- l--;
- linebuffer.setLength(l);
+ int len = lineBuffer.length();
+ if (len > 0) {
+ if (lineBuffer.charAt(len - 1) == HTTP.LF) {
+ len--;
+ lineBuffer.setLength(len);
}
// discard CR if found
- if (l > 0) {
- if (linebuffer.charAt(l - 1) == HTTP.CR) {
- l--;
- linebuffer.setLength(l);
+ if (len > 0) {
+ if (lineBuffer.charAt(len - 1) == HTTP.CR) {
+ len--;
+ lineBuffer.setLength(len);
}
}
}
@@ -381,13 +407,14 @@ public class SessionInputBufferImpl extends ExpandableBuffer implements SessionI
@Override
public String readLine(final boolean endOfStream) throws CharacterCodingException {
- final CharArrayBuffer buffer = new CharArrayBuffer(64);
- final boolean found = readLine(buffer, endOfStream);
- if (found) {
- return buffer.toString();
- } else {
- return null;
- }
+ final CharArrayBuffer tmpBuffer = new CharArrayBuffer(64);
+ final boolean found = readLine(tmpBuffer, endOfStream);
+ return found ? tmpBuffer.toString() : null;
+ }
+
+ @Override
+ public void clear() {
+ super.clear();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
index 70a66ef21..fd2f02214 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionOutputBufferImpl.java
@@ -60,18 +60,18 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
private static final byte[] CRLF = new byte[] {HTTP.CR, HTTP.LF};
- private final CharsetEncoder charencoder;
- private final int lineBuffersize;
+ private final CharsetEncoder charEncoder;
+ private final int lineBufferSize;
- private CharBuffer charbuffer;
+ private CharBuffer charBuffer;
/**
* Creates SessionOutputBufferImpl instance.
*
- * @param buffersize input buffer size
- * @param lineBuffersize buffer size for line operations. Has effect only if
- * {@code charencoder} is not {@code null}.
- * @param charencoder charencoder to be used for encoding HTTP protocol elements.
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations. Has effect only if
+ * {@code charEncoder} is not {@code null}.
+ * @param charEncoder CharEncoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param allocator memory allocator.
* If {@code null} {@link HeapByteBufferAllocator#INSTANCE} will be used.
@@ -79,13 +79,13 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
* @since 4.3
*/
public SessionOutputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
- final CharsetEncoder charencoder,
+ final int bufferSize,
+ final int lineBufferSize,
+ final CharsetEncoder charEncoder,
final ByteBufferAllocator allocator) {
- super(buffersize, allocator != null ? allocator : HeapByteBufferAllocator.INSTANCE);
- this.lineBuffersize = Args.positive(lineBuffersize, "Line buffer size");
- this.charencoder = charencoder;
+ super(bufferSize, allocator != null ? allocator : HeapByteBufferAllocator.INSTANCE);
+ this.lineBufferSize = Args.positive(lineBufferSize, "Line buffer size");
+ this.charEncoder = charEncoder;
}
/**
@@ -95,24 +95,24 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
*/
@Deprecated
public SessionOutputBufferImpl(
- final int buffersize,
- final int lineBuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final ByteBufferAllocator allocator,
final HttpParams params) {
- super(buffersize, allocator);
- this.lineBuffersize = Args.positive(lineBuffersize, "Line buffer size");
+ super(bufferSize, allocator);
+ this.lineBufferSize = Args.positive(lineBufferSize, "Line buffer size");
final String charsetName = (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
final Charset charset = CharsetUtils.lookup(charsetName);
if (charset != null) {
- this.charencoder = charset.newEncoder();
+ this.charEncoder = charset.newEncoder();
final CodingErrorAction a1 = (CodingErrorAction) params.getParameter(
CoreProtocolPNames.HTTP_MALFORMED_INPUT_ACTION);
- this.charencoder.onMalformedInput(a1 != null ? a1 : CodingErrorAction.REPORT);
+ this.charEncoder.onMalformedInput(a1 != null ? a1 : CodingErrorAction.REPORT);
final CodingErrorAction a2 = (CodingErrorAction) params.getParameter(
CoreProtocolPNames.HTTP_UNMAPPABLE_INPUT_ACTION);
- this.charencoder.onUnmappableCharacter(a2 != null? a2 : CodingErrorAction.REPORT);
+ this.charEncoder.onUnmappableCharacter(a2 != null? a2 : CodingErrorAction.REPORT);
} else {
- this.charencoder = null;
+ this.charEncoder = null;
}
}
@@ -122,37 +122,53 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
*/
@Deprecated
public SessionOutputBufferImpl(
- final int buffersize,
- final int linebuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final HttpParams params) {
- this(buffersize, linebuffersize, HeapByteBufferAllocator.INSTANCE, params);
+ this(bufferSize, lineBufferSize, HeapByteBufferAllocator.INSTANCE, params);
}
/**
+ * Creates SessionOutputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
* @since 4.3
*/
- public SessionOutputBufferImpl(final int buffersize) {
- this(buffersize, 256, null, HeapByteBufferAllocator.INSTANCE);
+ public SessionOutputBufferImpl(final int bufferSize) {
+ this(bufferSize, 256, null, HeapByteBufferAllocator.INSTANCE);
}
/**
+ * Creates SessionOutputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations. Has effect only if
+ * {@code charset} is not {@code null}.
+ * @param charset Charset to be used for encoding HTTP protocol elements.
+ * If {@code null} simple type cast will be used for char to byte conversion.
+ *
* @since 4.3
*/
public SessionOutputBufferImpl(
- final int buffersize,
- final int linebuffersize,
+ final int bufferSize,
+ final int lineBufferSize,
final Charset charset) {
- this(buffersize, linebuffersize,
+ this(bufferSize, lineBufferSize,
charset != null ? charset.newEncoder() : null, HeapByteBufferAllocator.INSTANCE);
}
/**
+ * Creates SessionOutputBufferImpl instance.
+ *
+ * @param bufferSize input buffer size.
+ * @param lineBufferSize buffer size for line operations.
+ *
* @since 4.3
*/
public SessionOutputBufferImpl(
- final int buffersize,
- final int linebuffersize) {
- this(buffersize, linebuffersize, null, HeapByteBufferAllocator.INSTANCE);
+ final int bufferSize,
+ final int lineBufferSize) {
+ this(bufferSize, lineBufferSize, null, HeapByteBufferAllocator.INSTANCE);
}
public void reset(final HttpParams params) {
@@ -203,51 +219,51 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
}
@Override
- public void writeLine(final CharArrayBuffer linebuffer) throws CharacterCodingException {
- if (linebuffer == null) {
+ public void writeLine(final CharArrayBuffer lineBuffer) throws CharacterCodingException {
+ if (lineBuffer == null) {
return;
}
setInputMode();
// Do not bother if the buffer is empty
- if (linebuffer.length() > 0 ) {
- if (this.charencoder == null) {
- final int requiredCapacity = this.buffer.position() + linebuffer.length();
+ if (lineBuffer.length() > 0 ) {
+ if (this.charEncoder == null) {
+ final int requiredCapacity = this.buffer.position() + lineBuffer.length();
ensureCapacity(requiredCapacity);
if (this.buffer.hasArray()) {
final byte[] b = this.buffer.array();
- final int len = linebuffer.length();
+ final int len = lineBuffer.length();
final int off = this.buffer.position();
for (int i = 0; i < len; i++) {
- b[off + i] = (byte) linebuffer.charAt(i);
+ b[off + i] = (byte) lineBuffer.charAt(i);
}
this.buffer.position(off + len);
} else {
- for (int i = 0; i < linebuffer.length(); i++) {
- this.buffer.put((byte) linebuffer.charAt(i));
+ for (int i = 0; i < lineBuffer.length(); i++) {
+ this.buffer.put((byte) lineBuffer.charAt(i));
}
}
} else {
- if (this.charbuffer == null) {
- this.charbuffer = CharBuffer.allocate(this.lineBuffersize);
+ if (this.charBuffer == null) {
+ this.charBuffer = CharBuffer.allocate(this.lineBufferSize);
}
- this.charencoder.reset();
+ this.charEncoder.reset();
// transfer the string in small chunks
- int remaining = linebuffer.length();
+ int remaining = lineBuffer.length();
int offset = 0;
while (remaining > 0) {
- int l = this.charbuffer.remaining();
+ int l = this.charBuffer.remaining();
boolean eol = false;
if (remaining <= l) {
l = remaining;
// terminate the encoding process
eol = true;
}
- this.charbuffer.put(linebuffer.buffer(), offset, l);
- this.charbuffer.flip();
+ this.charBuffer.put(lineBuffer.buffer(), offset, l);
+ this.charBuffer.flip();
boolean retry = true;
while (retry) {
- final CoderResult result = this.charencoder.encode(this.charbuffer, this.buffer, eol);
+ final CoderResult result = this.charEncoder.encode(this.charBuffer, this.buffer, eol);
if (result.isError()) {
result.throwException();
}
@@ -256,14 +272,14 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
}
retry = !result.isUnderflow();
}
- this.charbuffer.compact();
+ this.charBuffer.compact();
offset += l;
remaining -= l;
}
// flush the encoder
boolean retry = true;
while (retry) {
- final CoderResult result = this.charencoder.flush(this.buffer);
+ final CoderResult result = this.charEncoder.flush(this.buffer);
if (result.isError()) {
result.throwException();
}
@@ -291,4 +307,9 @@ public class SessionOutputBufferImpl extends ExpandableBuffer implements Session
}
}
+ @Override
+ public void clear() {
+ super.clear();
+ }
+
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionRequestHandle.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionRequestHandle.java
index b44097a16..9c7f622b1 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionRequestHandle.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionRequestHandle.java
@@ -27,12 +27,11 @@
package com.fr.third.org.apache.http.impl.nio.reactor;
-import com.fr.third.org.apache.http.nio.reactor.SessionRequest;
import com.fr.third.org.apache.http.util.Args;
/**
* Session request handle class used by I/O reactor implementations to keep
- * a reference to a {@link SessionRequest} along
+ * a reference to a {@link com.fr.third.org.apache.http.nio.reactor.SessionRequest} along
* with the time the request was made.
*
* @since 4.0
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionRequestImpl.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionRequestImpl.java
index 0cb8af06a..c13b2b709 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionRequestImpl.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/impl/nio/reactor/SessionRequestImpl.java
@@ -31,9 +31,10 @@ import java.io.IOException;
import java.net.SocketAddress;
import java.nio.channels.Channel;
import java.nio.channels.SelectionKey;
+import java.util.concurrent.atomic.AtomicReference;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.nio.reactor.IOSession;
import com.fr.third.org.apache.http.nio.reactor.SessionRequest;
import com.fr.third.org.apache.http.nio.reactor.SessionRequestCallback;
@@ -47,13 +48,21 @@ import com.fr.third.org.apache.http.util.Args;
@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
public class SessionRequestImpl implements SessionRequest {
- private volatile boolean completed;
- private volatile SelectionKey key;
+ enum SessionRequestState {
+ ACTIVE,
+ SUCCESSFUL,
+ TIMEDOUT,
+ CANCELLED,
+ FAILED,
+ }
private final SocketAddress remoteAddress;
private final SocketAddress localAddress;
private final Object attachment;
private final SessionRequestCallback callback;
+ private final AtomicReference state;
+
+ private volatile SelectionKey key;
private volatile int connectTimeout;
private volatile IOSession session = null;
@@ -70,7 +79,7 @@ public class SessionRequestImpl implements SessionRequest {
this.localAddress = localAddress;
this.attachment = attachment;
this.callback = callback;
- this.connectTimeout = 0;
+ this.state = new AtomicReference(SessionRequestState.ACTIVE);
}
@Override
@@ -90,20 +99,33 @@ public class SessionRequestImpl implements SessionRequest {
@Override
public boolean isCompleted() {
- return this.completed;
+ return this.state.get().compareTo(SessionRequestState.ACTIVE) != 0;
+ }
+
+ boolean isTerminated() {
+ return this.state.get().compareTo(SessionRequestState.SUCCESSFUL) > 0;
}
protected void setKey(final SelectionKey key) {
this.key = key;
+ if (this.isCompleted()) {
+ key.cancel();
+ final Channel channel = key.channel();
+ if (channel.isOpen()) {
+ try {
+ channel.close();
+ } catch (final IOException ignore) {}
+ }
+ }
}
@Override
public void waitFor() throws InterruptedException {
- if (this.completed) {
+ if (this.isCompleted()) {
return;
}
synchronized (this) {
- while (!this.completed) {
+ while (!this.isCompleted()) {
wait();
}
}
@@ -125,16 +147,14 @@ public class SessionRequestImpl implements SessionRequest {
public void completed(final IOSession session) {
Args.notNull(session, "Session");
- if (this.completed) {
- return;
- }
- this.completed = true;
- synchronized (this) {
- this.session = session;
- if (this.callback != null) {
- this.callback.completed(this);
+ if (this.state.compareAndSet(SessionRequestState.ACTIVE, SessionRequestState.SUCCESSFUL)) {
+ synchronized (this) {
+ this.session = session;
+ if (this.callback != null) {
+ this.callback.completed(this);
+ }
+ notifyAll();
}
- notifyAll();
}
}
@@ -142,45 +162,41 @@ public class SessionRequestImpl implements SessionRequest {
if (exception == null) {
return;
}
- if (this.completed) {
- return;
- }
- this.completed = true;
- final SelectionKey key = this.key;
- if (key != null) {
- key.cancel();
- final Channel channel = key.channel();
- try {
- channel.close();
- } catch (final IOException ignore) {}
- }
- synchronized (this) {
- this.exception = exception;
- if (this.callback != null) {
- this.callback.failed(this);
+ if (this.state.compareAndSet(SessionRequestState.ACTIVE, SessionRequestState.FAILED)) {
+ final SelectionKey key = this.key;
+ if (key != null) {
+ key.cancel();
+ final Channel channel = key.channel();
+ try {
+ channel.close();
+ } catch (final IOException ignore) {}
+ }
+ synchronized (this) {
+ this.exception = exception;
+ if (this.callback != null) {
+ this.callback.failed(this);
+ }
+ notifyAll();
}
- notifyAll();
}
}
public void timeout() {
- if (this.completed) {
- return;
- }
- this.completed = true;
- final SelectionKey key = this.key;
- if (key != null) {
- key.cancel();
- final Channel channel = key.channel();
- if (channel.isOpen()) {
- try {
- channel.close();
- } catch (final IOException ignore) {}
+ if (this.state.compareAndSet(SessionRequestState.ACTIVE, SessionRequestState.TIMEDOUT)) {
+ final SelectionKey key = this.key;
+ if (key != null) {
+ key.cancel();
+ final Channel channel = key.channel();
+ if (channel.isOpen()) {
+ try {
+ channel.close();
+ } catch (final IOException ignore) {}
+ }
}
- }
- synchronized (this) {
- if (this.callback != null) {
- this.callback.timeout(this);
+ synchronized (this) {
+ if (this.callback != null) {
+ this.callback.timeout(this);
+ }
}
}
}
@@ -203,25 +219,23 @@ public class SessionRequestImpl implements SessionRequest {
@Override
public void cancel() {
- if (this.completed) {
- return;
- }
- this.completed = true;
- final SelectionKey key = this.key;
- if (key != null) {
- key.cancel();
- final Channel channel = key.channel();
- if (channel.isOpen()) {
- try {
- channel.close();
- } catch (final IOException ignore) {}
+ if (this.state.compareAndSet(SessionRequestState.ACTIVE, SessionRequestState.CANCELLED)) {
+ final SelectionKey key = this.key;
+ if (key != null) {
+ key.cancel();
+ final Channel channel = key.channel();
+ if (channel.isOpen()) {
+ try {
+ channel.close();
+ } catch (final IOException ignore) {}
+ }
}
- }
- synchronized (this) {
- if (this.callback != null) {
- this.callback.cancelled(this);
+ synchronized (this) {
+ if (this.callback != null) {
+ this.callback.cancelled(this);
+ }
+ notifyAll();
}
- notifyAll();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/FileContentDecoder.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/FileContentDecoder.java
index 70a31547f..177e715f0 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/FileContentDecoder.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/FileContentDecoder.java
@@ -39,11 +39,12 @@ public interface FileContentDecoder extends ContentDecoder {
/**
* Transfers a portion of entity content from the underlying network channel
- * into the given file channel.
- *
+ * into the given file channel.
+ *
* Warning: Many implementations cannot write beyond the length of the file.
* If the position exceeds the channel's size, some implementations
* may throw an IOException.
+ *
*
* @param dst the target FileChannel to transfer data into.
* @param position
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/NHttpClientIOTarget.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/NHttpClientIOTarget.java
index f63cf5e81..3e7879ec3 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/NHttpClientIOTarget.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/NHttpClientIOTarget.java
@@ -27,11 +27,9 @@
package com.fr.third.org.apache.http.nio;
-import com.fr.third.org.apache.http.nio.reactor.IOEventDispatch;
-
/**
* Extended version of the {@link NHttpClientConnection} used by
- * {@link IOEventDispatch} implementations
+ * {@link com.fr.third.org.apache.http.nio.reactor.IOEventDispatch} implementations
* to inform client-side connection objects of I/O events.
*
* @since 4.0
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/NHttpConnection.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/NHttpConnection.java
index b0dc2f594..b9bbd15ed 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/NHttpConnection.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/NHttpConnection.java
@@ -50,9 +50,9 @@ import com.fr.third.org.apache.http.protocol.HttpContext;
*/
public interface NHttpConnection extends HttpConnection, IOControl {
- public static final int ACTIVE = 0;
- public static final int CLOSING = 1;
- public static final int CLOSED = 2;
+ int ACTIVE = 0;
+ int CLOSING = 1;
+ int CLOSED = 2;
/**
* Returns status of the connection:
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/NHttpServerIOTarget.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/NHttpServerIOTarget.java
index 0cfe367af..7a7e8edf7 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/NHttpServerIOTarget.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/NHttpServerIOTarget.java
@@ -27,11 +27,9 @@
package com.fr.third.org.apache.http.nio;
-import com.fr.third.org.apache.http.nio.reactor.IOEventDispatch;
-
/**
* Extended version of the {@link NHttpServerConnection} used by
- * {@link IOEventDispatch } implementations
+ * {@link com.fr.third.org.apache.http.nio.reactor.IOEventDispatch } implementations
* to inform server-side connection objects of I/O events.
*
* @since 4.0
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/ConsumingNHttpEntity.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/ConsumingNHttpEntity.java
index b84cad504..cc96165ee 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/ConsumingNHttpEntity.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/ConsumingNHttpEntity.java
@@ -30,8 +30,6 @@ package com.fr.third.org.apache.http.nio.entity;
import java.io.IOException;
import com.fr.third.org.apache.http.HttpEntity;
-import com.fr.third.org.apache.http.nio.protocol.BasicAsyncRequestProducer;
-import com.fr.third.org.apache.http.nio.protocol.BasicAsyncResponseProducer;
import com.fr.third.org.apache.http.nio.ContentDecoder;
import com.fr.third.org.apache.http.nio.IOControl;
@@ -42,8 +40,8 @@ import com.fr.third.org.apache.http.nio.IOControl;
* @since 4.0
*
* @deprecated use (4.2)
- * {@link BasicAsyncRequestProducer}
- * or {@link BasicAsyncResponseProducer}
+ * {@link com.fr.third.org.apache.http.nio.protocol.BasicAsyncRequestProducer}
+ * or {@link com.fr.third.org.apache.http.nio.protocol.BasicAsyncResponseProducer}
*/
@Deprecated
public interface ConsumingNHttpEntity extends HttpEntity {
@@ -55,9 +53,9 @@ public interface ConsumingNHttpEntity extends HttpEntity {
* allocate more storage to accommodate all incoming content.
*
* @param decoder content decoder.
- * @param ioctrl I/O control of the underlying connection.
+ * @param ioControl I/O control of the underlying connection.
*/
- void consumeContent(ContentDecoder decoder, IOControl ioctrl) throws IOException;
+ void consumeContent(ContentDecoder decoder, IOControl ioControl) throws IOException;
/**
* Notification that any resources allocated for reading can be released.
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/ContentInputStream.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/ContentInputStream.java
index cc99342b8..7da09e16c 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/ContentInputStream.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/ContentInputStream.java
@@ -51,11 +51,7 @@ public class ContentInputStream extends InputStream {
@Override
public int available() throws IOException {
- if (this.buffer instanceof BufferInfo) {
- return ((BufferInfo) this.buffer).length();
- } else {
- return super.available();
- }
+ return this.buffer instanceof BufferInfo ? ((BufferInfo) this.buffer).length() : super.available();
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/EntityAsyncContentProducer.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/EntityAsyncContentProducer.java
index 1d7bdc62c..0b0543781 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/EntityAsyncContentProducer.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/EntityAsyncContentProducer.java
@@ -41,7 +41,7 @@ import com.fr.third.org.apache.http.util.Args;
/**
* Basic implementation of {@link HttpAsyncContentProducer} that relies on
* inefficient and potentially blocking I/O operation redirection through
- * {@link Channels#newChannel(java.io.InputStream)}.
+ * {@link Channels#newChannel(InputStream)}.
*
* @since 4.2
*/
@@ -60,7 +60,7 @@ public class EntityAsyncContentProducer implements HttpAsyncContentProducer {
@Override
public void produceContent(
- final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
+ final ContentEncoder encoder, final IOControl ioControl) throws IOException {
if (this.channel == null) {
this.channel = Channels.newChannel(this.entity.getContent());
}
@@ -88,8 +88,8 @@ public class EntityAsyncContentProducer implements HttpAsyncContentProducer {
local.close();
}
if (this.entity.isStreaming()) {
- final InputStream instream = this.entity.getContent();
- instream.close();
+ final InputStream inStream = this.entity.getContent();
+ inStream.close();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/HttpAsyncContentProducer.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/HttpAsyncContentProducer.java
index 6d21d122b..35319f8c8 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/HttpAsyncContentProducer.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/HttpAsyncContentProducer.java
@@ -56,9 +56,9 @@ public interface HttpAsyncContentProducer extends Closeable {
* to resume output event notifications when more content is made available.
*
* @param encoder content encoder.
- * @param ioctrl I/O control of the underlying connection.
+ * @param ioControl I/O control of the underlying connection.
*/
- void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException;
+ void produceContent(ContentEncoder encoder, IOControl ioControl) throws IOException;
/**
* Determines whether or not this producer is capable of producing
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/NByteArrayEntity.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/NByteArrayEntity.java
index dcbd10ec9..698632acc 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/NByteArrayEntity.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/NByteArrayEntity.java
@@ -131,7 +131,7 @@ public class NByteArrayEntity extends AbstractHttpEntity
}
@Override
- public void produceContent(final ContentEncoder encoder, final IOControl ioctrl)
+ public void produceContent(final ContentEncoder encoder, final IOControl ioControl)
throws IOException {
encoder.write(this.buf);
if(!this.buf.hasRemaining()) {
@@ -160,10 +160,10 @@ public class NByteArrayEntity extends AbstractHttpEntity
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- outstream.write(this.b, this.off, this.len);
- outstream.flush();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ outStream.write(this.b, this.off, this.len);
+ outStream.flush();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/NFileEntity.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/NFileEntity.java
index 930cfae86..7471ec8a6 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/NFileEntity.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/NFileEntity.java
@@ -158,7 +158,7 @@ public class NFileEntity extends AbstractHttpEntity
}
@Override
- public void produceContent(final ContentEncoder encoder, final IOControl ioctrl)
+ public void produceContent(final ContentEncoder encoder, final IOControl ioControl)
throws IOException {
if (accessfile == null) {
accessfile = new RandomAccessFile(this.file, "r");
@@ -196,18 +196,18 @@ public class NFileEntity extends AbstractHttpEntity
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = new FileInputStream(this.file);
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = new FileInputStream(this.file);
try {
final byte[] tmp = new byte[4096];
int l;
- while ((l = instream.read(tmp)) != -1) {
- outstream.write(tmp, 0, l);
+ while ((l = inStream.read(tmp)) != -1) {
+ outStream.write(tmp, 0, l);
}
- outstream.flush();
+ outStream.flush();
} finally {
- instream.close();
+ inStream.close();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/NStringEntity.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/NStringEntity.java
index 68675fec2..1eca1f9b7 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/NStringEntity.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/NStringEntity.java
@@ -171,7 +171,7 @@ public class NStringEntity extends AbstractHttpEntity
@Override
public void produceContent(
- final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
+ final ContentEncoder encoder, final IOControl ioControl) throws IOException {
encoder.write(this.buf);
if (!this.buf.hasRemaining()) {
encoder.complete();
@@ -189,10 +189,10 @@ public class NStringEntity extends AbstractHttpEntity
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- outstream.write(this.b);
- outstream.flush();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ outStream.write(this.b);
+ outStream.flush();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/ProducingNHttpEntity.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/ProducingNHttpEntity.java
index 443d5de64..3867f26cd 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/ProducingNHttpEntity.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/entity/ProducingNHttpEntity.java
@@ -30,8 +30,6 @@ package com.fr.third.org.apache.http.nio.entity;
import java.io.IOException;
import com.fr.third.org.apache.http.HttpEntity;
-import com.fr.third.org.apache.http.nio.protocol.BasicAsyncRequestProducer;
-import com.fr.third.org.apache.http.nio.protocol.BasicAsyncResponseProducer;
import com.fr.third.org.apache.http.nio.ContentEncoder;
import com.fr.third.org.apache.http.nio.IOControl;
@@ -42,8 +40,8 @@ import com.fr.third.org.apache.http.nio.IOControl;
* @since 4.0
*
* @deprecated use (4.2)
- * {@link BasicAsyncRequestProducer}
- * or {@link BasicAsyncResponseProducer}
+ * {@link com.fr.third.org.apache.http.nio.protocol.BasicAsyncRequestProducer}
+ * or {@link com.fr.third.org.apache.http.nio.protocol.BasicAsyncResponseProducer}
*/
@Deprecated
public interface ProducingNHttpEntity extends HttpEntity {
@@ -58,9 +56,9 @@ public interface ProducingNHttpEntity extends HttpEntity {
* Failure to do so could result in the entity never being written.
*
* @param encoder content encoder.
- * @param ioctrl I/O control of the underlying connection.
+ * @param ioControl I/O control of the underlying connection.
*/
- void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException;
+ void produceContent(ContentEncoder encoder, IOControl ioControl) throws IOException;
/**
* Notification that any resources allocated for writing can be released.
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/params/NIOReactorPNames.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/params/NIOReactorPNames.java
index 03e4adcfe..8a152c591 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/params/NIOReactorPNames.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/params/NIOReactorPNames.java
@@ -27,14 +27,12 @@
package com.fr.third.org.apache.http.nio.params;
-import com.fr.third.org.apache.http.impl.nio.reactor.IOReactorConfig;
-
/**
* Parameter names for I/O reactors.
*
* @since 4.0
*
- * @deprecated (4.2) use {@link IOReactorConfig}
+ * @deprecated (4.2) use {@link com.fr.third.org.apache.http.impl.nio.reactor.IOReactorConfig}
*/
@Deprecated
public interface NIOReactorPNames {
@@ -46,7 +44,7 @@ public interface NIOReactorPNames {
* This parameter expects a value of type {@link Integer}.
*
*/
- public static final String CONTENT_BUFFER_SIZE = "http.nio.content-buffer-size";
+ String CONTENT_BUFFER_SIZE = "http.nio.content-buffer-size";
/**
* Determines the time interval in milliseconds at which the
@@ -55,7 +53,7 @@ public interface NIOReactorPNames {
* This parameter expects a value of type {@link Long}.
*
*/
- public static final String SELECT_INTERVAL = "http.nio.select-interval";
+ String SELECT_INTERVAL = "http.nio.select-interval";
/**
* Determines the grace period the I/O reactors are expected to block
@@ -64,7 +62,7 @@ public interface NIOReactorPNames {
* This parameter expects a value of type {@link Long}.
*
*/
- public static final String GRACE_PERIOD = "http.nio.grace-period";
+ String GRACE_PERIOD = "http.nio.grace-period";
/**
* Determines whether interestOps() queueing is enabled for the I/O reactors.
@@ -74,6 +72,6 @@ public interface NIOReactorPNames {
*
* @since 4.1
*/
- public static final String INTEREST_OPS_QUEUEING = "http.nio.interest-ops-queueing";
+ String INTEREST_OPS_QUEUEING = "http.nio.interest-ops-queueing";
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/pool/AbstractNIOConnPool.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/pool/AbstractNIOConnPool.java
index 47cb48512..4a103f54f 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/pool/AbstractNIOConnPool.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/pool/AbstractNIOConnPool.java
@@ -36,6 +36,7 @@ import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -74,7 +75,7 @@ import com.fr.third.org.apache.http.util.LangUtils;
public abstract class AbstractNIOConnPool>
implements ConnPool, ConnPoolControl {
- private final ConnectingIOReactor ioreactor;
+ private final ConnectingIOReactor ioReactor;
private final NIOConnFactory connFactory;
private final SocketAddressResolver addressResolver;
private final SessionRequestCallback sessionRequestCallback;
@@ -97,16 +98,16 @@ public abstract class AbstractNIOConnPool>
*/
@Deprecated
public AbstractNIOConnPool(
- final ConnectingIOReactor ioreactor,
+ final ConnectingIOReactor ioReactor,
final NIOConnFactory connFactory,
final int defaultMaxPerRoute,
final int maxTotal) {
super();
- Args.notNull(ioreactor, "I/O reactor");
+ Args.notNull(ioReactor, "I/O reactor");
Args.notNull(connFactory, "Connection factory");
Args.positive(defaultMaxPerRoute, "Max per route value");
Args.positive(maxTotal, "Max total value");
- this.ioreactor = ioreactor;
+ this.ioReactor = ioReactor;
this.connFactory = connFactory;
this.addressResolver = new SocketAddressResolver() {
@@ -139,18 +140,18 @@ public abstract class AbstractNIOConnPool>
* @since 4.3
*/
public AbstractNIOConnPool(
- final ConnectingIOReactor ioreactor,
+ final ConnectingIOReactor ioReactor,
final NIOConnFactory connFactory,
final SocketAddressResolver addressResolver,
final int defaultMaxPerRoute,
final int maxTotal) {
super();
- Args.notNull(ioreactor, "I/O reactor");
+ Args.notNull(ioReactor, "I/O reactor");
Args.notNull(connFactory, "Connection factory");
Args.notNull(addressResolver, "Address resolver");
Args.positive(defaultMaxPerRoute, "Max per route value");
Args.positive(maxTotal, "Max total value");
- this.ioreactor = ioreactor;
+ this.ioReactor = ioReactor;
this.connFactory = connFactory;
this.addressResolver = addressResolver;
this.sessionRequestCallback = new InternalSessionRequestCallback();
@@ -229,7 +230,7 @@ public abstract class AbstractNIOConnPool>
this.pending.clear();
this.available.clear();
this.leasingRequests.clear();
- this.ioreactor.shutdown(waitMs);
+ this.ioReactor.shutdown(waitMs);
} finally {
this.lock.unlock();
}
@@ -254,9 +255,9 @@ public abstract class AbstractNIOConnPool>
public Future lease(
final T route, final Object state,
- final long connectTimeout, final TimeUnit tunit,
+ final long connectTimeout, final TimeUnit timeUnit,
final FutureCallback callback) {
- return this.lease(route, state, connectTimeout, connectTimeout, tunit, callback);
+ return this.lease(route, state, connectTimeout, connectTimeout, timeUnit, callback);
}
/**
@@ -264,28 +265,63 @@ public abstract class AbstractNIOConnPool>
*/
public Future lease(
final T route, final Object state,
- final long connectTimeout, final long leaseTimeout, final TimeUnit tunit,
+ final long connectTimeout, final long leaseTimeout, final TimeUnit timeUnit,
final FutureCallback callback) {
Args.notNull(route, "Route");
- Args.notNull(tunit, "Time unit");
+ Args.notNull(timeUnit, "Time unit");
Asserts.check(!this.isShutDown.get(), "Connection pool shut down");
final BasicFuture future = new BasicFuture(callback);
+ final LeaseRequest leaseRequest = new LeaseRequest(route, state,
+ connectTimeout >= 0 ? timeUnit.toMillis(connectTimeout) : -1,
+ leaseTimeout > 0 ? timeUnit.toMillis(leaseTimeout) : 0,
+ future);
this.lock.lock();
try {
- final long timeout = connectTimeout > 0 ? tunit.toMillis(connectTimeout) : 0;
- final LeaseRequest request = new LeaseRequest(route, state, timeout, leaseTimeout, future);
- final boolean completed = processPendingRequest(request);
- if (!request.isDone() && !completed) {
- this.leasingRequests.add(request);
+ final boolean completed = processPendingRequest(leaseRequest);
+ if (!leaseRequest.isDone() && !completed) {
+ this.leasingRequests.add(leaseRequest);
}
- if (request.isDone()) {
- this.completedRequests.add(request);
+ if (leaseRequest.isDone()) {
+ this.completedRequests.add(leaseRequest);
}
} finally {
this.lock.unlock();
}
fireCallbacks();
- return future;
+ return new Future() {
+
+ @Override
+ public E get() throws InterruptedException, ExecutionException {
+ return future.get();
+ }
+
+ @Override
+ public E get(
+ final long timeout,
+ final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
+ return future.get(timeout, unit);
+ }
+
+ @Override
+ public boolean cancel(final boolean mayInterruptIfRunning) {
+ try {
+ leaseRequest.cancel();
+ } finally {
+ return future.cancel(mayInterruptIfRunning);
+ }
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return future.isCancelled();
+ }
+
+ @Override
+ public boolean isDone() {
+ return future.isDone();
+ }
+
+ };
}
@Override
@@ -372,7 +408,7 @@ public abstract class AbstractNIOConnPool>
final long now = System.currentTimeMillis();
if (now > deadline) {
- request.failed(new TimeoutException());
+ request.failed(new TimeoutException("Connection lease request time out"));
return false;
}
@@ -442,17 +478,18 @@ public abstract class AbstractNIOConnPool>
return false;
}
- final SessionRequest sessionRequest = this.ioreactor.connect(
+ final SessionRequest sessionRequest = this.ioReactor.connect(
remoteAddress, localAddress, route, this.sessionRequestCallback);
- final int timout = request.getConnectTimeout() < Integer.MAX_VALUE ?
- (int) request.getConnectTimeout() : Integer.MAX_VALUE;
- sessionRequest.setConnectTimeout(timout);
+ request.attachSessionRequest(sessionRequest);
+ final long connectTimeout = request.getConnectTimeout();
+ if (connectTimeout >= 0) {
+ sessionRequest.setConnectTimeout(connectTimeout < Integer.MAX_VALUE ? (int) connectTimeout : Integer.MAX_VALUE);
+ }
this.pending.add(sessionRequest);
pool.addPending(sessionRequest, request.getFuture());
return true;
- } else {
- return false;
}
+ return false;
}
private void fireCallbacks() {
@@ -484,11 +521,18 @@ public abstract class AbstractNIOConnPool>
final ListIterator> it = this.leasingRequests.listIterator();
while (it.hasNext()) {
final LeaseRequest request = it.next();
- final long deadline = request.getDeadline();
- if (now > deadline) {
+ final BasicFuture future = request.getFuture();
+ if (future.isCancelled() && !request.isDone()) {
it.remove();
- request.failed(new TimeoutException());
- this.completedRequests.add(request);
+ } else {
+ final long deadline = request.getDeadline();
+ if (now > deadline) {
+ request.failed(new TimeoutException("Connection lease request time out"));
+ }
+ if (request.isDone()) {
+ it.remove();
+ this.completedRequests.add(request);
+ }
}
}
} finally {
@@ -499,6 +543,10 @@ public abstract class AbstractNIOConnPool>
protected void requestCompleted(final SessionRequest request) {
if (this.isShutDown.get()) {
+ final IOSession session = request.getSession();
+ if (session != null) {
+ session.close();
+ }
return;
}
@SuppressWarnings("unchecked")
@@ -517,7 +565,7 @@ public abstract class AbstractNIOConnPool>
onLease(entry);
} else {
this.available.add(entry);
- if (this.ioreactor.getStatus().compareTo(IOReactorStatus.ACTIVE) <= 0) {
+ if (this.ioReactor.getStatus().compareTo(IOReactorStatus.ACTIVE) <= 0) {
processNextPendingRequest();
}
}
@@ -542,7 +590,7 @@ public abstract class AbstractNIOConnPool>
this.pending.remove(request);
final RouteSpecificPool pool = getPool(route);
pool.cancelled(request);
- if (this.ioreactor.getStatus().compareTo(IOReactorStatus.ACTIVE) <= 0) {
+ if (this.ioReactor.getStatus().compareTo(IOReactorStatus.ACTIVE) <= 0) {
processNextPendingRequest();
}
} finally {
@@ -591,11 +639,7 @@ public abstract class AbstractNIOConnPool>
private int getMax(final T route) {
final Integer v = this.maxPerRoute.get(route);
- if (v != null) {
- return v.intValue();
- } else {
- return this.defaultMaxPerRoute;
- }
+ return v != null ? v.intValue() : this.defaultMaxPerRoute;
}
@Override
@@ -643,10 +687,13 @@ public abstract class AbstractNIOConnPool>
@Override
public void setMaxPerRoute(final T route, final int max) {
Args.notNull(route, "Route");
- Args.positive(max, "Max value");
this.lock.lock();
try {
- this.maxPerRoute.put(route, Integer.valueOf(max));
+ if (max > -1) {
+ this.maxPerRoute.put(route, Integer.valueOf(max));
+ } else {
+ this.maxPerRoute.remove(route);
+ }
} finally {
this.lock.unlock();
}
@@ -684,7 +731,7 @@ public abstract class AbstractNIOConnPool>
try {
final RouteSpecificPool pool = getPool(route);
int pendingCount = 0;
- for (LeaseRequest request: leasingRequests) {
+ for (final LeaseRequest request: leasingRequests) {
if (LangUtils.equals(route, request.getRoute())) {
pendingCount++;
}
@@ -758,8 +805,8 @@ public abstract class AbstractNIOConnPool>
}
/**
- * Use {@link #enumLeased(PoolEntryCallback)}
- * or {@link #enumAvailable(PoolEntryCallback)} instead.
+ * Use {@link #enumLeased(org.apache.http.pool.PoolEntryCallback)}
+ * or {@link #enumAvailable(org.apache.http.pool.PoolEntryCallback)} instead.
*
* @deprecated (4.3.2)
*/
@@ -783,9 +830,9 @@ public abstract class AbstractNIOConnPool>
}
}
- public void closeIdle(final long idletime, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
- long time = tunit.toMillis(idletime);
+ public void closeIdle(final long idletime, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
+ long time = timeUnit.toMillis(idletime);
if (time < 0) {
time = 0;
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/pool/LeaseRequest.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/pool/LeaseRequest.java
index 420239001..93338fced 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/pool/LeaseRequest.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/pool/LeaseRequest.java
@@ -26,18 +26,23 @@
*/
package com.fr.third.org.apache.http.nio.pool;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
import com.fr.third.org.apache.http.concurrent.BasicFuture;
+import com.fr.third.org.apache.http.concurrent.Cancellable;
+import com.fr.third.org.apache.http.nio.reactor.SessionRequest;
import com.fr.third.org.apache.http.pool.PoolEntry;
+import com.fr.third.org.apache.http.util.Asserts;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-class LeaseRequest> {
+class LeaseRequest> implements Cancellable {
private final T route;
private final Object state;
private final long connectTimeout;
private final long deadline;
private final BasicFuture future;
+ private final AtomicReference sessionRequestRef;
private final AtomicBoolean completed;
private volatile E result;
private volatile Exception ex;
@@ -60,9 +65,9 @@ class LeaseRequest> {
this.route = route;
this.state = state;
this.connectTimeout = connectTimeout;
- this.deadline = leaseTimeout > 0 ? System.currentTimeMillis() + leaseTimeout :
- Long.MAX_VALUE;
+ this.deadline = leaseTimeout > 0 ? System.currentTimeMillis() + leaseTimeout : Long.MAX_VALUE;
this.future = future;
+ this.sessionRequestRef = new AtomicReference(null);
this.completed = new AtomicBoolean(false);
}
@@ -86,6 +91,20 @@ class LeaseRequest> {
return this.completed.get();
}
+ public void attachSessionRequest(final SessionRequest sessionRequest) {
+ Asserts.check(this.sessionRequestRef.compareAndSet(null, sessionRequest), "Session request has already been set");
+ }
+
+ @Override
+ public boolean cancel() {
+ final boolean cancelled = this.completed.compareAndSet(false, true);
+ final SessionRequest sessionRequest = this.sessionRequestRef.getAndSet(null);
+ if (sessionRequest != null) {
+ sessionRequest.cancel();
+ }
+ return cancelled;
+ }
+
public void failed(final Exception ex) {
if (this.completed.compareAndSet(false, true)) {
this.ex = ex;
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/pool/RouteSpecificPool.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/pool/RouteSpecificPool.java
index 686eb1688..8f14a85dc 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/pool/RouteSpecificPool.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/pool/RouteSpecificPool.java
@@ -104,11 +104,7 @@ abstract class RouteSpecificPool> {
}
public E getLastUsed() {
- if (!this.available.isEmpty()) {
- return this.available.getLast();
- } else {
- return null;
- }
+ return this.available.isEmpty() ? null : this.available.getLast();
}
public boolean remove(final E entry) {
@@ -130,16 +126,12 @@ abstract class RouteSpecificPool> {
}
}
- public void addPending(
- final SessionRequest sessionRequest,
- final BasicFuture future) {
- this.pending.put(sessionRequest, future);
+ public void addPending(final SessionRequest request, final BasicFuture future) {
+ this.pending.put(request, future);
}
private BasicFuture removeRequest(final SessionRequest request) {
- final BasicFuture future = this.pending.remove(request);
- Asserts.notNull(future, "Session request future");
- return future;
+ return this.pending.remove(request);
}
public E createEntry(final SessionRequest request, final C conn) {
@@ -150,27 +142,37 @@ abstract class RouteSpecificPool> {
public boolean completed(final SessionRequest request, final E entry) {
final BasicFuture future = removeRequest(request);
- return future.completed(entry);
+ if (future != null) {
+ return future.completed(entry);
+ }
+ request.cancel();
+ return false;
}
public void cancelled(final SessionRequest request) {
final BasicFuture future = removeRequest(request);
- future.cancel(true);
+ if (future != null) {
+ future.cancel(true);
+ }
}
public void failed(final SessionRequest request, final Exception ex) {
final BasicFuture future = removeRequest(request);
- future.failed(ex);
+ if (future != null) {
+ future.failed(ex);
+ }
}
public void timeout(final SessionRequest request) {
final BasicFuture future = removeRequest(request);
- future.failed(new ConnectException());
+ if (future != null) {
+ future.failed(new ConnectException("Timeout connecting to [" + request.getRemoteAddress() + "]"));
+ }
}
public void shutdown() {
- for (final SessionRequest sessionRequest: this.pending.keySet()) {
- sessionRequest.cancel();
+ for (final SessionRequest request: this.pending.keySet()) {
+ request.cancel();
}
this.pending.clear();
for (final E entry: this.available) {
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/AbstractAsyncRequestConsumer.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/AbstractAsyncRequestConsumer.java
index 5399fdd97..c2e5512ad 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/AbstractAsyncRequestConsumer.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/AbstractAsyncRequestConsumer.java
@@ -90,11 +90,11 @@ public abstract class AbstractAsyncRequestConsumer implements HttpAsyncReques
* to find out whether or not the message content has been fully consumed.
*
* @param decoder content decoder.
- * @param ioctrl I/O control of the underlying connection.
+ * @param ioControl I/O control of the underlying connection.
* @throws IOException in case of an I/O error
*/
protected abstract void onContentReceived(
- ContentDecoder decoder, IOControl ioctrl) throws IOException;
+ ContentDecoder decoder, IOControl ioControl) throws IOException;
/**
* Invoked to generate a result object from the received HTTP request
@@ -141,8 +141,8 @@ public abstract class AbstractAsyncRequestConsumer implements HttpAsyncReques
*/
@Override
public final void consumeContent(
- final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
- onContentReceived(decoder, ioctrl);
+ final ContentDecoder decoder, final IOControl ioControl) throws IOException {
+ onContentReceived(decoder, ioControl);
}
/**
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java
index 16350e940..0cea33ab4 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/AbstractAsyncResponseConsumer.java
@@ -78,11 +78,11 @@ public abstract class AbstractAsyncResponseConsumer implements HttpAsyncRespo
* to find out whether or not the message content has been fully consumed.
*
* @param decoder content decoder.
- * @param ioctrl I/O control of the underlying connection.
+ * @param ioControl I/O control of the underlying connection.
* @throws IOException in case of an I/O error
*/
protected abstract void onContentReceived(
- ContentDecoder decoder, IOControl ioctrl) throws IOException;
+ ContentDecoder decoder, IOControl ioControl) throws IOException;
/**
* Invoked if the response message encloses a content entity.
@@ -143,8 +143,8 @@ public abstract class AbstractAsyncResponseConsumer implements HttpAsyncRespo
*/
@Override
public final void consumeContent(
- final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
- onContentReceived(decoder, ioctrl);
+ final ContentDecoder decoder, final IOControl ioControl) throws IOException {
+ onContentReceived(decoder, ioControl);
}
/**
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncClientExchangeHandler.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncClientExchangeHandler.java
index d8fb263d2..acbbd03d3 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncClientExchangeHandler.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncClientExchangeHandler.java
@@ -62,7 +62,7 @@ public class BasicAsyncClientExchangeHandler implements HttpAsyncClientExchan
private final BasicFuture future;
private final HttpContext localContext;
private final NHttpClientConnection conn;
- private final HttpProcessor httppocessor;
+ private final HttpProcessor httpPocessor;
private final ConnectionReuseStrategy connReuseStrategy;
private final AtomicBoolean requestSent;
private final AtomicBoolean keepAlive;
@@ -76,7 +76,7 @@ public class BasicAsyncClientExchangeHandler implements HttpAsyncClientExchan
* @param callback the future callback invoked when the operation is completed.
* @param localContext the local execution context.
* @param conn the actual connection.
- * @param httppocessor the HTTP protocol processor.
+ * @param httpPocessor the HTTP protocol processor.
* @param connReuseStrategy the connection re-use strategy.
*/
public BasicAsyncClientExchangeHandler(
@@ -85,7 +85,7 @@ public class BasicAsyncClientExchangeHandler implements HttpAsyncClientExchan
final FutureCallback callback,
final HttpContext localContext,
final NHttpClientConnection conn,
- final HttpProcessor httppocessor,
+ final HttpProcessor httpPocessor,
final ConnectionReuseStrategy connReuseStrategy) {
super();
this.requestProducer = Args.notNull(requestProducer, "Request producer");
@@ -93,7 +93,7 @@ public class BasicAsyncClientExchangeHandler implements HttpAsyncClientExchan
this.future = new BasicFuture(callback);
this.localContext = Args.notNull(localContext, "HTTP context");
this.conn = Args.notNull(conn, "HTTP connection");
- this.httppocessor = Args.notNull(httppocessor, "HTTP processor");
+ this.httpPocessor = Args.notNull(httpPocessor, "HTTP processor");
this.connReuseStrategy = connReuseStrategy != null ? connReuseStrategy :
DefaultConnectionReuseStrategy.INSTANCE;
this.requestSent = new AtomicBoolean(false);
@@ -108,15 +108,15 @@ public class BasicAsyncClientExchangeHandler implements HttpAsyncClientExchan
* @param responseConsumer the response consumer.
* @param localContext the local execution context.
* @param conn the actual connection.
- * @param httppocessor the HTTP protocol processor.
+ * @param httpPocessor the HTTP protocol processor.
*/
public BasicAsyncClientExchangeHandler(
final HttpAsyncRequestProducer requestProducer,
final HttpAsyncResponseConsumer responseConsumer,
final HttpContext localContext,
final NHttpClientConnection conn,
- final HttpProcessor httppocessor) {
- this(requestProducer, responseConsumer, null, localContext, conn, httppocessor, null);
+ final HttpProcessor httpPocessor) {
+ this(requestProducer, responseConsumer, null, localContext, conn, httpPocessor, null);
}
public Future getFuture() {
@@ -152,14 +152,14 @@ public class BasicAsyncClientExchangeHandler implements HttpAsyncClientExchan
final HttpRequest request = this.requestProducer.generateRequest();
this.localContext.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
this.localContext.setAttribute(HttpCoreContext.HTTP_CONNECTION, this.conn);
- this.httppocessor.process(request, this.localContext);
+ this.httpPocessor.process(request, this.localContext);
return request;
}
@Override
public void produceContent(
- final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
- this.requestProducer.produceContent(encoder, ioctrl);
+ final ContentEncoder encoder, final IOControl ioControl) throws IOException {
+ this.requestProducer.produceContent(encoder, ioControl);
}
@Override
@@ -171,15 +171,15 @@ public class BasicAsyncClientExchangeHandler implements HttpAsyncClientExchan
@Override
public void responseReceived(final HttpResponse response) throws IOException, HttpException {
this.localContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
- this.httppocessor.process(response, this.localContext);
+ this.httpPocessor.process(response, this.localContext);
this.responseConsumer.responseReceived(response);
this.keepAlive.set(this.connReuseStrategy.keepAlive(response, this.localContext));
}
@Override
public void consumeContent(
- final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
- this.responseConsumer.consumeContent(decoder, ioctrl);
+ final ContentDecoder decoder, final IOControl ioControl) throws IOException {
+ this.responseConsumer.consumeContent(decoder, ioControl);
}
@Override
@@ -207,7 +207,7 @@ public class BasicAsyncClientExchangeHandler implements HttpAsyncClientExchan
@Override
public void inputTerminated() {
- failed(new ConnectionClosedException("Connection closed"));
+ failed(new ConnectionClosedException());
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestConsumer.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestConsumer.java
index 8277a6205..d704704be 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestConsumer.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestConsumer.java
@@ -50,6 +50,8 @@ import com.fr.third.org.apache.http.util.Asserts;
*/
public class BasicAsyncRequestConsumer extends AbstractAsyncRequestConsumer {
+ private static final int MAX_INITIAL_BUFFER_SIZE = 256 * 1024;
+
private volatile HttpRequest request;
private volatile SimpleInputBuffer buf;
@@ -67,19 +69,20 @@ public class BasicAsyncRequestConsumer extends AbstractAsyncRequestConsumer Integer.MAX_VALUE) {
- throw new ContentTooLongException("Entity content is too long: " + len);
+ throw new ContentTooLongException("Entity content is too long: %,d", len);
}
if (len < 0) {
len = 4096;
}
- this.buf = new SimpleInputBuffer((int) len, new HeapByteBufferAllocator());
+ final int initialBufferSize = Math.min((int) len, MAX_INITIAL_BUFFER_SIZE);
+ this.buf = new SimpleInputBuffer(initialBufferSize, new HeapByteBufferAllocator());
((HttpEntityEnclosingRequest) this.request).setEntity(
new ContentBufferEntity(entity, this.buf));
}
@Override
protected void onContentReceived(
- final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
+ final ContentDecoder decoder, final IOControl ioControl) throws IOException {
Asserts.notNull(this.buf, "Content buffer");
this.buf.consumeContent(decoder);
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestHandler.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestHandler.java
index 168a8068b..b463db923 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestHandler.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestHandler.java
@@ -31,8 +31,8 @@ import java.io.IOException;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpRequest;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.protocol.HttpContext;
import com.fr.third.org.apache.http.protocol.HttpRequestHandler;
import com.fr.third.org.apache.http.util.Args;
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestProducer.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestProducer.java
index cc9571b05..6bb6fd8e2 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestProducer.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncRequestProducer.java
@@ -120,9 +120,9 @@ public class BasicAsyncRequestProducer implements HttpAsyncRequestProducer {
@Override
public void produceContent(
- final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
+ final ContentEncoder encoder, final IOControl ioControl) throws IOException {
if (this.producer != null) {
- this.producer.produceContent(encoder, ioctrl);
+ this.producer.produceContent(encoder, ioControl);
if (encoder.isCompleted()) {
this.producer.close();
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncResponseConsumer.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncResponseConsumer.java
index e58afef29..763aad76e 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncResponseConsumer.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncResponseConsumer.java
@@ -49,6 +49,8 @@ import com.fr.third.org.apache.http.util.Asserts;
*/
public class BasicAsyncResponseConsumer extends AbstractAsyncResponseConsumer {
+ private static final int MAX_INITIAL_BUFFER_SIZE = 256 * 1024;
+
private volatile HttpResponse response;
private volatile SimpleInputBuffer buf;
@@ -66,18 +68,19 @@ public class BasicAsyncResponseConsumer extends AbstractAsyncResponseConsumer Integer.MAX_VALUE) {
- throw new ContentTooLongException("Entity content is too long: " + len);
+ throw new ContentTooLongException("Entity content is too long: %,d", len);
}
if (len < 0) {
len = 4096;
}
- this.buf = new SimpleInputBuffer((int) len, new HeapByteBufferAllocator());
+ final int initialBufferSize = Math.min((int) len, MAX_INITIAL_BUFFER_SIZE);
+ this.buf = new SimpleInputBuffer(initialBufferSize, new HeapByteBufferAllocator());
this.response.setEntity(new ContentBufferEntity(entity, this.buf));
}
@Override
protected void onContentReceived(
- final ContentDecoder decoder, final IOControl ioctrl) throws IOException {
+ final ContentDecoder decoder, final IOControl ioControl) throws IOException {
Asserts.notNull(this.buf, "Content buffer");
this.buf.consumeContent(decoder);
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncResponseProducer.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncResponseProducer.java
index 35a156052..25f98ecd1 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncResponseProducer.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/BasicAsyncResponseProducer.java
@@ -104,9 +104,9 @@ public class BasicAsyncResponseProducer implements HttpAsyncResponseProducer {
@Override
public void produceContent(
- final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
+ final ContentEncoder encoder, final IOControl ioControl) throws IOException {
if (this.producer != null) {
- this.producer.produceContent(encoder, ioctrl);
+ this.producer.produceContent(encoder, ioControl);
if (encoder.isCompleted()) {
this.producer.close();
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/ErrorResponseProducer.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/ErrorResponseProducer.java
index 7d78418c6..b88bb0615 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/ErrorResponseProducer.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/ErrorResponseProducer.java
@@ -38,14 +38,19 @@ import com.fr.third.org.apache.http.nio.entity.HttpAsyncContentProducer;
import com.fr.third.org.apache.http.protocol.HTTP;
import com.fr.third.org.apache.http.protocol.HttpContext;
-class ErrorResponseProducer implements HttpAsyncResponseProducer {
+/**
+ * This class changed from package private to public in version 4.4.8.
+ *
+ * @since 4.4.8
+ */
+public class ErrorResponseProducer implements HttpAsyncResponseProducer {
private final HttpResponse response;
private final HttpEntity entity;
private final HttpAsyncContentProducer contentProducer;
private final boolean keepAlive;
- ErrorResponseProducer(
+ public ErrorResponseProducer(
final HttpResponse response,
final HttpEntity entity,
final boolean keepAlive) {
@@ -73,8 +78,8 @@ class ErrorResponseProducer implements HttpAsyncResponseProducer {
@Override
public void produceContent(
- final ContentEncoder encoder, final IOControl ioctrl) throws IOException {
- this.contentProducer.produceContent(encoder, ioctrl);
+ final ContentEncoder encoder, final IOControl ioControl) throws IOException {
+ this.contentProducer.produceContent(encoder, ioControl);
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncClientExchangeHandler.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncClientExchangeHandler.java
index a07b5bd67..19e41e097 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncClientExchangeHandler.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncClientExchangeHandler.java
@@ -30,8 +30,6 @@ package com.fr.third.org.apache.http.nio.protocol;
import java.io.Closeable;
import java.io.IOException;
-import com.fr.third.org.apache.http.HttpEntityEnclosingRequest;
-import com.fr.third.org.apache.http.protocol.HttpProcessor;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
@@ -46,7 +44,7 @@ import com.fr.third.org.apache.http.nio.IOControl;
* on the client side.
*
* Individual {@code HttpAsyncClientExchangeHandler} are expected to make use of
- * a {@link HttpProcessor} to generate mandatory protocol
+ * a {@link com.fr.third.org.apache.http.protocol.HttpProcessor} to generate mandatory protocol
* headers for all outgoing messages and apply common, cross-cutting message
* transformations to all incoming and outgoing messages.
* {@code HttpAsyncClientExchangeHandler}s can delegate implementation
@@ -59,10 +57,10 @@ public interface HttpAsyncClientExchangeHandler extends Closeable, Cancellable {
/**
* Invoked to generate a HTTP request message head. The message is expected
- * to implement the {@link HttpEntityEnclosingRequest} interface if it is
+ * to implement the {@link com.fr.third.org.apache.http.HttpEntityEnclosingRequest} interface if it is
* to enclose a content entity. The {@link #produceContent(ContentEncoder,
* IOControl)} method will not be invoked if
- * {@link HttpEntityEnclosingRequest#getEntity()} returns
+ * {@link com.fr.third.org.apache.http.HttpEntityEnclosingRequest#getEntity()} returns
* {@code null}.
*
* @return HTTP request message.
@@ -86,10 +84,10 @@ public interface HttpAsyncClientExchangeHandler extends Closeable, Cancellable {
* to resume output event notifications when more content is made available.
*
* @param encoder content encoder.
- * @param ioctrl I/O control of the underlying connection.
+ * @param ioControl I/O control of the underlying connection.
* @throws IOException in case of an I/O error
*/
- void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException;
+ void produceContent(ContentEncoder encoder, IOControl ioControl) throws IOException;
/**
* Invoked to signal that the request has been fully written out.
@@ -123,10 +121,10 @@ public interface HttpAsyncClientExchangeHandler extends Closeable, Cancellable {
* processing more content.
*
* @param decoder content decoder.
- * @param ioctrl I/O control of the underlying connection.
+ * @param ioControl I/O control of the underlying connection.
* @throws IOException in case of an I/O error
*/
- void consumeContent(ContentDecoder decoder, IOControl ioctrl) throws IOException;
+ void consumeContent(ContentDecoder decoder, IOControl ioControl) throws IOException;
/**
* Invoked to signal that the response has been fully processed.
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncExchange.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncExchange.java
index 3ee520877..86782d4d0 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncExchange.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncExchange.java
@@ -27,11 +27,9 @@
package com.fr.third.org.apache.http.nio.protocol;
-import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.concurrent.Cancellable;
-import com.fr.third.org.apache.http.nio.entity.HttpAsyncContentProducer;
/**
* {@code HttpAsyncExchange} represents a server-side HTTP message exchange
@@ -59,9 +57,9 @@ public interface HttpAsyncExchange {
/**
* Submits the default HTTP response and completed the message exchange.
- * If the response encloses an {@link HttpEntity} instance
+ * If the response encloses an {@link com.fr.third.org.apache.http.HttpEntity} instance
* the entity is also expected to implement the
- * {@link HttpAsyncContentProducer }
+ * {@link com.fr.third.org.apache.http.nio.entity.HttpAsyncContentProducer }
* interface for efficient content streaming to a non-blocking HTTP
* connection.
*
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestConsumer.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestConsumer.java
index 3099d69f9..52fe76a7d 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestConsumer.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestConsumer.java
@@ -29,7 +29,6 @@ package com.fr.third.org.apache.http.nio.protocol;
import java.io.Closeable;
import java.io.IOException;
-import com.fr.third.org.apache.http.HttpEntityEnclosingRequest;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.nio.ContentDecoder;
@@ -50,7 +49,7 @@ public interface HttpAsyncRequestConsumer extends Closeable {
* Invoked when a HTTP request message is received. Please note
* that the {@link #consumeContent(ContentDecoder, IOControl)} method
* will be invoked only for if the request message implements
- * {@link HttpEntityEnclosingRequest} interface and
+ * {@link com.fr.third.org.apache.http.HttpEntityEnclosingRequest} interface and
* has a content entity enclosed.
*
* @param request HTTP request message.
@@ -74,10 +73,10 @@ public interface HttpAsyncRequestConsumer extends Closeable {
* processing more content.
*
* @param decoder content decoder.
- * @param ioctrl I/O control of the underlying connection.
+ * @param ioControl I/O control of the underlying connection.
* @throws IOException in case of an I/O error
*/
- void consumeContent(ContentDecoder decoder, IOControl ioctrl) throws IOException;
+ void consumeContent(ContentDecoder decoder, IOControl ioControl) throws IOException;
/**
* Invoked to signal that the request has been fully processed.
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
index 7455237ad..c2756ae17 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestExecutor.java
@@ -32,8 +32,6 @@ import java.net.SocketTimeoutException;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
-import com.fr.third.org.apache.http.HttpConnection;
-import com.fr.third.org.apache.http.protocol.HttpProcessor;
import com.fr.third.org.apache.http.ConnectionClosedException;
import com.fr.third.org.apache.http.ExceptionLogger;
import com.fr.third.org.apache.http.HttpEntity;
@@ -45,8 +43,8 @@ import com.fr.third.org.apache.http.HttpStatus;
import com.fr.third.org.apache.http.HttpVersion;
import com.fr.third.org.apache.http.ProtocolException;
import com.fr.third.org.apache.http.ProtocolVersion;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.nio.ContentDecoder;
import com.fr.third.org.apache.http.nio.ContentEncoder;
import com.fr.third.org.apache.http.nio.NHttpClientConnection;
@@ -71,7 +69,7 @@ import com.fr.third.org.apache.http.util.Asserts;
* be used to facilitate initiation of asynchronous HTTP request execution.
*
* Individual {@code HttpAsyncClientExchangeHandler} are expected to make use of
- * a {@link HttpProcessor} to generate mandatory protocol
+ * a {@link com.fr.third.org.apache.http.protocol.HttpProcessor} to generate mandatory protocol
* headers for all outgoing messages and apply common, cross-cutting message
* transformations to all incoming and outgoing messages.
* {@code HttpAsyncClientExchangeHandler}s can delegate implementation of
@@ -97,7 +95,7 @@ public class HttpAsyncRequestExecutor implements NHttpClientEventHandler {
* @param exceptionLogger Exception logger. If {@code null}
* {@link ExceptionLogger#NO_OP} will be used. Please note that the exception
* logger will be only used to log I/O exception thrown while closing
- * {@link java.io.Closeable} objects (such as {@link HttpConnection}).
+ * {@link java.io.Closeable} objects (such as {@link com.fr.third.org.apache.http.HttpConnection}).
*
* @since 4.4
*/
@@ -122,6 +120,10 @@ public class HttpAsyncRequestExecutor implements NHttpClientEventHandler {
this(DEFAULT_WAIT_FOR_CONTINUE, null);
}
+ private static boolean pipelining(final HttpAsyncClientExchangeHandler handler) {
+ return handler.getClass().getAnnotation(Pipelined.class) != null;
+ }
+
@Override
public void connected(
final NHttpClientConnection conn,
@@ -134,16 +136,20 @@ public class HttpAsyncRequestExecutor implements NHttpClientEventHandler {
@Override
public void closed(final NHttpClientConnection conn) {
- final State state = getState(conn);
final HttpAsyncClientExchangeHandler handler = getHandler(conn);
+ if (handler == null) {
+ return;
+ }
+ final State state = getState(conn);
if (state != null) {
if (state.getRequestState() != MessageState.READY || state.getResponseState() != MessageState.READY) {
- if (handler != null) {
- handler.failed(new ConnectionClosedException("Connection closed unexpectedly"));
- }
+ handler.failed(new ConnectionClosedException("Connection closed unexpectedly"));
}
}
- if (state == null || (handler != null && handler.isDone())) {
+ if (!handler.isDone() && pipelining(handler)) {
+ handler.failed(new ConnectionClosedException("Connection closed unexpectedly"));
+ }
+ if (state == null || handler.isDone()) {
closeHandler(handler);
}
}
@@ -182,7 +188,7 @@ public class HttpAsyncRequestExecutor implements NHttpClientEventHandler {
return;
}
}
- final boolean pipelined = handler.getClass().getAnnotation(Pipelined.class) != null;
+ final boolean pipelined = pipelining(handler);
final HttpRequest request = handler.generateRequest();
if (request == null) {
@@ -243,8 +249,7 @@ public class HttpAsyncRequestExecutor implements NHttpClientEventHandler {
handler.produceContent(encoder, conn);
if (encoder.isCompleted()) {
handler.requestCompleted();
- final boolean pipelined = handler.getClass().getAnnotation(Pipelined.class) != null;
- state.setRequestState(pipelined ? MessageState.READY : MessageState.COMPLETED);
+ state.setRequestState(pipelining(handler) ? MessageState.READY : MessageState.COMPLETED);
}
}
@@ -259,9 +264,8 @@ public class HttpAsyncRequestExecutor implements NHttpClientEventHandler {
final HttpAsyncClientExchangeHandler handler = getHandler(conn);
Asserts.notNull(handler, "Client exchange handler");
- final boolean pipelined = handler.getClass().getAnnotation(Pipelined.class) != null;
final HttpRequest request;
- if (pipelined) {
+ if (pipelining(handler)) {
request = state.getRequestQueue().poll();
Asserts.notNull(request, "HTTP request");
} else {
@@ -274,6 +278,9 @@ public class HttpAsyncRequestExecutor implements NHttpClientEventHandler {
final HttpResponse response = conn.getHttpResponse();
final int statusCode = response.getStatusLine().getStatusCode();
+ if (statusCode < HttpStatus.SC_CONTINUE) {
+ throw new ProtocolException("Invalid response: " + response.getStatusLine());
+ }
if (statusCode < HttpStatus.SC_OK) {
// 1xx intermediate response
if (statusCode != HttpStatus.SC_CONTINUE) {
@@ -296,10 +303,12 @@ public class HttpAsyncRequestExecutor implements NHttpClientEventHandler {
state.setRequestState(MessageState.COMPLETED);
} else if (state.getRequestState() == MessageState.BODY_STREAM) {
// Early response
- conn.resetOutput();
- conn.suspendOutput();
- state.setRequestState(MessageState.COMPLETED);
- state.invalidate();
+ if (statusCode >= 400) {
+ conn.resetOutput();
+ conn.suspendOutput();
+ state.setRequestState(MessageState.COMPLETED);
+ state.invalidate();
+ }
}
if (canResponseHaveBody(request, response)) {
@@ -344,7 +353,7 @@ public class HttpAsyncRequestExecutor implements NHttpClientEventHandler {
if (state.isValid()) {
handler.inputTerminated();
} else {
- handler.failed(new ConnectionClosedException("Connection closed"));
+ handler.failed(new ConnectionClosedException());
}
}
}
@@ -371,13 +380,13 @@ public class HttpAsyncRequestExecutor implements NHttpClientEventHandler {
state.setRequestState(MessageState.BODY_STREAM);
state.setTimeout(0);
return;
- } else {
- state.invalidate();
- final HttpAsyncClientExchangeHandler handler = getHandler(conn);
- if (handler != null) {
- handler.failed(new SocketTimeoutException());
- handler.close();
- }
+ }
+ state.invalidate();
+ final HttpAsyncClientExchangeHandler handler = getHandler(conn);
+ if (handler != null) {
+ handler.failed(new SocketTimeoutException(
+ String.format("%,d milliseconds timeout on connection %s", conn.getSocketTimeout(), conn)));
+ handler.close();
}
}
if (conn.getStatus() == NHttpConnection.ACTIVE) {
@@ -395,7 +404,7 @@ public class HttpAsyncRequestExecutor implements NHttpClientEventHandler {
/**
* This method can be used to log I/O exception thrown while closing
* {@link java.io.Closeable} objects (such as
- * {@link HttpConnection}}).
+ * {@link com.fr.third.org.apache.http.HttpConnection}}).
*
* @param ex I/O exception thrown by {@link java.io.Closeable#close()}
*/
@@ -438,8 +447,7 @@ public class HttpAsyncRequestExecutor implements NHttpClientEventHandler {
}
handler.responseCompleted();
- final boolean pipelined = handler.getClass().getAnnotation(Pipelined.class) != null;
- if (!pipelined) {
+ if (!pipelining(handler)) {
state.setRequestState(MessageState.READY);
state.setRequest(null);
}
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestProducer.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestProducer.java
index d2a0bdd43..d2d2e508d 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestProducer.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequestProducer.java
@@ -29,7 +29,6 @@ package com.fr.third.org.apache.http.nio.protocol;
import java.io.Closeable;
import java.io.IOException;
-import com.fr.third.org.apache.http.HttpEntityEnclosingRequest;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.HttpRequest;
@@ -59,10 +58,10 @@ public interface HttpAsyncRequestProducer extends Closeable {
/**
* Invoked to generate a HTTP request message head. The message is expected
- * to implement the {@link HttpEntityEnclosingRequest} interface
+ * to implement the {@link com.fr.third.org.apache.http.HttpEntityEnclosingRequest} interface
* if it is to enclose a content entity. The {@link #produceContent(
* ContentEncoder, IOControl)} method will not be invoked if
- * {@link HttpEntityEnclosingRequest#getEntity()}
+ * {@link com.fr.third.org.apache.http.HttpEntityEnclosingRequest#getEntity()}
* returns {@code null}.
*
* @return HTTP request message.
@@ -86,10 +85,10 @@ public interface HttpAsyncRequestProducer extends Closeable {
* to resume output event notifications when more content is made available.
*
* @param encoder content encoder.
- * @param ioctrl I/O control of the underlying connection.
+ * @param ioControl I/O control of the underlying connection.
* @throws IOException in case of an I/O error
*/
- void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException;
+ void produceContent(ContentEncoder encoder, IOControl ioControl) throws IOException;
/**
* Invoked to signal that the request has been fully written out.
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequester.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequester.java
index 7a8472cd5..8e922f940 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequester.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncRequester.java
@@ -34,10 +34,9 @@ import java.util.concurrent.Future;
import com.fr.third.org.apache.http.ConnectionClosedException;
import com.fr.third.org.apache.http.ConnectionReuseStrategy;
import com.fr.third.org.apache.http.ExceptionLogger;
-import com.fr.third.org.apache.http.HttpConnection;
import com.fr.third.org.apache.http.HttpHost;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.concurrent.BasicFuture;
import com.fr.third.org.apache.http.concurrent.FutureCallback;
import com.fr.third.org.apache.http.impl.DefaultConnectionReuseStrategy;
@@ -87,7 +86,7 @@ public class HttpAsyncRequester {
* @param exceptionLogger Exception logger. If {@code null}
* {@link ExceptionLogger#NO_OP} will be used. Please note that the exception
* logger will be only used to log I/O exception thrown while closing
- * {@link java.io.Closeable} objects (such as {@link HttpConnection}).
+ * {@link Closeable} objects (such as {@link com.fr.third.org.apache.http.HttpConnection}).
*
* @since 4.4
*/
@@ -157,7 +156,7 @@ public class HttpAsyncRequester {
synchronized (context) {
context.setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, handler);
if (!conn.isOpen()) {
- handler.failed(new ConnectionClosedException("Connection closed"));
+ handler.failed(new ConnectionClosedException());
} else {
conn.requestOutput();
}
@@ -577,10 +576,10 @@ public class HttpAsyncRequester {
/**
* This method can be used to log I/O exception thrown while closing
- * {@link java.io.Closeable} objects (such as
- * {@link HttpConnection}}).
+ * {@link Closeable} objects (such as
+ * {@link com.fr.third.org.apache.http.HttpConnection}}).
*
- * @param ex I/O exception thrown by {@link java.io.Closeable#close()}
+ * @param ex I/O exception thrown by {@link Closeable#close()}
*/
protected void log(final Exception ex) {
this.exceptionLogger.log(ex);
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncResponseConsumer.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncResponseConsumer.java
index 436824e33..45b929dc6 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncResponseConsumer.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncResponseConsumer.java
@@ -73,10 +73,10 @@ public interface HttpAsyncResponseConsumer extends Closeable, Cancellable {
* processing more content.
*
* @param decoder content decoder.
- * @param ioctrl I/O control of the underlying connection.
+ * @param ioControl I/O control of the underlying connection.
* @throws IOException in case of an I/O error
*/
- void consumeContent(ContentDecoder decoder, IOControl ioctrl) throws IOException;
+ void consumeContent(ContentDecoder decoder, IOControl ioControl) throws IOException;
/**
* Invoked to signal that the response has been fully processed.
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncResponseProducer.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncResponseProducer.java
index 1e66f9da2..04fe88209 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncResponseProducer.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncResponseProducer.java
@@ -66,10 +66,10 @@ public interface HttpAsyncResponseProducer extends Closeable {
* to resume output event notifications when more content is made available.
*
* @param encoder content encoder.
- * @param ioctrl I/O control of the underlying connection.
+ * @param ioControl I/O control of the underlying connection.
* @throws IOException in case of an I/O error
*/
- void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException;
+ void produceContent(ContentEncoder encoder, IOControl ioControl) throws IOException;
/**
* Invoked to signal that the response has been fully written out.
diff --git a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncService.java b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncService.java
index 826c84187..866f1e95f 100644
--- a/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncService.java
+++ b/fine-httpcomponents/http-core/httpcore-nio/src/main/java/com/fr/third/org/apache/http/nio/protocol/HttpAsyncService.java
@@ -28,6 +28,7 @@
package com.fr.third.org.apache.http.nio.protocol;
import java.io.IOException;
+import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -35,7 +36,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import com.fr.third.org.apache.http.ConnectionReuseStrategy;
import com.fr.third.org.apache.http.ExceptionLogger;
-import com.fr.third.org.apache.http.HttpConnection;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpEntityEnclosingRequest;
import com.fr.third.org.apache.http.HttpException;
@@ -47,8 +47,8 @@ import com.fr.third.org.apache.http.HttpVersion;
import com.fr.third.org.apache.http.MethodNotSupportedException;
import com.fr.third.org.apache.http.ProtocolException;
import com.fr.third.org.apache.http.UnsupportedHttpVersionException;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.concurrent.Cancellable;
import com.fr.third.org.apache.http.entity.ContentType;
import com.fr.third.org.apache.http.impl.DefaultConnectionReuseStrategy;
@@ -106,7 +106,7 @@ public class HttpAsyncService implements NHttpServerEventHandler {
static final String HTTP_EXCHANGE_STATE = "http.nio.http-exchange-state";
private final HttpProcessor httpProcessor;
- private final ConnectionReuseStrategy connStrategy;
+ private final ConnectionReuseStrategy connectionStrategy;
private final HttpResponseFactory responseFactory;
private final HttpAsyncRequestHandlerMapper handlerMapper;
private final HttpAsyncExpectationVerifier expectationVerifier;
@@ -201,7 +201,7 @@ public class HttpAsyncService implements NHttpServerEventHandler {
* @param exceptionLogger Exception logger. If {@code null}
* {@link ExceptionLogger#NO_OP} will be used. Please note that the exception
* logger will be only used to log I/O exception thrown while closing
- * {@link java.io.Closeable} objects (such as {@link HttpConnection}).
+ * {@link java.io.Closeable} objects (such as {@link com.fr.third.org.apache.http.HttpConnection}).
*
* @since 4.4
*/
@@ -214,7 +214,7 @@ public class HttpAsyncService implements NHttpServerEventHandler {
final ExceptionLogger exceptionLogger) {
super();
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
- this.connStrategy = connStrategy != null ? connStrategy :
+ this.connectionStrategy = connStrategy != null ? connStrategy :
DefaultConnectionReuseStrategy.INSTANCE;
this.responseFactory = responseFactory != null ? responseFactory :
DefaultHttpResponseFactory.INSTANCE;
@@ -245,7 +245,7 @@ public class HttpAsyncService implements NHttpServerEventHandler {
* @param exceptionLogger Exception logger. If {@code null}
* {@link ExceptionLogger#NO_OP} will be used. Please note that the exception
* logger will be only used to log I/O exception thrown while closing
- * {@link java.io.Closeable} objects (such as {@link HttpConnection}).
+ * {@link java.io.Closeable} objects (such as {@link com.fr.third.org.apache.http.HttpConnection}).
*
* @since 4.4
*/
@@ -278,48 +278,75 @@ public class HttpAsyncService implements NHttpServerEventHandler {
@Override
public void exception(
final NHttpServerConnection conn, final Exception cause) {
+ log(cause);
final State state = getState(conn);
if (state == null) {
shutdownConnection(conn);
- log(cause);
return;
}
state.setTerminated();
closeHandlers(state, cause);
- final Cancellable cancellable = state.getCancellable();
- if (cancellable != null) {
- cancellable.cancel();
- }
- final Queue pipeline = state.getPipeline();
- if (!pipeline.isEmpty()
- || conn.isResponseSubmitted()
- || state.getResponseState().compareTo(MessageState.INIT) > 0) {
- // There is not much that we can do if a response
- // has already been submitted or pipelining is being used.
- shutdownConnection(conn);
- } else {
- try {
+ try {
+ final Cancellable cancellable = state.getCancellable();
+ if (cancellable != null) {
+ cancellable.cancel();
+ }
+ if (cause instanceof SocketException || cause.getClass() == IOException.class) {
+ // Transport layer is likely unreliable.
+ conn.shutdown();
+ return;
+ }
+ if (cause instanceof SocketTimeoutException) {
+ // Connection timed out due to inactivity.
+ conn.close();
+ return;
+ }
+
+ if (conn.isResponseSubmitted() || state.getResponseState().compareTo(MessageState.INIT) > 0) {
+ // There is not much that we can do if a response has already been submitted.
+ conn.close();
+ return;
+ }
+ HttpRequest request = conn.getHttpRequest();
+ if (request == null) {
final Incoming incoming = state.getIncoming();
- final HttpRequest request = incoming != null ? incoming.getRequest() : null;
- final HttpContext context = incoming != null ? incoming.getContext() : new BasicHttpContext();
+ if (incoming != null) {
+ request = incoming.getRequest();
+ }
+ }
+ if (request == null) {
+ final Queue pipeline = state.getPipeline();
+ final PipelineEntry pipelineEntry = pipeline.poll();
+ if (pipelineEntry != null) {
+ request = pipelineEntry.getRequest();
+ }
+ }
+ if (request != null) {
+ conn.resetInput();
+ final HttpCoreContext context = HttpCoreContext.create();
final HttpAsyncResponseProducer responseProducer = handleException(cause, context);
final HttpResponse response = responseProducer.generateResponse();
final Outgoing outgoing = new Outgoing(request, response, responseProducer, context);
state.setResponseState(MessageState.INIT);
state.setOutgoing(outgoing);
commitFinalResponse(conn, state);
- } catch (final Exception ex) {
- shutdownConnection(conn);
- closeHandlers(state);
- if (ex instanceof RuntimeException) {
- throw (RuntimeException) ex;
- } else {
- log(ex);
- }
+ return;
}
+ conn.close();
+ } catch (final Exception ex) {
+ shutdownConnection(conn);
+ closeHandlers(state);
+ if (ex instanceof RuntimeException) {
+ throw (RuntimeException) ex;
+ }
+ log(ex);
}
}
+ protected HttpResponse createHttpResponse(final int status, final HttpContext context) {
+ return this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_1, status, context);
+ }
+
@Override
public void requestReceived(
final NHttpServerConnection conn) throws IOException, HttpException {
@@ -352,8 +379,7 @@ public class HttpAsyncService implements NHttpServerEventHandler {
&& !(conn instanceof SessionBufferStatus && ((SessionBufferStatus) conn).hasBufferedInput())) {
state.setRequestState(MessageState.ACK_EXPECTED);
- final HttpResponse ack = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_1,
- HttpStatus.SC_CONTINUE, context);
+ final HttpResponse ack = createHttpResponse(HttpStatus.SC_CONTINUE, context);
if (this.expectationVerifier != null) {
conn.suspendInput();
conn.suspendOutput();
@@ -401,9 +427,14 @@ public class HttpAsyncService implements NHttpServerEventHandler {
"Unexpected response state %s", state.getResponseState());
if (state.getRequestState() == MessageState.ACK_EXPECTED) {
- final Outgoing outgoing = state.getOutgoing();
- Asserts.notNull(outgoing, "Outgoing response");
-
+ final Outgoing outgoing;
+ synchronized (state) {
+ outgoing = state.getOutgoing();
+ if (outgoing == null) {
+ conn.suspendOutput();
+ return;
+ }
+ }
final HttpResponse response = outgoing.getResponse();
final int status = response.getStatusLine().getStatusCode();
if (status == 100) {
@@ -439,11 +470,10 @@ public class HttpAsyncService implements NHttpServerEventHandler {
final Object result = pipelineEntry.getResult();
final HttpRequest request = pipelineEntry.getRequest();
final HttpContext context = pipelineEntry.getContext();
+ final HttpResponse response = createHttpResponse(HttpStatus.SC_OK, context);
+ final HttpAsyncExchangeImpl httpExchange = new HttpAsyncExchangeImpl(
+ request, response, state, conn, context);
if (result != null) {
- final HttpResponse response = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_1,
- HttpStatus.SC_OK, context);
- final HttpAsyncExchangeImpl httpExchange = new HttpAsyncExchangeImpl(
- request, response, state, conn, context);
final HttpAsyncRequestHandler
*/
public AbstractHttpClientConnection() {
super();
@@ -117,7 +114,8 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
*
* This method can be overridden in a super class in order to create
* instances of {@link EntityDeserializer} using a custom
- * {@link ContentLengthStrategy}.
+ * {@link com.fr.third.org.apache.http.entity.ContentLengthStrategy}.
+ *
*
* @return HTTP entity deserializer
*/
@@ -132,7 +130,8 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
*
* This method can be overridden in a super class in order to create
* instances of {@link EntitySerializer} using a custom
- * {@link ContentLengthStrategy}.
+ * {@link com.fr.third.org.apache.http.entity.ContentLengthStrategy}.
+ *
*
* @return HTTP entity serialzier.
*/
@@ -147,6 +146,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
*
* This method can be overridden in a super class in order to provide
* a different implementation of the {@link HttpResponseFactory} interface.
+ *
*
* @return HTTP response factory.
*/
@@ -161,8 +161,9 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
* This method can be overridden in a super class in order to provide
* a different implementation of the {@link HttpMessageParser} interface or
* to pass a different implementation of the
- * {@link LineParser} to the the
+ * {@link com.fr.third.org.apache.http.message.LineParser} to the the
* {@link DefaultHttpResponseParser} constructor.
+ *
*
* @param buffer the session input buffer.
* @param responseFactory the HTTP response factory.
@@ -183,8 +184,9 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
* This method can be overridden in a super class in order to provide
* a different implementation of the {@link HttpMessageWriter} interface or
* to pass a different implementation of
- * {@link LineFormatter} to the the default implementation
+ * {@link com.fr.third.org.apache.http.message.LineFormatter} to the the default implementation
* {@link HttpRequestWriter}.
+ *
*
* @param buffer the session output buffer
* @param params HTTP parameters
@@ -216,40 +218,43 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
* and {@link #createResponseParser(SessionInputBuffer, HttpResponseFactory, HttpParams)}
* methods to initialize HTTP request writer and response parser for this
* connection.
+ *
*
- * @param inbuffer the session input buffer.
- * @param outbuffer the session output buffer.
+ * @param sessionInputBuffer the session input buffer.
+ * @param sessionOutputBuffer the session output buffer.
* @param params HTTP parameters.
*/
protected void init(
- final SessionInputBuffer inbuffer,
- final SessionOutputBuffer outbuffer,
+ final SessionInputBuffer sessionInputBuffer,
+ final SessionOutputBuffer sessionOutputBuffer,
final HttpParams params) {
- this.inbuffer = Args.notNull(inbuffer, "Input session buffer");
- this.outbuffer = Args.notNull(outbuffer, "Output session buffer");
- if (inbuffer instanceof EofSensor) {
- this.eofSensor = (EofSensor) inbuffer;
+ this.inBuffer = Args.notNull(sessionInputBuffer, "Input session buffer");
+ this.outbuffer = Args.notNull(sessionOutputBuffer, "Output session buffer");
+ if (sessionInputBuffer instanceof EofSensor) {
+ this.eofSensor = (EofSensor) sessionInputBuffer;
}
this.responseParser = createResponseParser(
- inbuffer,
+ sessionInputBuffer,
createHttpResponseFactory(),
params);
this.requestWriter = createRequestWriter(
- outbuffer, params);
+ sessionOutputBuffer, params);
this.metrics = createConnectionMetrics(
- inbuffer.getMetrics(),
- outbuffer.getMetrics());
+ sessionInputBuffer.getMetrics(),
+ sessionOutputBuffer.getMetrics());
}
+ @Override
public boolean isResponseAvailable(final int timeout) throws IOException {
assertOpen();
try {
- return this.inbuffer.isDataAvailable(timeout);
+ return this.inBuffer.isDataAvailable(timeout);
} catch (final SocketTimeoutException ex) {
return false;
}
}
+ @Override
public void sendRequestHeader(final HttpRequest request)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
@@ -258,6 +263,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
this.metrics.incrementRequestCount();
}
+ @Override
public void sendRequestEntity(final HttpEntityEnclosingRequest request)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
@@ -275,11 +281,13 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
this.outbuffer.flush();
}
+ @Override
public void flush() throws IOException {
assertOpen();
doFlush();
}
+ @Override
public HttpResponse receiveResponseHeader()
throws HttpException, IOException {
assertOpen();
@@ -290,11 +298,12 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
return response;
}
+ @Override
public void receiveResponseEntity(final HttpResponse response)
throws HttpException, IOException {
Args.notNull(response, "HTTP response");
assertOpen();
- final HttpEntity entity = this.entitydeserializer.deserialize(this.inbuffer, response);
+ final HttpEntity entity = this.entitydeserializer.deserialize(this.inBuffer, response);
response.setEntity(entity);
}
@@ -302,6 +311,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
return this.eofSensor != null && this.eofSensor.isEof();
}
+ @Override
public boolean isStale() {
if (!isOpen()) {
return true;
@@ -310,7 +320,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
return true;
}
try {
- this.inbuffer.isDataAvailable(1);
+ this.inBuffer.isDataAvailable(1);
return isEof();
} catch (final SocketTimeoutException ex) {
return false;
@@ -319,6 +329,7 @@ public abstract class AbstractHttpClientConnection implements HttpClientConnecti
}
}
+ @Override
public HttpConnectionMetrics getMetrics() {
return this.metrics;
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/AbstractHttpServerConnection.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/AbstractHttpServerConnection.java
index a5b4e9fe8..ff6ff7a5f 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/AbstractHttpServerConnection.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/AbstractHttpServerConnection.java
@@ -29,11 +29,6 @@ package com.fr.third.org.apache.http.impl;
import java.io.IOException;
-import com.fr.third.org.apache.http.entity.ContentLengthStrategy;
-import com.fr.third.org.apache.http.message.LineFormatter;
-import com.fr.third.org.apache.http.message.LineParser;
-import com.fr.third.org.apache.http.params.CoreConnectionPNames;
-import com.fr.third.org.apache.http.params.CoreProtocolPNames;
import com.fr.third.org.apache.http.HttpConnectionMetrics;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpEntityEnclosingRequest;
@@ -66,9 +61,9 @@ import com.fr.third.org.apache.http.util.Args;
* The following parameters can be used to customize the behavior of this
* class:
*
*
* @since 4.0
@@ -81,7 +76,7 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
private final EntitySerializer entityserializer;
private final EntityDeserializer entitydeserializer;
- private SessionInputBuffer inbuffer = null;
+ private SessionInputBuffer inBuffer = null;
private SessionOutputBuffer outbuffer = null;
private EofSensor eofSensor = null;
private HttpMessageParser requestParser = null;
@@ -116,7 +111,7 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
*
* This method can be overridden in a super class in order to create
* instances of {@link EntityDeserializer} using a custom
- * {@link ContentLengthStrategy}.
+ * {@link com.fr.third.org.apache.http.entity.ContentLengthStrategy}.
*
* @return HTTP entity deserializer
*/
@@ -132,7 +127,7 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
*
* This method can be overridden in a super class in order to create
* instances of {@link EntitySerializer} using a custom
- * {@link ContentLengthStrategy}.
+ * {@link com.fr.third.org.apache.http.entity.ContentLengthStrategy}.
*
* @return HTTP entity serialzier.
*/
@@ -161,7 +156,7 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
* This method can be overridden in a super class in order to provide
* a different implementation of the {@link HttpMessageParser} interface or
* to pass a different implementation of the
- * {@link LineParser} to the
+ * {@link com.fr.third.org.apache.http.message.LineParser} to the
* {@link DefaultHttpRequestParser} constructor.
*
* @param buffer the session input buffer.
@@ -183,7 +178,7 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
* This method can be overridden in a super class in order to provide
* a different implementation of the {@link HttpMessageWriter} interface or
* to pass a different implementation of
- * {@link LineFormatter} to the the default
+ * {@link com.fr.third.org.apache.http.message.LineFormatter} to the the default
* implementation {@link HttpResponseWriter}.
*
* @param buffer the session output buffer
@@ -217,30 +212,31 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
* methods to initialize HTTP request parser and response writer for this
* connection.
*
- * @param inbuffer the session input buffer.
+ * @param inBuffer the session input buffer.
* @param outbuffer the session output buffer.
* @param params HTTP parameters.
*/
protected void init(
- final SessionInputBuffer inbuffer,
+ final SessionInputBuffer inBuffer,
final SessionOutputBuffer outbuffer,
final HttpParams params) {
- this.inbuffer = Args.notNull(inbuffer, "Input session buffer");
+ this.inBuffer = Args.notNull(inBuffer, "Input session buffer");
this.outbuffer = Args.notNull(outbuffer, "Output session buffer");
- if (inbuffer instanceof EofSensor) {
- this.eofSensor = (EofSensor) inbuffer;
+ if (inBuffer instanceof EofSensor) {
+ this.eofSensor = (EofSensor) inBuffer;
}
this.requestParser = createRequestParser(
- inbuffer,
+ inBuffer,
createHttpRequestFactory(),
params);
this.responseWriter = createResponseWriter(
outbuffer, params);
this.metrics = createConnectionMetrics(
- inbuffer.getMetrics(),
+ inBuffer.getMetrics(),
outbuffer.getMetrics());
}
+ @Override
public HttpRequest receiveRequestHeader()
throws HttpException, IOException {
assertOpen();
@@ -249,11 +245,12 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
return request;
}
+ @Override
public void receiveRequestEntity(final HttpEntityEnclosingRequest request)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
assertOpen();
- final HttpEntity entity = this.entitydeserializer.deserialize(this.inbuffer, request);
+ final HttpEntity entity = this.entitydeserializer.deserialize(this.inBuffer, request);
request.setEntity(entity);
}
@@ -261,11 +258,13 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
this.outbuffer.flush();
}
+ @Override
public void flush() throws IOException {
assertOpen();
doFlush();
}
+ @Override
public void sendResponseHeader(final HttpResponse response)
throws HttpException, IOException {
Args.notNull(response, "HTTP response");
@@ -276,6 +275,7 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
}
}
+ @Override
public void sendResponseEntity(final HttpResponse response)
throws HttpException, IOException {
if (response.getEntity() == null) {
@@ -291,6 +291,7 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
return this.eofSensor != null && this.eofSensor.isEof();
}
+ @Override
public boolean isStale() {
if (!isOpen()) {
return true;
@@ -299,13 +300,14 @@ public abstract class AbstractHttpServerConnection implements HttpServerConnecti
return true;
}
try {
- this.inbuffer.isDataAvailable(1);
+ this.inBuffer.isDataAvailable(1);
return isEof();
} catch (final IOException ex) {
return true;
}
}
+ @Override
public HttpConnectionMetrics getMetrics() {
return this.metrics;
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/SocketHttpClientConnection.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/SocketHttpClientConnection.java
index 05d120ffe..b2f1c8334 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/SocketHttpClientConnection.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/SocketHttpClientConnection.java
@@ -83,16 +83,16 @@ public class SocketHttpClientConnection
* @see SocketInputBuffer#SocketInputBuffer(Socket, int, HttpParams)
*
* @param socket the socket.
- * @param buffersize the buffer size.
+ * @param bufferSize the buffer size.
* @param params HTTP parameters.
* @return session input buffer.
* @throws IOException in case of an I/O error.
*/
protected SessionInputBuffer createSessionInputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
- return new SocketInputBuffer(socket, buffersize, params);
+ return new SocketInputBuffer(socket, bufferSize, params);
}
/**
@@ -105,16 +105,16 @@ public class SocketHttpClientConnection
* @see SocketOutputBuffer#SocketOutputBuffer(Socket, int, HttpParams)
*
* @param socket the socket.
- * @param buffersize the buffer size.
+ * @param bufferSize the buffer size.
* @param params HTTP parameters.
* @return session output buffer.
* @throws IOException in case of an I/O error.
*/
protected SessionOutputBuffer createSessionOutputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
- return new SocketOutputBuffer(socket, buffersize, params);
+ return new SocketOutputBuffer(socket, bufferSize, params);
}
/**
@@ -142,15 +142,16 @@ public class SocketHttpClientConnection
Args.notNull(params, "HTTP parameters");
this.socket = socket;
- final int buffersize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
+ final int bufferSize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
init(
- createSessionInputBuffer(socket, buffersize, params),
- createSessionOutputBuffer(socket, buffersize, params),
+ createSessionInputBuffer(socket, bufferSize, params),
+ createSessionOutputBuffer(socket, bufferSize, params),
params);
this.open = true;
}
+ @Override
public boolean isOpen() {
return this.open;
}
@@ -159,38 +160,39 @@ public class SocketHttpClientConnection
return this.socket;
}
+ @Override
public InetAddress getLocalAddress() {
if (this.socket != null) {
return this.socket.getLocalAddress();
- } else {
- return null;
}
+ return null;
}
+ @Override
public int getLocalPort() {
if (this.socket != null) {
return this.socket.getLocalPort();
- } else {
- return -1;
}
+ return -1;
}
+ @Override
public InetAddress getRemoteAddress() {
if (this.socket != null) {
return this.socket.getInetAddress();
- } else {
- return null;
}
+ return null;
}
+ @Override
public int getRemotePort() {
if (this.socket != null) {
return this.socket.getPort();
- } else {
- return -1;
}
+ return -1;
}
+ @Override
public void setSocketTimeout(final int timeout) {
assertOpen();
if (this.socket != null) {
@@ -204,18 +206,19 @@ public class SocketHttpClientConnection
}
}
+ @Override
public int getSocketTimeout() {
if (this.socket != null) {
try {
return this.socket.getSoTimeout();
} catch (final SocketException ignore) {
- return -1;
+ // ignore
}
- } else {
- return -1;
}
+ return -1;
}
+ @Override
public void shutdown() throws IOException {
this.open = false;
final Socket tmpsocket = this.socket;
@@ -224,6 +227,7 @@ public class SocketHttpClientConnection
}
}
+ @Override
public void close() throws IOException {
if (!this.open) {
return;
@@ -236,10 +240,12 @@ public class SocketHttpClientConnection
try {
sock.shutdownOutput();
} catch (final IOException ignore) {
+ // ignore
}
try {
sock.shutdownInput();
} catch (final IOException ignore) {
+ // ignore
}
} catch (final UnsupportedOperationException ignore) {
// if one isn't supported, the other one isn't either
@@ -273,9 +279,8 @@ public class SocketHttpClientConnection
formatAddress(buffer, remoteAddress);
}
return buffer.toString();
- } else {
- return super.toString();
}
+ return super.toString();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/SocketHttpServerConnection.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/SocketHttpServerConnection.java
index 97e7e7fc1..6066d362a 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/SocketHttpServerConnection.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/SocketHttpServerConnection.java
@@ -44,6 +44,9 @@ import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
import com.fr.third.org.apache.http.util.Asserts;
+/**
+ * @deprecated Do not use.
+ */
@Deprecated
public class SocketHttpServerConnection extends
AbstractHttpServerConnection implements HttpInetConnection {
@@ -74,16 +77,16 @@ public class SocketHttpServerConnection extends
* @see SocketInputBuffer#SocketInputBuffer(Socket, int, HttpParams)
*
* @param socket the socket.
- * @param buffersize the buffer size.
+ * @param bufferSize the buffer size.
* @param params HTTP parameters.
* @return session input buffer.
* @throws IOException in case of an I/O error.
*/
protected SessionInputBuffer createSessionInputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
- return new SocketInputBuffer(socket, buffersize, params);
+ return new SocketInputBuffer(socket, bufferSize, params);
}
/**
@@ -96,16 +99,16 @@ public class SocketHttpServerConnection extends
* @see SocketOutputBuffer#SocketOutputBuffer(Socket, int, HttpParams)
*
* @param socket the socket.
- * @param buffersize the buffer size.
+ * @param bufferSize the buffer size.
* @param params HTTP parameters.
* @return session output buffer.
* @throws IOException in case of an I/O error.
*/
protected SessionOutputBuffer createSessionOutputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
- return new SocketOutputBuffer(socket, buffersize, params);
+ return new SocketOutputBuffer(socket, bufferSize, params);
}
/**
@@ -131,10 +134,10 @@ public class SocketHttpServerConnection extends
Args.notNull(params, "HTTP parameters");
this.socket = socket;
- final int buffersize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
+ final int bufferSize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
init(
- createSessionInputBuffer(socket, buffersize, params),
- createSessionOutputBuffer(socket, buffersize, params),
+ createSessionInputBuffer(socket, bufferSize, params),
+ createSessionOutputBuffer(socket, bufferSize, params),
params);
this.open = true;
@@ -144,42 +147,44 @@ public class SocketHttpServerConnection extends
return this.socket;
}
+ @Override
public boolean isOpen() {
return this.open;
}
+ @Override
public InetAddress getLocalAddress() {
if (this.socket != null) {
return this.socket.getLocalAddress();
- } else {
- return null;
}
+ return null;
}
+ @Override
public int getLocalPort() {
if (this.socket != null) {
return this.socket.getLocalPort();
- } else {
- return -1;
}
+ return -1;
}
+ @Override
public InetAddress getRemoteAddress() {
if (this.socket != null) {
return this.socket.getInetAddress();
- } else {
- return null;
}
+ return null;
}
+ @Override
public int getRemotePort() {
if (this.socket != null) {
return this.socket.getPort();
- } else {
- return -1;
}
+ return -1;
}
+ @Override
public void setSocketTimeout(final int timeout) {
assertOpen();
if (this.socket != null) {
@@ -193,18 +198,19 @@ public class SocketHttpServerConnection extends
}
}
+ @Override
public int getSocketTimeout() {
if (this.socket != null) {
try {
return this.socket.getSoTimeout();
} catch (final SocketException ignore) {
- return -1;
+ // ignore
}
- } else {
- return -1;
}
+ return -1;
}
+ @Override
public void shutdown() throws IOException {
this.open = false;
final Socket tmpsocket = this.socket;
@@ -213,6 +219,7 @@ public class SocketHttpServerConnection extends
}
}
+ @Override
public void close() throws IOException {
if (!this.open) {
return;
@@ -263,9 +270,8 @@ public class SocketHttpServerConnection extends
formatAddress(buffer, remoteAddress);
}
return buffer.toString();
- } else {
- return super.toString();
}
+ return super.toString();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/entity/EntityDeserializer.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/entity/EntityDeserializer.java
index f7affc454..a02557fae 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/entity/EntityDeserializer.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/entity/EntityDeserializer.java
@@ -29,13 +29,12 @@ package com.fr.third.org.apache.http.impl.entity;
import java.io.IOException;
-import com.fr.third.org.apache.http.impl.BHttpConnectionBase;
import com.fr.third.org.apache.http.Header;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpMessage;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.entity.BasicHttpEntity;
import com.fr.third.org.apache.http.entity.ContentLengthStrategy;
import com.fr.third.org.apache.http.impl.io.ChunkedInputStream;
@@ -61,7 +60,7 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link BHttpConnectionBase}
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.impl.BHttpConnectionBase}
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
@Deprecated
@@ -83,14 +82,14 @@ public class EntityDeserializer {
* This method is called by the public
* {@link #deserialize(SessionInputBuffer, HttpMessage)}.
*
- * @param inbuffer the session input buffer.
+ * @param inBuffer the session input buffer.
* @param message the message.
* @return HTTP entity.
* @throws HttpException in case of HTTP protocol violation.
* @throws IOException in case of an I/O error.
*/
protected BasicHttpEntity doDeserialize(
- final SessionInputBuffer inbuffer,
+ final SessionInputBuffer inBuffer,
final HttpMessage message) throws HttpException, IOException {
final BasicHttpEntity entity = new BasicHttpEntity();
@@ -98,15 +97,15 @@ public class EntityDeserializer {
if (len == ContentLengthStrategy.CHUNKED) {
entity.setChunked(true);
entity.setContentLength(-1);
- entity.setContent(new ChunkedInputStream(inbuffer));
+ entity.setContent(new ChunkedInputStream(inBuffer));
} else if (len == ContentLengthStrategy.IDENTITY) {
entity.setChunked(false);
entity.setContentLength(-1);
- entity.setContent(new IdentityInputStream(inbuffer));
+ entity.setContent(new IdentityInputStream(inBuffer));
} else {
entity.setChunked(false);
entity.setContentLength(len);
- entity.setContent(new ContentLengthInputStream(inbuffer, len));
+ entity.setContent(new ContentLengthInputStream(inBuffer, len));
}
final Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
@@ -128,18 +127,18 @@ public class EntityDeserializer {
*
* The content of the entity is NOT retrieved by this method.
*
- * @param inbuffer the session input buffer.
+ * @param inBuffer the session input buffer.
* @param message the message.
* @return HTTP entity.
* @throws HttpException in case of HTTP protocol violation.
* @throws IOException in case of an I/O error.
*/
public HttpEntity deserialize(
- final SessionInputBuffer inbuffer,
+ final SessionInputBuffer inBuffer,
final HttpMessage message) throws HttpException, IOException {
- Args.notNull(inbuffer, "Session input buffer");
+ Args.notNull(inBuffer, "Session input buffer");
Args.notNull(message, "HTTP message");
- return doDeserialize(inbuffer, message);
+ return doDeserialize(inBuffer, message);
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/entity/EntitySerializer.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/entity/EntitySerializer.java
index 6ffdbe549..ce7e54c33 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/entity/EntitySerializer.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/entity/EntitySerializer.java
@@ -30,12 +30,11 @@ package com.fr.third.org.apache.http.impl.entity;
import java.io.IOException;
import java.io.OutputStream;
-import com.fr.third.org.apache.http.impl.BHttpConnectionBase;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpMessage;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.entity.ContentLengthStrategy;
import com.fr.third.org.apache.http.impl.io.ChunkedOutputStream;
import com.fr.third.org.apache.http.impl.io.ContentLengthOutputStream;
@@ -58,7 +57,7 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link BHttpConnectionBase}
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.impl.BHttpConnectionBase}
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
@Deprecated
@@ -115,9 +114,9 @@ public class EntitySerializer {
Args.notNull(outbuffer, "Session output buffer");
Args.notNull(message, "HTTP message");
Args.notNull(entity, "HTTP entity");
- final OutputStream outstream = doSerialize(outbuffer, message);
- entity.writeTo(outstream);
- outstream.close();
+ final OutputStream outStream = doSerialize(outbuffer, message);
+ entity.writeTo(outStream);
+ outStream.close();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/AbstractSessionInputBuffer.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/AbstractSessionInputBuffer.java
index ad5d96a1d..87702c803 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/AbstractSessionInputBuffer.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/AbstractSessionInputBuffer.java
@@ -36,8 +36,6 @@ import java.nio.charset.CharsetDecoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
-import com.fr.third.org.apache.http.impl.io.HttpTransportMetricsImpl;
-import com.fr.third.org.apache.http.impl.io.SessionInputBufferImpl;
import com.fr.third.org.apache.http.Consts;
import com.fr.third.org.apache.http.io.BufferInfo;
import com.fr.third.org.apache.http.io.HttpTransportMetrics;
@@ -66,9 +64,9 @@ import com.fr.third.org.apache.http.util.CharArrayBuffer;
@Deprecated
public abstract class AbstractSessionInputBuffer implements SessionInputBuffer, BufferInfo {
- private InputStream instream;
+ private InputStream inStream;
private byte[] buffer;
- private ByteArrayBuffer linebuffer;
+ private ByteArrayBuffer lineBuffer;
private Charset charset;
private boolean ascii;
private int maxLineLen;
@@ -77,8 +75,8 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
private CodingErrorAction onMalformedCharAction;
private CodingErrorAction onUnmappableCharAction;
- private int bufferpos;
- private int bufferlen;
+ private int bufferPos;
+ private int bufferLen;
private CharsetDecoder decoder;
private CharBuffer cbuf;
@@ -88,19 +86,19 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
/**
* Initializes this session input buffer.
*
- * @param instream the source input stream.
- * @param buffersize the size of the internal buffer.
+ * @param inputStream the source input stream.
+ * @param bufferSize the size of the internal buffer.
* @param params HTTP parameters.
*/
- protected void init(final InputStream instream, final int buffersize, final HttpParams params) {
- Args.notNull(instream, "Input stream");
- Args.notNegative(buffersize, "Buffer size");
+ protected void init(final InputStream inputStream, final int bufferSize, final HttpParams params) {
+ Args.notNull(inputStream, "Input stream");
+ Args.notNegative(bufferSize, "Buffer size");
Args.notNull(params, "HTTP parameters");
- this.instream = instream;
- this.buffer = new byte[buffersize];
- this.bufferpos = 0;
- this.bufferlen = 0;
- this.linebuffer = new ByteArrayBuffer(buffersize);
+ this.inStream = inputStream;
+ this.buffer = new byte[bufferSize];
+ this.bufferPos = 0;
+ this.bufferLen = 0;
+ this.lineBuffer = new ByteArrayBuffer(bufferSize);
final String charset = (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
this.charset = charset != null ? Charset.forName(charset) : Consts.ASCII;
this.ascii = this.charset.equals(Consts.ASCII);
@@ -126,6 +124,7 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
/**
* @since 4.1
*/
+ @Override
public int capacity() {
return this.buffer.length;
}
@@ -133,44 +132,46 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
/**
* @since 4.1
*/
+ @Override
public int length() {
- return this.bufferlen - this.bufferpos;
+ return this.bufferLen - this.bufferPos;
}
/**
* @since 4.1
*/
+ @Override
public int available() {
return capacity() - length();
}
protected int fillBuffer() throws IOException {
// compact the buffer if necessary
- if (this.bufferpos > 0) {
- final int len = this.bufferlen - this.bufferpos;
+ if (this.bufferPos > 0) {
+ final int len = this.bufferLen - this.bufferPos;
if (len > 0) {
- System.arraycopy(this.buffer, this.bufferpos, this.buffer, 0, len);
+ System.arraycopy(this.buffer, this.bufferPos, this.buffer, 0, len);
}
- this.bufferpos = 0;
- this.bufferlen = len;
+ this.bufferPos = 0;
+ this.bufferLen = len;
}
- final int l;
- final int off = this.bufferlen;
+ final int readLen;
+ final int off = this.bufferLen;
final int len = this.buffer.length - off;
- l = this.instream.read(this.buffer, off, len);
- if (l == -1) {
+ readLen = this.inStream.read(this.buffer, off, len);
+ if (readLen == -1) {
return -1;
- } else {
- this.bufferlen = off + l;
- this.metrics.incrementBytesTransferred(l);
- return l;
}
+ this.bufferLen = off + readLen;
+ this.metrics.incrementBytesTransferred(readLen);
+ return readLen;
}
protected boolean hasBufferedData() {
- return this.bufferpos < this.bufferlen;
+ return this.bufferPos < this.bufferLen;
}
+ @Override
public int read() throws IOException {
int noRead;
while (!hasBufferedData()) {
@@ -179,42 +180,43 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
return -1;
}
}
- return this.buffer[this.bufferpos++] & 0xff;
+ return this.buffer[this.bufferPos++] & 0xff;
}
+ @Override
public int read(final byte[] b, final int off, final int len) throws IOException {
if (b == null) {
return 0;
}
if (hasBufferedData()) {
- final int chunk = Math.min(len, this.bufferlen - this.bufferpos);
- System.arraycopy(this.buffer, this.bufferpos, b, off, chunk);
- this.bufferpos += chunk;
+ final int chunk = Math.min(len, this.bufferLen - this.bufferPos);
+ System.arraycopy(this.buffer, this.bufferPos, b, off, chunk);
+ this.bufferPos += chunk;
return chunk;
}
// If the remaining capacity is big enough, read directly from the
// underlying input stream bypassing the buffer.
if (len > this.minChunkLimit) {
- final int read = this.instream.read(b, off, len);
+ final int read = this.inStream.read(b, off, len);
if (read > 0) {
this.metrics.incrementBytesTransferred(read);
}
return read;
- } else {
- // otherwise read to the buffer first
- while (!hasBufferedData()) {
- final int noRead = fillBuffer();
- if (noRead == -1) {
- return -1;
- }
+ }
+ // otherwise read to the buffer first
+ while (!hasBufferedData()) {
+ final int noRead = fillBuffer();
+ if (noRead == -1) {
+ return -1;
}
- final int chunk = Math.min(len, this.bufferlen - this.bufferpos);
- System.arraycopy(this.buffer, this.bufferpos, b, off, chunk);
- this.bufferpos += chunk;
- return chunk;
}
+ final int chunk = Math.min(len, this.bufferLen - this.bufferPos);
+ System.arraycopy(this.buffer, this.bufferPos, b, off, chunk);
+ this.bufferPos += chunk;
+ return chunk;
}
+ @Override
public int read(final byte[] b) throws IOException {
if (b == null) {
return 0;
@@ -223,7 +225,7 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
}
private int locateLF() {
- for (int i = this.bufferpos; i < this.bufferlen; i++) {
+ for (int i = this.bufferPos; i < this.bufferLen; i++) {
if (this.buffer[i] == HTTP.LF) {
return i;
}
@@ -244,8 +246,9 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
*
* @param charbuffer the line buffer.
* @return one line of characters
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
+ @Override
public int readLine(final CharArrayBuffer charbuffer) throws IOException {
Args.notNull(charbuffer, "Char array buffer");
int noRead = 0;
@@ -255,31 +258,31 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
final int i = locateLF();
if (i != -1) {
// end of line found.
- if (this.linebuffer.isEmpty()) {
+ if (this.lineBuffer.isEmpty()) {
// the entire line is preset in the read buffer
return lineFromReadBuffer(charbuffer, i);
}
retry = false;
- final int len = i + 1 - this.bufferpos;
- this.linebuffer.append(this.buffer, this.bufferpos, len);
- this.bufferpos = i + 1;
+ final int len = i + 1 - this.bufferPos;
+ this.lineBuffer.append(this.buffer, this.bufferPos, len);
+ this.bufferPos = i + 1;
} else {
// end of line not found
if (hasBufferedData()) {
- final int len = this.bufferlen - this.bufferpos;
- this.linebuffer.append(this.buffer, this.bufferpos, len);
- this.bufferpos = this.bufferlen;
+ final int len = this.bufferLen - this.bufferPos;
+ this.lineBuffer.append(this.buffer, this.bufferPos, len);
+ this.bufferPos = this.bufferLen;
}
noRead = fillBuffer();
if (noRead == -1) {
retry = false;
}
}
- if (this.maxLineLen > 0 && this.linebuffer.length() >= this.maxLineLen) {
+ if (this.maxLineLen > 0 && this.lineBuffer.length() >= this.maxLineLen) {
throw new IOException("Maximum line length limit exceeded");
}
}
- if (noRead == -1 && this.linebuffer.isEmpty()) {
+ if (noRead == -1 && this.lineBuffer.isEmpty()) {
// indicate the end of stream
return -1;
}
@@ -297,38 +300,38 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
* to CR-LF required by the HTTP specification.
*
* @return HTTP line as a string
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
private int lineFromLineBuffer(final CharArrayBuffer charbuffer)
throws IOException {
// discard LF if found
- int len = this.linebuffer.length();
+ int len = this.lineBuffer.length();
if (len > 0) {
- if (this.linebuffer.byteAt(len - 1) == HTTP.LF) {
+ if (this.lineBuffer.byteAt(len - 1) == HTTP.LF) {
len--;
}
// discard CR if found
if (len > 0) {
- if (this.linebuffer.byteAt(len - 1) == HTTP.CR) {
+ if (this.lineBuffer.byteAt(len - 1) == HTTP.CR) {
len--;
}
}
}
if (this.ascii) {
- charbuffer.append(this.linebuffer, 0, len);
+ charbuffer.append(this.lineBuffer, 0, len);
} else {
- final ByteBuffer bbuf = ByteBuffer.wrap(this.linebuffer.buffer(), 0, len);
+ final ByteBuffer bbuf = ByteBuffer.wrap(this.lineBuffer.buffer(), 0, len);
len = appendDecoded(charbuffer, bbuf);
}
- this.linebuffer.clear();
+ this.lineBuffer.clear();
return len;
}
private int lineFromReadBuffer(final CharArrayBuffer charbuffer, final int position)
throws IOException {
- final int off = this.bufferpos;
+ final int off = this.bufferPos;
int i = position;
- this.bufferpos = i + 1;
+ this.bufferPos = i + 1;
if (i > off && this.buffer[i - 1] == HTTP.CR) {
// skip CR if found
i--;
@@ -384,16 +387,17 @@ public abstract class AbstractSessionInputBuffer implements SessionInputBuffer,
return len;
}
+ @Override
public String readLine() throws IOException {
final CharArrayBuffer charbuffer = new CharArrayBuffer(64);
- final int l = readLine(charbuffer);
- if (l != -1) {
+ final int readLen = readLine(charbuffer);
+ if (readLen != -1) {
return charbuffer.toString();
- } else {
- return null;
}
+ return null;
}
+ @Override
public HttpTransportMetrics getMetrics() {
return this.metrics;
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/AbstractSessionOutputBuffer.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/AbstractSessionOutputBuffer.java
index 838cfb922..e02e1103c 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/AbstractSessionOutputBuffer.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/AbstractSessionOutputBuffer.java
@@ -36,8 +36,6 @@ import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
-import com.fr.third.org.apache.http.impl.io.HttpTransportMetricsImpl;
-import com.fr.third.org.apache.http.impl.io.SessionOutputBufferImpl;
import com.fr.third.org.apache.http.Consts;
import com.fr.third.org.apache.http.io.BufferInfo;
import com.fr.third.org.apache.http.io.HttpTransportMetrics;
@@ -67,7 +65,7 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
private static final byte[] CRLF = new byte[] {HTTP.CR, HTTP.LF};
- private OutputStream outstream;
+ private OutputStream outStream;
private ByteArrayBuffer buffer;
private Charset charset;
private boolean ascii;
@@ -80,17 +78,17 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
private ByteBuffer bbuf;
protected AbstractSessionOutputBuffer(
- final OutputStream outstream,
- final int buffersize,
+ final OutputStream outStream,
+ final int bufferSize,
final Charset charset,
final int minChunkLimit,
final CodingErrorAction malformedCharAction,
final CodingErrorAction unmappableCharAction) {
super();
- Args.notNull(outstream, "Input stream");
- Args.notNegative(buffersize, "Buffer size");
- this.outstream = outstream;
- this.buffer = new ByteArrayBuffer(buffersize);
+ Args.notNull(outStream, "Input stream");
+ Args.notNegative(bufferSize, "Buffer size");
+ this.outStream = outStream;
+ this.buffer = new ByteArrayBuffer(bufferSize);
this.charset = charset != null ? charset : Consts.ASCII;
this.ascii = this.charset.equals(Consts.ASCII);
this.encoder = null;
@@ -105,12 +103,12 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
public AbstractSessionOutputBuffer() {
}
- protected void init(final OutputStream outstream, final int buffersize, final HttpParams params) {
- Args.notNull(outstream, "Input stream");
- Args.notNegative(buffersize, "Buffer size");
+ protected void init(final OutputStream outStream, final int bufferSize, final HttpParams params) {
+ Args.notNull(outStream, "Input stream");
+ Args.notNegative(bufferSize, "Buffer size");
Args.notNull(params, "HTTP parameters");
- this.outstream = outstream;
- this.buffer = new ByteArrayBuffer(buffersize);
+ this.outStream = outStream;
+ this.buffer = new ByteArrayBuffer(bufferSize);
final String charset = (String) params.getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
this.charset = charset != null ? Charset.forName(charset) : Consts.ASCII;
this.ascii = this.charset.equals(Consts.ASCII);
@@ -135,6 +133,7 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
/**
* @since 4.1
*/
+ @Override
public int capacity() {
return this.buffer.capacity();
}
@@ -142,6 +141,7 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
/**
* @since 4.1
*/
+ @Override
public int length() {
return this.buffer.length();
}
@@ -149,6 +149,7 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
/**
* @since 4.1
*/
+ @Override
public int available() {
return capacity() - length();
}
@@ -156,17 +157,19 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
protected void flushBuffer() throws IOException {
final int len = this.buffer.length();
if (len > 0) {
- this.outstream.write(this.buffer.buffer(), 0, len);
+ this.outStream.write(this.buffer.buffer(), 0, len);
this.buffer.clear();
this.metrics.incrementBytesTransferred(len);
}
}
+ @Override
public void flush() throws IOException {
flushBuffer();
- this.outstream.flush();
+ this.outStream.flush();
}
+ @Override
public void write(final byte[] b, final int off, final int len) throws IOException {
if (b == null) {
return;
@@ -178,7 +181,7 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
// flush the buffer
flushBuffer();
// write directly to the out stream
- this.outstream.write(b, off, len);
+ this.outStream.write(b, off, len);
this.metrics.incrementBytesTransferred(len);
} else {
// Do not let the buffer grow unnecessarily
@@ -192,6 +195,7 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
}
}
+ @Override
public void write(final byte[] b) throws IOException {
if (b == null) {
return;
@@ -199,6 +203,7 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
write(b, 0, b.length);
}
+ @Override
public void write(final int b) throws IOException {
if (this.buffer.isFull()) {
flushBuffer();
@@ -213,8 +218,9 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
* This method uses CR-LF as a line delimiter.
*
* @param s the line.
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
+ @Override
public void writeLine(final String s) throws IOException {
if (s == null) {
return;
@@ -239,8 +245,9 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
* This method uses CR-LF as a line delimiter.
*
* @param charbuffer the buffer containing chars of the line.
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
+ @Override
public void writeLine(final CharArrayBuffer charbuffer) throws IOException {
if (charbuffer == null) {
return;
@@ -300,6 +307,7 @@ public abstract class AbstractSessionOutputBuffer implements SessionOutputBuffer
this.bbuf.compact();
}
+ @Override
public HttpTransportMetrics getMetrics() {
return this.metrics;
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/HttpRequestParser.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/HttpRequestParser.java
index 6933e0d57..1951b0d90 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/HttpRequestParser.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/HttpRequestParser.java
@@ -29,10 +29,6 @@ package com.fr.third.org.apache.http.impl.io;
import java.io.IOException;
-import com.fr.third.org.apache.http.HttpRequest;
-import com.fr.third.org.apache.http.impl.io.AbstractMessageParser;
-import com.fr.third.org.apache.http.impl.io.DefaultHttpRequestParser;
-import com.fr.third.org.apache.http.params.CoreConnectionPNames;
import com.fr.third.org.apache.http.ConnectionClosedException;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpMessage;
@@ -53,8 +49,8 @@ import com.fr.third.org.apache.http.util.CharArrayBuffer;
* The following parameters can be used to customize the behavior of this
* class:
*
*
* @since 4.0
@@ -73,7 +69,7 @@ public class HttpResponseParser extends AbstractMessageParser {
* @param buffer the session input buffer.
* @param parser the line parser.
* @param responseFactory the factory to use to create
- * {@link HttpResponse}s.
+ * {@link com.fr.third.org.apache.http.HttpResponse}s.
* @param params HTTP parameters.
*/
public HttpResponseParser(
@@ -92,8 +88,8 @@ public class HttpResponseParser extends AbstractMessageParser {
throws IOException, HttpException, ParseException {
this.lineBuf.clear();
- final int i = sessionBuffer.readLine(this.lineBuf);
- if (i == -1) {
+ final int readLen = sessionBuffer.readLine(this.lineBuf);
+ if (readLen == -1) {
throw new NoHttpResponseException("The target server failed to respond");
}
//create the status line from the status string
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/HttpResponseWriter.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/HttpResponseWriter.java
index 3ec7e0faa..5d41d1464 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/HttpResponseWriter.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/HttpResponseWriter.java
@@ -29,8 +29,6 @@ package com.fr.third.org.apache.http.impl.io;
import java.io.IOException;
-import com.fr.third.org.apache.http.impl.io.AbstractMessageWriter;
-import com.fr.third.org.apache.http.impl.io.DefaultHttpResponseWriter;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.io.SessionOutputBuffer;
import com.fr.third.org.apache.http.message.LineFormatter;
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/SocketInputBuffer.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/SocketInputBuffer.java
index ddca4e77e..0dcf8634e 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/SocketInputBuffer.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/SocketInputBuffer.java
@@ -31,12 +31,11 @@ import java.io.IOException;
import java.net.Socket;
import com.fr.third.org.apache.http.io.EofSensor;
-import com.fr.third.org.apache.http.io.SessionInputBuffer;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
/**
- * {@link SessionInputBuffer} implementation
+ * {@link com.fr.third.org.apache.http.io.SessionInputBuffer} implementation
* bound to a {@link Socket}.
*
* @since 4.0
@@ -54,7 +53,7 @@ public class SocketInputBuffer extends AbstractSessionInputBuffer implements Eof
* Creates an instance of this class.
*
* @param socket the socket to read data from.
- * @param buffersize the size of the internal buffer. If this number is less
+ * @param bufferSize the size of the internal buffer. If this number is less
* than {@code 0} it is set to the value of
* {@link Socket#getReceiveBufferSize()}. If resultant number is less
* than {@code 1024} it is set to {@code 1024}.
@@ -62,13 +61,13 @@ public class SocketInputBuffer extends AbstractSessionInputBuffer implements Eof
*/
public SocketInputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
super();
Args.notNull(socket, "Socket");
this.socket = socket;
this.eof = false;
- int n = buffersize;
+ int n = bufferSize;
if (n < 0) {
n = socket.getReceiveBufferSize();
}
@@ -85,6 +84,7 @@ public class SocketInputBuffer extends AbstractSessionInputBuffer implements Eof
return i;
}
+ @Override
public boolean isDataAvailable(final int timeout) throws IOException {
boolean result = hasBufferedData();
if (!result) {
@@ -100,6 +100,7 @@ public class SocketInputBuffer extends AbstractSessionInputBuffer implements Eof
return result;
}
+ @Override
public boolean isEof() {
return this.eof;
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/SocketOutputBuffer.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/SocketOutputBuffer.java
index 27e7e5412..37c2184f5 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/SocketOutputBuffer.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/impl/io/SocketOutputBuffer.java
@@ -30,12 +30,11 @@ package com.fr.third.org.apache.http.impl.io;
import java.io.IOException;
import java.net.Socket;
-import com.fr.third.org.apache.http.io.SessionOutputBuffer;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
/**
- * {@link SessionOutputBuffer} implementation
+ * {@link com.fr.third.org.apache.http.io.SessionOutputBuffer} implementation
* bound to a {@link Socket}.
*
* @since 4.0
@@ -49,7 +48,7 @@ public class SocketOutputBuffer extends AbstractSessionOutputBuffer {
* Creates an instance of this class.
*
* @param socket the socket to write data to.
- * @param buffersize the size of the internal buffer. If this number is less
+ * @param bufferSize the size of the internal buffer. If this number is less
* than {@code 0} it is set to the value of
* {@link Socket#getSendBufferSize()}. If resultant number is less
* than {@code 1024} it is set to {@code 1024}.
@@ -57,11 +56,11 @@ public class SocketOutputBuffer extends AbstractSessionOutputBuffer {
*/
public SocketOutputBuffer(
final Socket socket,
- final int buffersize,
+ final int bufferSize,
final HttpParams params) throws IOException {
super();
Args.notNull(socket, "Socket");
- int n = buffersize;
+ int n = bufferSize;
if (n < 0) {
n = socket.getSendBufferSize();
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/DefaultedHttpParams.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/DefaultedHttpParams.java
index ef175a422..30be9269d 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/DefaultedHttpParams.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/DefaultedHttpParams.java
@@ -40,8 +40,8 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Deprecated
public final class DefaultedHttpParams extends AbstractHttpParams {
@@ -64,6 +64,7 @@ public final class DefaultedHttpParams extends AbstractHttpParams {
/**
* Creates a copy of the local collection with the same default
*/
+ @Override
public HttpParams copy() {
final HttpParams clone = this.local.copy();
return new DefaultedHttpParams(clone, this.defaults);
@@ -74,6 +75,7 @@ public final class DefaultedHttpParams extends AbstractHttpParams {
* parameter is not set locally, delegates its resolution to the default
* collection.
*/
+ @Override
public Object getParameter(final String name) {
Object obj = this.local.getParameter(name);
if (obj == null && this.defaults != null) {
@@ -86,6 +88,7 @@ public final class DefaultedHttpParams extends AbstractHttpParams {
* Attempts to remove the parameter from the local collection. This method
* does not modify the default collection.
*/
+ @Override
public boolean removeParameter(final String name) {
return this.local.removeParameter(name);
}
@@ -94,6 +97,7 @@ public final class DefaultedHttpParams extends AbstractHttpParams {
* Sets the parameter in the local collection. This method does not
* modify the default collection.
*/
+ @Override
public HttpParams setParameter(final String name, final Object value) {
return this.local.setParameter(name, value);
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpAbstractParamBean.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpAbstractParamBean.java
index a11d1b00b..01cba4f02 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpAbstractParamBean.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpAbstractParamBean.java
@@ -27,14 +27,13 @@
package com.fr.third.org.apache.http.params;
-import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
/**
* @since 4.0
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Deprecated
public abstract class HttpAbstractParamBean {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpConnectionParamBean.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpConnectionParamBean.java
index 50717cb23..d008a1844 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpConnectionParamBean.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpConnectionParamBean.java
@@ -34,8 +34,8 @@ package com.fr.third.org.apache.http.params;
*
* @since 4.0
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Deprecated
public class HttpConnectionParamBean extends HttpAbstractParamBean {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpConnectionParams.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpConnectionParams.java
index ee6260623..312cdcba7 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpConnectionParams.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpConnectionParams.java
@@ -27,8 +27,6 @@
package com.fr.third.org.apache.http.params;
-import com.fr.third.org.apache.http.params.CoreConnectionPNames;
-import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.util.Args;
/**
@@ -36,8 +34,8 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Deprecated
public final class HttpConnectionParams implements CoreConnectionPNames {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpProtocolParamBean.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpProtocolParamBean.java
index 5c0c263f1..096ac7477 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpProtocolParamBean.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpProtocolParamBean.java
@@ -36,8 +36,8 @@ import com.fr.third.org.apache.http.HttpVersion;
*
* @since 4.0
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Deprecated
public class HttpProtocolParamBean extends HttpAbstractParamBean {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpProtocolParams.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpProtocolParams.java
index b43533108..6fdb427c0 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpProtocolParams.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/HttpProtocolParams.java
@@ -29,8 +29,6 @@ package com.fr.third.org.apache.http.params;
import java.nio.charset.CodingErrorAction;
-import com.fr.third.org.apache.http.params.CoreProtocolPNames;
-import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.HttpVersion;
import com.fr.third.org.apache.http.ProtocolVersion;
import com.fr.third.org.apache.http.protocol.HTTP;
@@ -41,8 +39,8 @@ import com.fr.third.org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Deprecated
public final class HttpProtocolParams implements CoreProtocolPNames {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/SyncBasicHttpParams.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/SyncBasicHttpParams.java
index 9ac50ef20..271396751 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/SyncBasicHttpParams.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/params/SyncBasicHttpParams.java
@@ -26,18 +26,16 @@
*/
package com.fr.third.org.apache.http.params;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
-import com.fr.third.org.apache.http.params.BasicHttpParams;
-import com.fr.third.org.apache.http.params.HttpParams;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
/**
* Thread-safe extension of the {@link BasicHttpParams}.
*
* @since 4.1
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Contract(threading = ThreadingBehavior.SAFE)
@Deprecated
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/BasicHttpProcessor.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/BasicHttpProcessor.java
index 792acf940..013296afa 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/BasicHttpProcessor.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/BasicHttpProcessor.java
@@ -57,6 +57,7 @@ public final class BasicHttpProcessor implements
protected final List requestInterceptors = new ArrayList();
protected final List responseInterceptors = new ArrayList();
+ @Override
public void addRequestInterceptor(final HttpRequestInterceptor itcp) {
if (itcp == null) {
return;
@@ -64,6 +65,7 @@ public final class BasicHttpProcessor implements
this.requestInterceptors.add(itcp);
}
+ @Override
public void addRequestInterceptor(
final HttpRequestInterceptor itcp, final int index) {
if (itcp == null) {
@@ -72,6 +74,7 @@ public final class BasicHttpProcessor implements
this.requestInterceptors.add(index, itcp);
}
+ @Override
public void addResponseInterceptor(
final HttpResponseInterceptor itcp, final int index) {
if (itcp == null) {
@@ -80,6 +83,7 @@ public final class BasicHttpProcessor implements
this.responseInterceptors.add(index, itcp);
}
+ @Override
public void removeRequestInterceptorByClass(final Class extends HttpRequestInterceptor> clazz) {
for (final Iterator it = this.requestInterceptors.iterator();
it.hasNext(); ) {
@@ -90,6 +94,7 @@ public final class BasicHttpProcessor implements
}
}
+ @Override
public void removeResponseInterceptorByClass(final Class extends HttpResponseInterceptor> clazz) {
for (final Iterator it = this.responseInterceptors.iterator();
it.hasNext(); ) {
@@ -100,18 +105,20 @@ public final class BasicHttpProcessor implements
}
}
- public final void addInterceptor(final HttpRequestInterceptor interceptor) {
+ public void addInterceptor(final HttpRequestInterceptor interceptor) {
addRequestInterceptor(interceptor);
}
- public final void addInterceptor(final HttpRequestInterceptor interceptor, final int index) {
+ public void addInterceptor(final HttpRequestInterceptor interceptor, final int index) {
addRequestInterceptor(interceptor, index);
}
+ @Override
public int getRequestInterceptorCount() {
return this.requestInterceptors.size();
}
+ @Override
public HttpRequestInterceptor getRequestInterceptor(final int index) {
if ((index < 0) || (index >= this.requestInterceptors.size())) {
return null;
@@ -119,10 +126,12 @@ public final class BasicHttpProcessor implements
return this.requestInterceptors.get(index);
}
+ @Override
public void clearRequestInterceptors() {
this.requestInterceptors.clear();
}
+ @Override
public void addResponseInterceptor(final HttpResponseInterceptor itcp) {
if (itcp == null) {
return;
@@ -130,18 +139,20 @@ public final class BasicHttpProcessor implements
this.responseInterceptors.add(itcp);
}
- public final void addInterceptor(final HttpResponseInterceptor interceptor) {
+ public void addInterceptor(final HttpResponseInterceptor interceptor) {
addResponseInterceptor(interceptor);
}
- public final void addInterceptor(final HttpResponseInterceptor interceptor, final int index) {
+ public void addInterceptor(final HttpResponseInterceptor interceptor, final int index) {
addResponseInterceptor(interceptor, index);
}
+ @Override
public int getResponseInterceptorCount() {
return this.responseInterceptors.size();
}
+ @Override
public HttpResponseInterceptor getResponseInterceptor(final int index) {
if ((index < 0) || (index >= this.responseInterceptors.size())) {
return null;
@@ -149,6 +160,7 @@ public final class BasicHttpProcessor implements
return this.responseInterceptors.get(index);
}
+ @Override
public void clearResponseInterceptors() {
this.responseInterceptors.clear();
}
@@ -170,6 +182,7 @@ public final class BasicHttpProcessor implements
* @param list the list of request and response interceptors
* from which to initialize
*/
+ @Override
public void setInterceptors(final List> list) {
Args.notNull(list, "Inteceptor list");
this.requestInterceptors.clear();
@@ -192,6 +205,7 @@ public final class BasicHttpProcessor implements
clearResponseInterceptors();
}
+ @Override
public void process(
final HttpRequest request,
final HttpContext context)
@@ -201,6 +215,7 @@ public final class BasicHttpProcessor implements
}
}
+ @Override
public void process(
final HttpResponse response,
final HttpContext context)
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/DefaultedHttpContext.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/DefaultedHttpContext.java
index 3c42171a9..d99d6b00a 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/DefaultedHttpContext.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/DefaultedHttpContext.java
@@ -27,7 +27,6 @@
package com.fr.third.org.apache.http.protocol;
-import com.fr.third.org.apache.http.protocol.HttpContext;
import com.fr.third.org.apache.http.util.Args;
/**
@@ -52,19 +51,21 @@ public final class DefaultedHttpContext implements HttpContext {
this.defaults = defaults;
}
+ @Override
public Object getAttribute(final String id) {
final Object obj = this.local.getAttribute(id);
if (obj == null) {
return this.defaults.getAttribute(id);
- } else {
- return obj;
}
+ return obj;
}
+ @Override
public Object removeAttribute(final String id) {
return this.local.removeAttribute(id);
}
+ @Override
public void setAttribute(final String id, final Object obj) {
this.local.setAttribute(id, obj);
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/ExecutionContext.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/ExecutionContext.java
index 3230d4e88..07f1faaf4 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/ExecutionContext.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/ExecutionContext.java
@@ -27,13 +27,6 @@
package com.fr.third.org.apache.http.protocol;
-import com.fr.third.org.apache.http.HttpConnection;
-import com.fr.third.org.apache.http.HttpHost;
-import com.fr.third.org.apache.http.HttpRequest;
-import com.fr.third.org.apache.http.HttpResponse;
-import com.fr.third.org.apache.http.protocol.HttpContext;
-import com.fr.third.org.apache.http.protocol.HttpCoreContext;
-
/**
* {@link HttpContext} attribute names for protocol execution.
*
@@ -45,43 +38,42 @@ import com.fr.third.org.apache.http.protocol.HttpCoreContext;
public interface ExecutionContext {
/**
- * Attribute name of a {@link HttpConnection} object that
+ * Attribute name of a {@link com.fr.third.org.apache.http.HttpConnection} object that
* represents the actual HTTP connection.
*/
- public static final String HTTP_CONNECTION = "http.connection";
+ String HTTP_CONNECTION = "http.connection";
/**
- * Attribute name of a {@link HttpRequest} object that
+ * Attribute name of a {@link com.fr.third.org.apache.http.HttpRequest} object that
* represents the actual HTTP request.
*/
- public static final String HTTP_REQUEST = "http.request";
+ String HTTP_REQUEST = "http.request";
/**
- * Attribute name of a {@link HttpResponse} object that
+ * Attribute name of a {@link com.fr.third.org.apache.http.HttpResponse} object that
* represents the actual HTTP response.
*/
- public static final String HTTP_RESPONSE = "http.response";
+ String HTTP_RESPONSE = "http.response";
/**
- * Attribute name of a {@link HttpHost} object that
+ * Attribute name of a {@link com.fr.third.org.apache.http.HttpHost} object that
* represents the connection target.
*/
- public static final String HTTP_TARGET_HOST = "http.target_host";
+ String HTTP_TARGET_HOST = "http.target_host";
/**
- * Attribute name of a {@link HttpHost} object that
+ * Attribute name of a {@link com.fr.third.org.apache.http.HttpHost} object that
* represents the connection proxy.
*
* @deprecated (4.3) do not use.
*/
- @Deprecated
- public static final String HTTP_PROXY_HOST = "http.proxy_host";
+ @Deprecated String HTTP_PROXY_HOST = "http.proxy_host";
/**
* Attribute name of a {@link Boolean} object that represents the
* the flag indicating whether the actual request has been fully transmitted
* to the target host.
*/
- public static final String HTTP_REQ_SENT = "http.request_sent";
+ String HTTP_REQ_SENT = "http.request_sent";
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/HttpRequestHandlerRegistry.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/HttpRequestHandlerRegistry.java
index b986ec1e5..0f317c0f1 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/HttpRequestHandlerRegistry.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/HttpRequestHandlerRegistry.java
@@ -29,12 +29,8 @@ package com.fr.third.org.apache.http.protocol;
import java.util.Map;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
-import com.fr.third.org.apache.http.protocol.HttpRequestHandler;
-import com.fr.third.org.apache.http.protocol.HttpRequestHandlerResolver;
-import com.fr.third.org.apache.http.protocol.UriHttpRequestHandlerMapper;
-import com.fr.third.org.apache.http.protocol.UriPatternMatcher;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.util.Args;
/**
@@ -105,6 +101,7 @@ public class HttpRequestHandlerRegistry implements HttpRequestHandlerResolver {
return matcher.getObjects();
}
+ @Override
public HttpRequestHandler lookup(final String requestURI) {
return matcher.lookup(requestURI);
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/SyncBasicHttpContext.java b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/SyncBasicHttpContext.java
index 7e55697f2..bb395c98a 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/SyncBasicHttpContext.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java-deprecated/com/fr/third/org/apache/http/protocol/SyncBasicHttpContext.java
@@ -27,9 +27,6 @@
package com.fr.third.org.apache.http.protocol;
-import com.fr.third.org.apache.http.protocol.BasicHttpContext;
-import com.fr.third.org.apache.http.protocol.HttpContext;
-
/**
* Thread-safe extension of the {@link BasicHttpContext}.
*
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ConnectionClosedException.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ConnectionClosedException.java
index c0153330a..07e12aa16 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ConnectionClosedException.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ConnectionClosedException.java
@@ -38,13 +38,34 @@ public class ConnectionClosedException extends IOException {
private static final long serialVersionUID = 617550366255636674L;
+ /**
+ * Creates a new ConnectionClosedException with the message "Connection is closed".
+ *
+ * @since 4.4.11
+ */
+ public ConnectionClosedException() {
+ super("Connection is closed");
+ }
+
/**
* Creates a new ConnectionClosedException with the specified detail message.
*
* @param message The exception detail message
*/
public ConnectionClosedException(final String message) {
- super(message);
+ super(HttpException.clean(message));
+ }
+
+ /**
+ * Constructs a new ConnectionClosedException with the specified detail message.
+ *
+ * @param format The exception detail message format; see {@link String#format(String, Object...)}.
+ * @param args The exception detail message arguments; see {@link String#format(String, Object...)}.
+ *
+ * @since 4.4.11
+ */
+ public ConnectionClosedException(final String format, final Object... args) {
+ super(HttpException.clean(String.format(format, args)));
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ContentTooLongException.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ContentTooLongException.java
index f90ca769b..1607a5cc3 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ContentTooLongException.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ContentTooLongException.java
@@ -47,4 +47,16 @@ public class ContentTooLongException extends IOException {
super(message);
}
+ /**
+ * Constructs a new ContentTooLongException with the specified detail message.
+ *
+ * @param format The exception detail message format; see {@link String#format(String, Object...)}.
+ * @param args The exception detail message arguments; see {@link String#format(String, Object...)}.
+ *
+ * @since 4.4.11
+ */
+ public ContentTooLongException(final String format, final Object... args) {
+ super(HttpException.clean(String.format(format, args)));
+ }
+
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ExceptionLogger.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ExceptionLogger.java
index c1e222775..675dceed4 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ExceptionLogger.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ExceptionLogger.java
@@ -31,15 +31,16 @@ package com.fr.third.org.apache.http;
*/
public interface ExceptionLogger {
- public static final ExceptionLogger NO_OP = new ExceptionLogger() {
+ ExceptionLogger NO_OP = new ExceptionLogger() {
@Override
public void log(final Exception ex) {
+ // do nothing
}
};
- public static final ExceptionLogger STD_ERR = new ExceptionLogger() {
+ ExceptionLogger STD_ERR = new ExceptionLogger() {
@Override
public void log(final Exception ex) {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/Header.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/Header.java
index 711405a32..6ed28bc54 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/Header.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/Header.java
@@ -47,21 +47,7 @@ package com.fr.third.org.apache.http;
*
* @since 4.0
*/
-public interface Header {
-
- /**
- * Get the name of the Header.
- *
- * @return the name of the Header, never {@code null}
- */
- String getName();
-
- /**
- * Get the value of the Header.
- *
- * @return the value of the Header, may be {@code null}
- */
- String getValue();
+public interface Header extends NameValuePair {
/**
* Parses the value.
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpEntity.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpEntity.java
index d1bb86dfd..180ac5757 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpEntity.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpEntity.java
@@ -27,8 +27,6 @@
package com.fr.third.org.apache.http;
-import com.fr.third.org.apache.http.util.EntityUtils;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -95,7 +93,7 @@ public interface HttpEntity {
*
* @return the number of bytes of the content, or
* a negative number if unknown. If the content length is known
- * but exceeds {@link java.lang.Long#MAX_VALUE Long.MAX_VALUE},
+ * but exceeds {@link Long#MAX_VALUE Long.MAX_VALUE},
* a negative number is returned.
*/
long getContentLength();
@@ -140,7 +138,7 @@ public interface HttpEntity {
*
* @throws IOException if the stream could not be created
* @throws UnsupportedOperationException
- * if entity content cannot be represented as {@link java.io.InputStream}.
+ * if entity content cannot be represented as {@link InputStream}.
*
* @see #isRepeatable()
*/
@@ -153,11 +151,11 @@ public interface HttpEntity {
* all allocated resources are properly deallocated when this method
* returns.
*
- * @param outstream the output stream to write entity content to
+ * @param outStream the output stream to write entity content to
*
* @throws IOException if an I/O error occurs
*/
- void writeTo(OutputStream outstream) throws IOException;
+ void writeTo(OutputStream outStream) throws IOException;
/**
* Tells whether this entity depends on an underlying stream.
@@ -191,7 +189,7 @@ public interface HttpEntity {
*
* @throws IOException if an I/O error occurs.
*
- * @deprecated (4.1) Use {@link EntityUtils#consume(HttpEntity)}
+ * @deprecated (4.1) Use {@link com.fr.third.org.apache.http.util.EntityUtils#consume(HttpEntity)}
*
* @see #getContent() and #writeTo(OutputStream)
*/
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpException.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpException.java
index 17afb3fb1..a3b803283 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpException.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpException.java
@@ -34,8 +34,46 @@ package com.fr.third.org.apache.http;
*/
public class HttpException extends Exception {
+ private static final int FIRST_VALID_CHAR = 32;
private static final long serialVersionUID = -5437299376222011036L;
+ /**
+ * Converts characters < 32 to hex.
+ *
+ * @param message
+ * the source string.
+ * @return a converted string.
+ */
+ static String clean(final String message) {
+ final char[] chars = message.toCharArray();
+ int i;
+ // First check to see if need to allocate a new StringBuilder
+ for (i = 0; i < chars.length; i++) {
+ if (chars[i] < FIRST_VALID_CHAR) {
+ break;
+ }
+ }
+ if (i == chars.length) {
+ return message;
+ }
+ final StringBuilder builder = new StringBuilder(chars.length * 2);
+ for (i = 0; i < chars.length; i++) {
+ final char ch = chars[i];
+ if (ch < FIRST_VALID_CHAR) {
+ builder.append("[0x");
+ final String hexString = Integer.toHexString(i);
+ if (hexString.length() == 1) {
+ builder.append("0");
+ }
+ builder.append(hexString);
+ builder.append("]");
+ } else {
+ builder.append(ch);
+ }
+ }
+ return builder.toString();
+ }
+
/**
* Creates a new HttpException with a {@code null} detail message.
*/
@@ -46,21 +84,25 @@ public class HttpException extends Exception {
/**
* Creates a new HttpException with the specified detail message.
*
- * @param message the exception detail message
+ * @param message
+ * the exception detail message
*/
public HttpException(final String message) {
- super(message);
+ super(clean(message));
}
/**
* Creates a new HttpException with the specified detail message and cause.
*
- * @param message the exception detail message
- * @param cause the {@code Throwable} that caused this exception, or {@code null}
- * if the cause is unavailable, unknown, or not a {@code Throwable}
+ * @param message
+ * the exception detail message
+ * @param cause
+ * the {@code Throwable} that caused this exception, or
+ * {@code null} if the cause is unavailable, unknown, or not a
+ * {@code Throwable}
*/
public HttpException(final String message, final Throwable cause) {
- super(message);
+ super(clean(message));
initCause(cause);
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpHeaders.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpHeaders.java
index 04a635a3f..dad9a40bb 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpHeaders.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpHeaders.java
@@ -36,6 +36,7 @@ package com.fr.third.org.apache.http;
public final class HttpHeaders {
private HttpHeaders() {
+ // Don't allow instantiation.
}
/** RFC 2616 (HTTP/1.1) Section 14.1 */
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpHost.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpHost.java
index e869e780e..4ceb700fc 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpHost.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpHost.java
@@ -40,7 +40,6 @@ import com.fr.third.org.apache.http.util.LangUtils;
* Holds all of the variables needed to describe an HTTP connection to a host.
* This includes remote host name, port and scheme.
*
- *
* @since 4.0
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE)
@@ -288,9 +287,8 @@ public final class HttpHost implements Cloneable, Serializable {
buffer.append(":");
buffer.append(Integer.toString(this.port));
return buffer.toString();
- } else {
- return this.hostname;
}
+ return this.hostname;
}
@@ -311,13 +309,12 @@ public final class HttpHost implements Cloneable, Serializable {
&& this.port == that.port
&& this.schemeName.equals(that.schemeName)
&& (this.address==null ? that.address== null : this.address.equals(that.address));
- } else {
- return false;
}
+ return false;
}
/**
- * @see java.lang.Object#hashCode()
+ * @see Object#hashCode()
*/
@Override
public int hashCode() {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpMessage.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpMessage.java
index f3b62fc13..c3671c661 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpMessage.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpMessage.java
@@ -191,8 +191,8 @@ public interface HttpMessage {
* Returns the parameters effective for this message as set by
* {@link #setParams(HttpParams)}.
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Deprecated
HttpParams getParams();
@@ -201,8 +201,8 @@ public interface HttpMessage {
* Provides parameters to be used for the processing of this message.
* @param params the parameters
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Deprecated
void setParams(HttpParams params);
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpRequestFactory.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpRequestFactory.java
index 56e24fd12..46833ae3a 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpRequestFactory.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpRequestFactory.java
@@ -38,6 +38,6 @@ public interface HttpRequestFactory {
throws MethodNotSupportedException;
HttpRequest newHttpRequest(String method, String uri)
- throws MethodNotSupportedException;
+ throws MethodNotSupportedException;
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpResponse.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpResponse.java
index 4f27a416b..371f897aa 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpResponse.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpResponse.java
@@ -27,8 +27,6 @@
package com.fr.third.org.apache.http;
-import com.fr.third.org.apache.http.util.EntityUtils;
-
import java.util.Locale;
/**
@@ -133,7 +131,7 @@ public interface HttpResponse extends HttpMessage {
* {@code null} to unset
*
* @see HttpEntity#isStreaming()
- * @see EntityUtils#updateEntity(HttpResponse, HttpEntity)
+ * @see com.fr.third.org.apache.http.util.EntityUtils#updateEntity(HttpResponse, HttpEntity)
*/
void setEntity(HttpEntity entity);
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpStatus.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpStatus.java
index 0f7957a1c..157b15083 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpStatus.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpStatus.java
@@ -33,7 +33,9 @@ package com.fr.third.org.apache.http;
* RFC2518 (WebDAV) are listed.
*
* @see StatusLine
- *
+ * @see RFC1945 (HTTP/1.0)
+ * @see RFC2616 (HTTP/1.1)
+ * @see RFC2518 (WebDAV)
* @since 4.0
*/
public interface HttpStatus {
@@ -41,90 +43,90 @@ public interface HttpStatus {
// --- 1xx Informational ---
/** {@code 100 Continue} (HTTP/1.1 - RFC 2616) */
- public static final int SC_CONTINUE = 100;
+ int SC_CONTINUE = 100;
/** {@code 101 Switching Protocols} (HTTP/1.1 - RFC 2616)*/
- public static final int SC_SWITCHING_PROTOCOLS = 101;
+ int SC_SWITCHING_PROTOCOLS = 101;
/** {@code 102 Processing} (WebDAV - RFC 2518) */
- public static final int SC_PROCESSING = 102;
+ int SC_PROCESSING = 102;
// --- 2xx Success ---
/** {@code 200 OK} (HTTP/1.0 - RFC 1945) */
- public static final int SC_OK = 200;
+ int SC_OK = 200;
/** {@code 201 Created} (HTTP/1.0 - RFC 1945) */
- public static final int SC_CREATED = 201;
+ int SC_CREATED = 201;
/** {@code 202 Accepted} (HTTP/1.0 - RFC 1945) */
- public static final int SC_ACCEPTED = 202;
+ int SC_ACCEPTED = 202;
/** {@code 203 Non Authoritative Information} (HTTP/1.1 - RFC 2616) */
- public static final int SC_NON_AUTHORITATIVE_INFORMATION = 203;
+ int SC_NON_AUTHORITATIVE_INFORMATION = 203;
/** {@code 204 No Content} (HTTP/1.0 - RFC 1945) */
- public static final int SC_NO_CONTENT = 204;
+ int SC_NO_CONTENT = 204;
/** {@code 205 Reset Content} (HTTP/1.1 - RFC 2616) */
- public static final int SC_RESET_CONTENT = 205;
+ int SC_RESET_CONTENT = 205;
/** {@code 206 Partial Content} (HTTP/1.1 - RFC 2616) */
- public static final int SC_PARTIAL_CONTENT = 206;
+ int SC_PARTIAL_CONTENT = 206;
/**
* {@code 207 Multi-Status} (WebDAV - RFC 2518)
* or
* {@code 207 Partial Update OK} (HTTP/1.1 - draft-ietf-http-v11-spec-rev-01?)
*/
- public static final int SC_MULTI_STATUS = 207;
+ int SC_MULTI_STATUS = 207;
// --- 3xx Redirection ---
/** {@code 300 Mutliple Choices} (HTTP/1.1 - RFC 2616) */
- public static final int SC_MULTIPLE_CHOICES = 300;
+ int SC_MULTIPLE_CHOICES = 300;
/** {@code 301 Moved Permanently} (HTTP/1.0 - RFC 1945) */
- public static final int SC_MOVED_PERMANENTLY = 301;
+ int SC_MOVED_PERMANENTLY = 301;
/** {@code 302 Moved Temporarily} (Sometimes {@code Found}) (HTTP/1.0 - RFC 1945) */
- public static final int SC_MOVED_TEMPORARILY = 302;
+ int SC_MOVED_TEMPORARILY = 302;
/** {@code 303 See Other} (HTTP/1.1 - RFC 2616) */
- public static final int SC_SEE_OTHER = 303;
+ int SC_SEE_OTHER = 303;
/** {@code 304 Not Modified} (HTTP/1.0 - RFC 1945) */
- public static final int SC_NOT_MODIFIED = 304;
+ int SC_NOT_MODIFIED = 304;
/** {@code 305 Use Proxy} (HTTP/1.1 - RFC 2616) */
- public static final int SC_USE_PROXY = 305;
+ int SC_USE_PROXY = 305;
/** {@code 307 Temporary Redirect} (HTTP/1.1 - RFC 2616) */
- public static final int SC_TEMPORARY_REDIRECT = 307;
+ int SC_TEMPORARY_REDIRECT = 307;
// --- 4xx Client Error ---
/** {@code 400 Bad Request} (HTTP/1.1 - RFC 2616) */
- public static final int SC_BAD_REQUEST = 400;
+ int SC_BAD_REQUEST = 400;
/** {@code 401 Unauthorized} (HTTP/1.0 - RFC 1945) */
- public static final int SC_UNAUTHORIZED = 401;
+ int SC_UNAUTHORIZED = 401;
/** {@code 402 Payment Required} (HTTP/1.1 - RFC 2616) */
- public static final int SC_PAYMENT_REQUIRED = 402;
+ int SC_PAYMENT_REQUIRED = 402;
/** {@code 403 Forbidden} (HTTP/1.0 - RFC 1945) */
- public static final int SC_FORBIDDEN = 403;
+ int SC_FORBIDDEN = 403;
/** {@code 404 Not Found} (HTTP/1.0 - RFC 1945) */
- public static final int SC_NOT_FOUND = 404;
+ int SC_NOT_FOUND = 404;
/** {@code 405 Method Not Allowed} (HTTP/1.1 - RFC 2616) */
- public static final int SC_METHOD_NOT_ALLOWED = 405;
+ int SC_METHOD_NOT_ALLOWED = 405;
/** {@code 406 Not Acceptable} (HTTP/1.1 - RFC 2616) */
- public static final int SC_NOT_ACCEPTABLE = 406;
+ int SC_NOT_ACCEPTABLE = 406;
/** {@code 407 Proxy Authentication Required} (HTTP/1.1 - RFC 2616)*/
- public static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407;
+ int SC_PROXY_AUTHENTICATION_REQUIRED = 407;
/** {@code 408 Request Timeout} (HTTP/1.1 - RFC 2616) */
- public static final int SC_REQUEST_TIMEOUT = 408;
+ int SC_REQUEST_TIMEOUT = 408;
/** {@code 409 Conflict} (HTTP/1.1 - RFC 2616) */
- public static final int SC_CONFLICT = 409;
+ int SC_CONFLICT = 409;
/** {@code 410 Gone} (HTTP/1.1 - RFC 2616) */
- public static final int SC_GONE = 410;
+ int SC_GONE = 410;
/** {@code 411 Length Required} (HTTP/1.1 - RFC 2616) */
- public static final int SC_LENGTH_REQUIRED = 411;
+ int SC_LENGTH_REQUIRED = 411;
/** {@code 412 Precondition Failed} (HTTP/1.1 - RFC 2616) */
- public static final int SC_PRECONDITION_FAILED = 412;
+ int SC_PRECONDITION_FAILED = 412;
/** {@code 413 Request Entity Too Large} (HTTP/1.1 - RFC 2616) */
- public static final int SC_REQUEST_TOO_LONG = 413;
+ int SC_REQUEST_TOO_LONG = 413;
/** {@code 414 Request-URI Too Long} (HTTP/1.1 - RFC 2616) */
- public static final int SC_REQUEST_URI_TOO_LONG = 414;
+ int SC_REQUEST_URI_TOO_LONG = 414;
/** {@code 415 Unsupported Media Type} (HTTP/1.1 - RFC 2616) */
- public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415;
+ int SC_UNSUPPORTED_MEDIA_TYPE = 415;
/** {@code 416 Requested Range Not Satisfiable} (HTTP/1.1 - RFC 2616) */
- public static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
+ int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
/** {@code 417 Expectation Failed} (HTTP/1.1 - RFC 2616) */
- public static final int SC_EXPECTATION_FAILED = 417;
+ int SC_EXPECTATION_FAILED = 417;
/**
* Static constant for a 418 error.
@@ -141,36 +143,38 @@ public interface HttpStatus {
* or {@code 419 Proxy Reauthentication Required}
* (HTTP/1.1 drafts?)
*/
- public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419;
+ int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419;
/**
* Static constant for a 420 error.
* {@code 420 Method Failure}
* (WebDAV - draft-ietf-webdav-protocol-05?)
*/
- public static final int SC_METHOD_FAILURE = 420;
+ int SC_METHOD_FAILURE = 420;
/** {@code 422 Unprocessable Entity} (WebDAV - RFC 2518) */
- public static final int SC_UNPROCESSABLE_ENTITY = 422;
+ int SC_UNPROCESSABLE_ENTITY = 422;
/** {@code 423 Locked} (WebDAV - RFC 2518) */
- public static final int SC_LOCKED = 423;
+ int SC_LOCKED = 423;
/** {@code 424 Failed Dependency} (WebDAV - RFC 2518) */
- public static final int SC_FAILED_DEPENDENCY = 424;
+ int SC_FAILED_DEPENDENCY = 424;
+ /** {@code 429 Too Many Requests} (Additional HTTP Status Codes - RFC 6585) */
+ int SC_TOO_MANY_REQUESTS = 429;
// --- 5xx Server Error ---
/** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */
- public static final int SC_INTERNAL_SERVER_ERROR = 500;
+ int SC_INTERNAL_SERVER_ERROR = 500;
/** {@code 501 Not Implemented} (HTTP/1.0 - RFC 1945) */
- public static final int SC_NOT_IMPLEMENTED = 501;
+ int SC_NOT_IMPLEMENTED = 501;
/** {@code 502 Bad Gateway} (HTTP/1.0 - RFC 1945) */
- public static final int SC_BAD_GATEWAY = 502;
+ int SC_BAD_GATEWAY = 502;
/** {@code 503 Service Unavailable} (HTTP/1.0 - RFC 1945) */
- public static final int SC_SERVICE_UNAVAILABLE = 503;
+ int SC_SERVICE_UNAVAILABLE = 503;
/** {@code 504 Gateway Timeout} (HTTP/1.1 - RFC 2616) */
- public static final int SC_GATEWAY_TIMEOUT = 504;
+ int SC_GATEWAY_TIMEOUT = 504;
/** {@code 505 HTTP Version Not Supported} (HTTP/1.1 - RFC 2616) */
- public static final int SC_HTTP_VERSION_NOT_SUPPORTED = 505;
+ int SC_HTTP_VERSION_NOT_SUPPORTED = 505;
/** {@code 507 Insufficient Storage} (WebDAV - RFC 2518) */
- public static final int SC_INSUFFICIENT_STORAGE = 507;
+ int SC_INSUFFICIENT_STORAGE = 507;
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpVersion.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpVersion.java
index aa3b9c0d5..a409d4064 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpVersion.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/HttpVersion.java
@@ -27,10 +27,8 @@
package com.fr.third.org.apache.http;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
-
-import java.io.Serializable;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
/**
* Represents an HTTP version. HTTP uses a "major.minor" numbering
@@ -46,7 +44,7 @@ import java.io.Serializable;
* @since 4.0
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE)
-public final class HttpVersion extends ProtocolVersion implements Serializable {
+public final class HttpVersion extends ProtocolVersion {
private static final long serialVersionUID = -5856653513894415344L;
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/NameValuePair.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/NameValuePair.java
index efd7b382a..e087d8328 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/NameValuePair.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/NameValuePair.java
@@ -28,20 +28,30 @@
package com.fr.third.org.apache.http;
/**
- * A name / value pair parameter used as an element of HTTP messages.
+ * A name-value pair parameter used as an element of HTTP messages.
+ *
*
* parameter = attribute "=" value
* attribute = token
* value = token | quoted-string
*
*
- *
* @since 4.0
*/
public interface NameValuePair {
+ /**
+ * Gets the name of this pair.
+ *
+ * @return the name of this pair, never {@code null}.
+ */
String getName();
+ /**
+ * Gets the value of this pair.
+ *
+ * @return the value of this pair, may be {@code null}.
+ */
String getValue();
-}
+}
\ No newline at end of file
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/NoHttpResponseException.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/NoHttpResponseException.java
index 77b5765ff..0da1645cb 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/NoHttpResponseException.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/NoHttpResponseException.java
@@ -44,7 +44,7 @@ public class NoHttpResponseException extends IOException {
* @param message exception message
*/
public NoHttpResponseException(final String message) {
- super(message);
+ super(HttpException.clean(message));
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ProtocolVersion.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ProtocolVersion.java
index fb66a7f3c..607c94e93 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ProtocolVersion.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ProtocolVersion.java
@@ -70,7 +70,7 @@ public class ProtocolVersion implements Serializable, Cloneable {
*/
public ProtocolVersion(final String protocol, final int major, final int minor) {
this.protocol = Args.notNull(protocol, "Protocol name");
- this.major = Args.notNegative(major, "Protocol minor version");
+ this.major = Args.notNegative(major, "Protocol major version");
this.minor = Args.notNegative(minor, "Protocol minor version");
}
@@ -188,7 +188,7 @@ public class ProtocolVersion implements Serializable, Cloneable {
* Compares this protocol version with another one.
* Only protocol versions with the same protocol name can be compared.
* This method does not define a total ordering, as it would be
- * required for {@link java.lang.Comparable}.
+ * required for {@link Comparable}.
*
* @param that the protocol version to compare with
*
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/TruncatedChunkException.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/TruncatedChunkException.java
index 50d94d82a..71db142f9 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/TruncatedChunkException.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/TruncatedChunkException.java
@@ -45,4 +45,16 @@ public class TruncatedChunkException extends MalformedChunkCodingException {
super(message);
}
+ /**
+ * Constructs a new TruncatedChunkException with the specified detail message.
+ *
+ * @param format The exception detail message format; see {@link String#format(String, Object...)}.
+ * @param args The exception detail message arguments; see {@link String#format(String, Object...)}.
+ *
+ * @since 4.4.11
+ */
+ public TruncatedChunkException(final String format, final Object... args) {
+ super(HttpException.clean(String.format(format, args)));
+ }
+
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/concurrent/BasicFuture.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/concurrent/BasicFuture.java
index de1fea069..b23e9ff63 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/concurrent/BasicFuture.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/concurrent/BasicFuture.java
@@ -28,6 +28,7 @@ package com.fr.third.org.apache.http.concurrent;
import com.fr.third.org.apache.http.util.Args;
+import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -69,6 +70,9 @@ public class BasicFuture implements Future, Cancellable {
if (this.ex != null) {
throw new ExecutionException(this.ex);
}
+ if (cancelled) {
+ throw new CancellationException();
+ }
return this.result;
}
@@ -96,11 +100,10 @@ public class BasicFuture implements Future, Cancellable {
wait(waitTime);
if (this.completed) {
return getResult();
- } else {
- waitTime = msecs - (System.currentTimeMillis() - startTime);
- if (waitTime <= 0) {
- throw new TimeoutException();
- }
+ }
+ waitTime = msecs - (System.currentTimeMillis() - startTime);
+ if (waitTime <= 0) {
+ throw new TimeoutException();
}
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/concurrent/Cancellable.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/concurrent/Cancellable.java
index a7d860e80..e680d3e43 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/concurrent/Cancellable.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/concurrent/Cancellable.java
@@ -34,6 +34,12 @@ package com.fr.third.org.apache.http.concurrent;
*/
public interface Cancellable {
+ /**
+ * Cancels the ongoing operation or process.
+ *
+ * @return {@code true} if the operation or process has been cancelled as a result of
+ * this method call or {@code false} if it has already been cancelled or not started.
+ */
boolean cancel();
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/config/ConnectionConfig.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/config/ConnectionConfig.java
index f11b31f56..a0bd939db 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/config/ConnectionConfig.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/config/ConnectionConfig.java
@@ -110,11 +110,11 @@ public class ConnectionConfig implements Cloneable {
return builder.toString();
}
- public static ConnectionConfig.Builder custom() {
+ public static Builder custom() {
return new Builder();
}
- public static ConnectionConfig.Builder copy(final ConnectionConfig config) {
+ public static Builder copy(final ConnectionConfig config) {
Args.notNull(config, "Connection config");
return new Builder()
.setBufferSize(config.getBufferSize())
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/config/MessageConstraints.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/config/MessageConstraints.java
index 7119ac026..0ee063dd6 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/config/MessageConstraints.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/config/MessageConstraints.java
@@ -78,11 +78,11 @@ public class MessageConstraints implements Cloneable {
return new MessageConstraints(Args.notNegative(max, "Max line length"), -1);
}
- public static MessageConstraints.Builder custom() {
+ public static Builder custom() {
return new Builder();
}
- public static MessageConstraints.Builder copy(final MessageConstraints config) {
+ public static Builder copy(final MessageConstraints config) {
Args.notNull(config, "Message constraints");
return new Builder()
.setMaxHeaderCount(config.getMaxHeaderCount())
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/config/SocketConfig.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/config/SocketConfig.java
index 7e9b68664..610f2a9ba 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/config/SocketConfig.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/config/SocketConfig.java
@@ -115,7 +115,7 @@ public class SocketConfig implements Cloneable {
* Determines the default value of the {@link java.net.SocketOptions#SO_KEEPALIVE} parameter
* for newly created sockets.
*
*
* @return the default value of the {@link java.net.SocketOptions#SO_KEEPALIVE} parameter.
@@ -129,7 +129,7 @@ public class SocketConfig implements Cloneable {
* Determines the default value of the {@link java.net.SocketOptions#TCP_NODELAY} parameter
* for newly created sockets.
*
*
* @return the default value of the {@link java.net.SocketOptions#TCP_NODELAY} parameter.
@@ -202,11 +202,11 @@ public class SocketConfig implements Cloneable {
return builder.toString();
}
- public static SocketConfig.Builder custom() {
+ public static Builder custom() {
return new Builder();
}
- public static SocketConfig.Builder copy(final SocketConfig config) {
+ public static Builder copy(final SocketConfig config) {
Args.notNull(config, "Socket config");
return new Builder()
.setSoTimeout(config.getSoTimeout())
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/BasicHttpEntity.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/BasicHttpEntity.java
index 58995bf08..30d3ae067 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/BasicHttpEntity.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/BasicHttpEntity.java
@@ -99,25 +99,25 @@ public class BasicHttpEntity extends AbstractHttpEntity {
/**
* Specifies the content.
*
- * @param instream the stream to return with the next call to
+ * @param inStream the stream to return with the next call to
* {@link #getContent getContent}
*/
- public void setContent(final InputStream instream) {
- this.content = instream;
+ public void setContent(final InputStream inStream) {
+ this.content = inStream;
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = getContent();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = getContent();
try {
int l;
final byte[] tmp = new byte[OUTPUT_BUFFER_SIZE];
- while ((l = instream.read(tmp)) != -1) {
- outstream.write(tmp, 0, l);
+ while ((l = inStream.read(tmp)) != -1) {
+ outStream.write(tmp, 0, l);
}
} finally {
- instream.close();
+ inStream.close();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/BufferedHttpEntity.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/BufferedHttpEntity.java
index 3b853e9f5..4397a1ff0 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/BufferedHttpEntity.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/BufferedHttpEntity.java
@@ -69,20 +69,12 @@ public class BufferedHttpEntity extends HttpEntityWrapper {
@Override
public long getContentLength() {
- if (this.buffer != null) {
- return this.buffer.length;
- } else {
- return super.getContentLength();
- }
+ return this.buffer != null ? this.buffer.length : super.getContentLength();
}
@Override
public InputStream getContent() throws IOException {
- if (this.buffer != null) {
- return new ByteArrayInputStream(this.buffer);
- } else {
- return super.getContent();
- }
+ return this.buffer != null ? new ByteArrayInputStream(this.buffer) : super.getContent();
}
/**
@@ -107,12 +99,12 @@ public class BufferedHttpEntity extends HttpEntityWrapper {
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
if (this.buffer != null) {
- outstream.write(this.buffer);
+ outStream.write(this.buffer);
} else {
- super.writeTo(outstream);
+ super.writeTo(outStream);
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ByteArrayEntity.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ByteArrayEntity.java
index c3b9cc991..322205618 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ByteArrayEntity.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ByteArrayEntity.java
@@ -52,7 +52,6 @@ public class ByteArrayEntity extends AbstractHttpEntity implements Cloneable {
/**
* @since 4.2
*/
- @SuppressWarnings("deprecation")
public ByteArrayEntity(final byte[] b, final ContentType contentType) {
super();
Args.notNull(b, "Source byte array");
@@ -68,7 +67,6 @@ public class ByteArrayEntity extends AbstractHttpEntity implements Cloneable {
/**
* @since 4.2
*/
- @SuppressWarnings("deprecation")
public ByteArrayEntity(final byte[] b, final int off, final int len, final ContentType contentType) {
super();
Args.notNull(b, "Source byte array");
@@ -109,10 +107,10 @@ public class ByteArrayEntity extends AbstractHttpEntity implements Cloneable {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- outstream.write(this.b, this.off, this.len);
- outstream.flush();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ outStream.write(this.b, this.off, this.len);
+ outStream.flush();
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ContentLengthStrategy.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ContentLengthStrategy.java
index 1908351b4..f511f1321 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ContentLengthStrategy.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ContentLengthStrategy.java
@@ -38,8 +38,8 @@ import com.fr.third.org.apache.http.HttpMessage;
*/
public interface ContentLengthStrategy {
- public static final int IDENTITY = -1;
- public static final int CHUNKED = -2;
+ int IDENTITY = -1;
+ int CHUNKED = -2;
/**
* Returns length of the given message in bytes. The returned value
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ContentProducer.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ContentProducer.java
index fe0a38425..90872bcc3 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ContentProducer.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ContentProducer.java
@@ -39,6 +39,6 @@ import java.io.OutputStream;
*/
public interface ContentProducer {
- void writeTo(OutputStream outstream) throws IOException;
+ void writeTo(OutputStream outStream) throws IOException;
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ContentType.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ContentType.java
index 595a9c1d4..976168ff1 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ContentType.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/ContentType.java
@@ -77,12 +77,28 @@ public final class ContentType implements Serializable {
"application/json", Consts.UTF_8);
public static final ContentType APPLICATION_OCTET_STREAM = create(
"application/octet-stream", (Charset) null);
+ public static final ContentType APPLICATION_SOAP_XML = create(
+ "application/soap+xml", Consts.UTF_8);
public static final ContentType APPLICATION_SVG_XML = create(
"application/svg+xml", Consts.ISO_8859_1);
public static final ContentType APPLICATION_XHTML_XML = create(
"application/xhtml+xml", Consts.ISO_8859_1);
public static final ContentType APPLICATION_XML = create(
"application/xml", Consts.ISO_8859_1);
+ public static final ContentType IMAGE_BMP = create(
+ "image/bmp");
+ public static final ContentType IMAGE_GIF= create(
+ "image/gif");
+ public static final ContentType IMAGE_JPEG = create(
+ "image/jpeg");
+ public static final ContentType IMAGE_PNG = create(
+ "image/png");
+ public static final ContentType IMAGE_SVG= create(
+ "image/svg+xml");
+ public static final ContentType IMAGE_TIFF = create(
+ "image/tiff");
+ public static final ContentType IMAGE_WEBP = create(
+ "image/webp");
public static final ContentType MULTIPART_FORM_DATA = create(
"multipart/form-data", Consts.ISO_8859_1);
public static final ContentType TEXT_HTML = create(
@@ -105,12 +121,19 @@ public final class ContentType implements Serializable {
APPLICATION_SVG_XML,
APPLICATION_XHTML_XML,
APPLICATION_XML,
+ IMAGE_BMP,
+ IMAGE_GIF,
+ IMAGE_JPEG,
+ IMAGE_PNG,
+ IMAGE_SVG,
+ IMAGE_TIFF,
+ IMAGE_WEBP,
MULTIPART_FORM_DATA,
TEXT_HTML,
TEXT_PLAIN,
TEXT_XML };
final HashMap map = new HashMap();
- for (ContentType contentType: contentTypes) {
+ for (final ContentType contentType: contentTypes) {
map.put(contentType.getMimeType(), contentType);
}
CONTENT_TYPE_MAP = Collections.unmodifiableMap(map);
@@ -294,9 +317,8 @@ public final class ContentType implements Serializable {
final HeaderElement[] elements = BasicHeaderValueParser.INSTANCE.parseElements(buf, cursor);
if (elements.length > 0) {
return create(elements[0], true);
- } else {
- throw new ParseException("Invalid content type: " + s);
}
+ throw new ParseException("Invalid content type: " + s);
}
/**
@@ -348,7 +370,7 @@ public final class ContentType implements Serializable {
return create(elements[0], false);
}
} catch (final ParseException ex) {
- return null;
+ // ignore
}
}
return null;
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/EntityTemplate.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/EntityTemplate.java
index ac65f05e5..b68795a08 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/EntityTemplate.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/EntityTemplate.java
@@ -68,9 +68,9 @@ public class EntityTemplate extends AbstractHttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- this.contentproducer.writeTo(outstream);
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ this.contentproducer.writeTo(outStream);
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/FileEntity.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/FileEntity.java
index b411e4f1b..addadbba9 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/FileEntity.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/FileEntity.java
@@ -45,6 +45,11 @@ public class FileEntity extends AbstractHttpEntity implements Cloneable {
protected final File file;
/**
+ * Creates a new instance.
+ *
+ * @param file The file to serve.
+ * @param contentType The content type for the given {@code file}.
+ *
* @deprecated (4.1.3) {@link #FileEntity(File, ContentType)}
*/
@Deprecated
@@ -55,6 +60,11 @@ public class FileEntity extends AbstractHttpEntity implements Cloneable {
}
/**
+ * Creates a new instance.
+ *
+ * @param file The file to serve.
+ * @param contentType The content type for the given {@code file}.
+ *
* @since 4.2
*/
public FileEntity(final File file, final ContentType contentType) {
@@ -66,6 +76,10 @@ public class FileEntity extends AbstractHttpEntity implements Cloneable {
}
/**
+ * Creates a new instance.
+ *
+ * @param file The file to serve.
+ *
* @since 4.2
*/
public FileEntity(final File file) {
@@ -89,18 +103,18 @@ public class FileEntity extends AbstractHttpEntity implements Cloneable {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = new FileInputStream(this.file);
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = new FileInputStream(this.file);
try {
final byte[] tmp = new byte[OUTPUT_BUFFER_SIZE];
int l;
- while ((l = instream.read(tmp)) != -1) {
- outstream.write(tmp, 0, l);
+ while ((l = inStream.read(tmp)) != -1) {
+ outStream.write(tmp, 0, l);
}
- outstream.flush();
+ outStream.flush();
} finally {
- instream.close();
+ inStream.close();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/HttpEntityWrapper.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/HttpEntityWrapper.java
index 2247ded81..2ba83e665 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/HttpEntityWrapper.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/HttpEntityWrapper.java
@@ -51,11 +51,13 @@ public class HttpEntityWrapper implements HttpEntity {
/**
* Creates a new entity wrapper.
+ *
+ * @param wrappedEntity the entity to wrap.
*/
public HttpEntityWrapper(final HttpEntity wrappedEntity) {
super();
this.wrappedEntity = Args.notNull(wrappedEntity, "Wrapped entity");
- } // constructor
+ }
@Override
public boolean isRepeatable() {
@@ -89,9 +91,9 @@ public class HttpEntityWrapper implements HttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream)
+ public void writeTo(final OutputStream outStream)
throws IOException {
- wrappedEntity.writeTo(outstream);
+ wrappedEntity.writeTo(outStream);
}
@Override
@@ -100,7 +102,7 @@ public class HttpEntityWrapper implements HttpEntity {
}
/**
- * @deprecated (4.1) Either use {@link #getContent()} and call {@link java.io.InputStream#close()} on that;
+ * @deprecated (4.1) Either use {@link #getContent()} and call {@link InputStream#close()} on that;
* otherwise call {@link #writeTo(OutputStream)} which is required to free the resources.
*/
@Override
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/InputStreamEntity.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/InputStreamEntity.java
index e63737ef2..84f44deba 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/InputStreamEntity.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/InputStreamEntity.java
@@ -46,50 +46,50 @@ public class InputStreamEntity extends AbstractHttpEntity {
/**
* Creates an entity with an unknown length.
- * Equivalent to {@code new InputStreamEntity(instream, -1)}.
+ * Equivalent to {@code new InputStreamEntity(inStream, -1)}.
*
- * @param instream input stream
- * @throws IllegalArgumentException if {@code instream} is {@code null}
+ * @param inStream input stream
+ * @throws IllegalArgumentException if {@code inStream} is {@code null}
* @since 4.3
*/
- public InputStreamEntity(final InputStream instream) {
- this(instream, -1);
+ public InputStreamEntity(final InputStream inStream) {
+ this(inStream, -1);
}
/**
* Creates an entity with a specified content length.
*
- * @param instream input stream
+ * @param inStream input stream
* @param length of the input stream, {@code -1} if unknown
- * @throws IllegalArgumentException if {@code instream} is {@code null}
+ * @throws IllegalArgumentException if {@code inStream} is {@code null}
*/
- public InputStreamEntity(final InputStream instream, final long length) {
- this(instream, length, null);
+ public InputStreamEntity(final InputStream inStream, final long length) {
+ this(inStream, length, null);
}
/**
* Creates an entity with a content type and unknown length.
- * Equivalent to {@code new InputStreamEntity(instream, -1, contentType)}.
+ * Equivalent to {@code new InputStreamEntity(inStream, -1, contentType)}.
*
- * @param instream input stream
+ * @param inStream input stream
* @param contentType content type
- * @throws IllegalArgumentException if {@code instream} is {@code null}
+ * @throws IllegalArgumentException if {@code inStream} is {@code null}
* @since 4.3
*/
- public InputStreamEntity(final InputStream instream, final ContentType contentType) {
- this(instream, -1, contentType);
+ public InputStreamEntity(final InputStream inStream, final ContentType contentType) {
+ this(inStream, -1, contentType);
}
/**
- * @param instream input stream
+ * @param inStream input stream
* @param length of the input stream, {@code -1} if unknown
* @param contentType for specifying the {@code Content-Type} header, may be {@code null}
- * @throws IllegalArgumentException if {@code instream} is {@code null}
+ * @throws IllegalArgumentException if {@code inStream} is {@code null}
* @since 4.2
*/
- public InputStreamEntity(final InputStream instream, final long length, final ContentType contentType) {
+ public InputStreamEntity(final InputStream inStream, final long length, final ContentType contentType) {
super();
- this.content = Args.notNull(instream, "Source input stream");
+ this.content = Args.notNull(inStream, "Source input stream");
this.length = length;
if (contentType != null) {
setContentType(contentType.toString());
@@ -122,31 +122,31 @@ public class InputStreamEntity extends AbstractHttpEntity {
*
*/
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = this.content;
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ final InputStream inStream = this.content;
try {
final byte[] buffer = new byte[OUTPUT_BUFFER_SIZE];
- int l;
+ int readLen;
if (this.length < 0) {
// consume until EOF
- while ((l = instream.read(buffer)) != -1) {
- outstream.write(buffer, 0, l);
+ while ((readLen = inStream.read(buffer)) != -1) {
+ outStream.write(buffer, 0, readLen);
}
} else {
// consume no more than length
long remaining = this.length;
while (remaining > 0) {
- l = instream.read(buffer, 0, (int)Math.min(OUTPUT_BUFFER_SIZE, remaining));
- if (l == -1) {
+ readLen = inStream.read(buffer, 0, (int)Math.min(OUTPUT_BUFFER_SIZE, remaining));
+ if (readLen == -1) {
break;
}
- outstream.write(buffer, 0, l);
- remaining -= l;
+ outStream.write(buffer, 0, readLen);
+ remaining -= readLen;
}
}
} finally {
- instream.close();
+ inStream.close();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/SerializableEntity.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/SerializableEntity.java
index b1cfb95f8..774d80490 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/SerializableEntity.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/SerializableEntity.java
@@ -70,12 +70,16 @@ public class SerializableEntity extends AbstractHttpEntity {
}
/**
+ * Creates new instance of this class.
+ *
+ * @param serializable The object to serialize.
+ *
* @since 4.3
*/
- public SerializableEntity(final Serializable ser) {
+ public SerializableEntity(final Serializable serializable) {
super();
- Args.notNull(ser, "Source object");
- this.objRef = ser;
+ Args.notNull(serializable, "Source object");
+ this.objRef = serializable;
}
private void createBytes(final Serializable ser) throws IOException {
@@ -96,11 +100,7 @@ public class SerializableEntity extends AbstractHttpEntity {
@Override
public long getContentLength() {
- if (this.objSer == null) {
- return -1;
- } else {
- return this.objSer.length;
- }
+ return this.objSer == null ? -1 : this.objSer.length;
}
@Override
@@ -114,15 +114,15 @@ public class SerializableEntity extends AbstractHttpEntity {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
if (this.objSer == null) {
- final ObjectOutputStream out = new ObjectOutputStream(outstream);
+ final ObjectOutputStream out = new ObjectOutputStream(outStream);
out.writeObject(this.objRef);
out.flush();
} else {
- outstream.write(this.objSer);
- outstream.flush();
+ outStream.write(this.objSer);
+ outStream.flush();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/StringEntity.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/StringEntity.java
index a57f54f76..8556e43b2 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/StringEntity.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/entity/StringEntity.java
@@ -162,10 +162,10 @@ public class StringEntity extends AbstractHttpEntity implements Cloneable {
}
@Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- outstream.write(this.content);
- outstream.flush();
+ public void writeTo(final OutputStream outStream) throws IOException {
+ Args.notNull(outStream, "Output stream");
+ outStream.write(this.content);
+ outStream.flush();
}
/**
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/BHttpConnectionBase.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/BHttpConnectionBase.java
index fe972ec73..b9633ea51 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/BHttpConnectionBase.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/BHttpConnectionBase.java
@@ -41,7 +41,6 @@ import java.util.concurrent.atomic.AtomicReference;
import com.fr.third.org.apache.http.ConnectionClosedException;
import com.fr.third.org.apache.http.Header;
-import com.fr.third.org.apache.http.HttpConnection;
import com.fr.third.org.apache.http.HttpConnectionMetrics;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpException;
@@ -69,14 +68,14 @@ import com.fr.third.org.apache.http.util.Args;
import com.fr.third.org.apache.http.util.NetUtils;
/**
- * This class serves as a base for all {@link HttpConnection} implementations and provides
- * functionality common to both client and server HTTP connections.
+ * This class serves as a base for all {@link com.fr.third.org.apache.http.HttpConnection} implementations
+ * and provides functionality common to both client and server HTTP connections.
*
* @since 4.0
*/
-public class BHttpConnectionBase implements HttpConnection, HttpInetConnection {
+public class BHttpConnectionBase implements HttpInetConnection {
- private final SessionInputBufferImpl inbuffer;
+ private final SessionInputBufferImpl inBuffer;
private final SessionOutputBufferImpl outbuffer;
private final MessageConstraints messageConstraints;
private final HttpConnectionMetricsImpl connMetrics;
@@ -87,11 +86,11 @@ public class BHttpConnectionBase implements HttpConnection, HttpInetConnection {
/**
* Creates new instance of BHttpConnectionBase.
*
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param messageConstraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
@@ -101,21 +100,21 @@ public class BHttpConnectionBase implements HttpConnection, HttpInetConnection {
* {@link StrictContentLengthStrategy#INSTANCE} will be used.
*/
protected BHttpConnectionBase(
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints messageConstraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy) {
super();
- Args.positive(buffersize, "Buffer size");
+ Args.positive(bufferSize, "Buffer size");
final HttpTransportMetricsImpl inTransportMetrics = new HttpTransportMetricsImpl();
final HttpTransportMetricsImpl outTransportMetrics = new HttpTransportMetricsImpl();
- this.inbuffer = new SessionInputBufferImpl(inTransportMetrics, buffersize, -1,
- messageConstraints != null ? messageConstraints : MessageConstraints.DEFAULT, chardecoder);
- this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, buffersize, fragmentSizeHint,
- charencoder);
+ this.inBuffer = new SessionInputBufferImpl(inTransportMetrics, bufferSize, -1,
+ messageConstraints != null ? messageConstraints : MessageConstraints.DEFAULT, charDecoder);
+ this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, bufferSize, fragmentSizeHint,
+ charEncoder);
this.messageConstraints = messageConstraints;
this.connMetrics = new HttpConnectionMetricsImpl(inTransportMetrics, outTransportMetrics);
this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy :
@@ -128,10 +127,10 @@ public class BHttpConnectionBase implements HttpConnection, HttpInetConnection {
protected void ensureOpen() throws IOException {
final Socket socket = this.socketHolder.get();
if (socket == null) {
- throw new ConnectionClosedException("Connection is closed");
+ throw new ConnectionClosedException();
}
- if (!this.inbuffer.isBound()) {
- this.inbuffer.bind(getSocketInputStream(socket));
+ if (!this.inBuffer.isBound()) {
+ this.inBuffer.bind(getSocketInputStream(socket));
}
if (!this.outbuffer.isBound()) {
this.outbuffer.bind(getSocketOutputStream(socket));
@@ -159,12 +158,12 @@ public class BHttpConnectionBase implements HttpConnection, HttpInetConnection {
protected void bind(final Socket socket) throws IOException {
Args.notNull(socket, "Socket");
this.socketHolder.set(socket);
- this.inbuffer.bind(null);
+ this.inBuffer.bind(null);
this.outbuffer.bind(null);
}
protected SessionInputBuffer getSessionInputBuffer() {
- return this.inbuffer;
+ return this.inBuffer;
}
protected SessionOutputBuffer getSessionOutputBuffer() {
@@ -203,15 +202,15 @@ public class BHttpConnectionBase implements HttpConnection, HttpInetConnection {
protected InputStream createInputStream(
final long len,
- final SessionInputBuffer inbuffer) {
+ final SessionInputBuffer inBuffer) {
if (len == ContentLengthStrategy.CHUNKED) {
- return new ChunkedInputStream(inbuffer, this.messageConstraints);
+ return new ChunkedInputStream(inBuffer, this.messageConstraints);
} else if (len == ContentLengthStrategy.IDENTITY) {
- return new IdentityInputStream(inbuffer);
+ return new IdentityInputStream(inBuffer);
} else if (len == 0L) {
return EmptyInputStream.INSTANCE;
} else {
- return new ContentLengthInputStream(inbuffer, len);
+ return new ContentLengthInputStream(inBuffer, len);
}
}
@@ -219,19 +218,19 @@ public class BHttpConnectionBase implements HttpConnection, HttpInetConnection {
final BasicHttpEntity entity = new BasicHttpEntity();
final long len = this.incomingContentStrategy.determineLength(message);
- final InputStream instream = createInputStream(len, this.inbuffer);
+ final InputStream inStream = createInputStream(len, this.inBuffer);
if (len == ContentLengthStrategy.CHUNKED) {
entity.setChunked(true);
entity.setContentLength(-1);
- entity.setContent(instream);
+ entity.setContent(inStream);
} else if (len == ContentLengthStrategy.IDENTITY) {
entity.setChunked(false);
entity.setContentLength(-1);
- entity.setContent(instream);
+ entity.setContent(inStream);
} else {
entity.setChunked(false);
entity.setContentLength(len);
- entity.setContent(instream);
+ entity.setContent(inStream);
}
final Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
@@ -290,11 +289,10 @@ public class BHttpConnectionBase implements HttpConnection, HttpInetConnection {
try {
return socket.getSoTimeout();
} catch (final SocketException ignore) {
- return -1;
+ // ignore
}
- } else {
- return -1;
}
+ return -1;
}
@Override
@@ -316,20 +314,8 @@ public class BHttpConnectionBase implements HttpConnection, HttpInetConnection {
final Socket socket = this.socketHolder.getAndSet(null);
if (socket != null) {
try {
- this.inbuffer.clear();
+ this.inBuffer.clear();
this.outbuffer.flush();
- try {
- try {
- socket.shutdownOutput();
- } catch (final IOException ignore) {
- }
- try {
- socket.shutdownInput();
- } catch (final IOException ignore) {
- }
- } catch (final UnsupportedOperationException ignore) {
- // if one isn't supported, the other one isn't either
- }
} finally {
socket.close();
}
@@ -341,18 +327,18 @@ public class BHttpConnectionBase implements HttpConnection, HttpInetConnection {
final int oldtimeout = socket.getSoTimeout();
try {
socket.setSoTimeout(timeout);
- return this.inbuffer.fillBuffer();
+ return this.inBuffer.fillBuffer();
} finally {
socket.setSoTimeout(oldtimeout);
}
}
protected boolean awaitInput(final int timeout) throws IOException {
- if (this.inbuffer.hasBufferedData()) {
+ if (this.inBuffer.hasBufferedData()) {
return true;
}
fillInputBuffer(timeout);
- return this.inbuffer.hasBufferedData();
+ return this.inBuffer.hasBufferedData();
}
@Override
@@ -396,9 +382,8 @@ public class BHttpConnectionBase implements HttpConnection, HttpInetConnection {
NetUtils.formatAddress(buffer, remoteAddress);
}
return buffer.toString();
- } else {
- return "[Not bound]";
}
+ return "[Not bound]";
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/ConnSupport.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/ConnSupport.java
index 79c3f3e44..8c0f25b29 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/ConnSupport.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/ConnSupport.java
@@ -51,9 +51,8 @@ public final class ConnSupport {
return charset.newDecoder()
.onMalformedInput(malformed != null ? malformed : CodingErrorAction.REPORT)
.onUnmappableCharacter(unmappable != null ? unmappable: CodingErrorAction.REPORT);
- } else {
- return null;
}
+ return null;
}
public static CharsetEncoder createEncoder(final ConnectionConfig cconfig) {
@@ -67,9 +66,8 @@ public final class ConnSupport {
return charset.newEncoder()
.onMalformedInput(malformed != null ? malformed : CodingErrorAction.REPORT)
.onUnmappableCharacter(unmappable != null ? unmappable: CodingErrorAction.REPORT);
- } else {
- return null;
}
+ return null;
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpClientConnection.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpClientConnection.java
index 899fccedc..5e5b2d167 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpClientConnection.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpClientConnection.java
@@ -34,8 +34,6 @@ import java.net.SocketTimeoutException;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
-import com.fr.third.org.apache.http.impl.entity.LaxContentLengthStrategy;
-import com.fr.third.org.apache.http.impl.entity.StrictContentLengthStrategy;
import com.fr.third.org.apache.http.HttpClientConnection;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpEntityEnclosingRequest;
@@ -67,34 +65,34 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
/**
* Creates new instance of DefaultBHttpClientConnection.
*
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
* @param incomingContentStrategy incoming content length strategy. If {@code null}
- * {@link LaxContentLengthStrategy#INSTANCE} will be used.
+ * {@link com.fr.third.org.apache.http.impl.entity.LaxContentLengthStrategy#INSTANCE} will be used.
* @param outgoingContentStrategy outgoing content length strategy. If {@code null}
- * {@link StrictContentLengthStrategy#INSTANCE} will be used.
+ * {@link com.fr.third.org.apache.http.impl.entity.StrictContentLengthStrategy#INSTANCE} will be used.
* @param requestWriterFactory request writer factory. If {@code null}
* {@link DefaultHttpRequestWriterFactory#INSTANCE} will be used.
* @param responseParserFactory response parser factory. If {@code null}
* {@link DefaultHttpResponseParserFactory#INSTANCE} will be used.
*/
public DefaultBHttpClientConnection(
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageWriterFactory requestWriterFactory,
final HttpMessageParserFactory responseParserFactory) {
- super(buffersize, fragmentSizeHint, chardecoder, charencoder,
+ super(bufferSize, fragmentSizeHint, charDecoder, charEncoder,
constraints, incomingContentStrategy, outgoingContentStrategy);
this.requestWriter = (requestWriterFactory != null ? requestWriterFactory :
DefaultHttpRequestWriterFactory.INSTANCE).create(getSessionOutputBuffer());
@@ -103,15 +101,15 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
}
public DefaultBHttpClientConnection(
- final int buffersize,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final int bufferSize,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints) {
- this(buffersize, buffersize, chardecoder, charencoder, constraints, null, null, null, null);
+ this(bufferSize, bufferSize, charDecoder, charEncoder, constraints, null, null, null, null);
}
- public DefaultBHttpClientConnection(final int buffersize) {
- this(buffersize, buffersize, null, null, null, null, null, null, null);
+ public DefaultBHttpClientConnection(final int bufferSize) {
+ this(bufferSize, bufferSize, null, null, null, null, null, null, null);
}
protected void onResponseReceived(final HttpResponse response) {
@@ -154,9 +152,9 @@ public class DefaultBHttpClientConnection extends BHttpConnectionBase
if (entity == null) {
return;
}
- final OutputStream outstream = prepareOutput(request);
- entity.writeTo(outstream);
- outstream.close();
+ final OutputStream outStream = prepareOutput(request);
+ entity.writeTo(outStream);
+ outStream.close();
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpClientConnectionFactory.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpClientConnectionFactory.java
index 94c5d5fe1..050692a2e 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpClientConnectionFactory.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpClientConnectionFactory.java
@@ -27,7 +27,6 @@
package com.fr.third.org.apache.http.impl;
-import com.fr.third.org.apache.http.HttpClientConnection;
import com.fr.third.org.apache.http.HttpConnectionFactory;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
@@ -42,7 +41,7 @@ import java.io.IOException;
import java.net.Socket;
/**
- * Default factory for {@link HttpClientConnection}s.
+ * Default factory for {@link com.fr.third.org.apache.http.HttpClientConnection}s.
*
* @since 4.3
*/
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpServerConnection.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpServerConnection.java
index 474546757..1ab11cb89 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpServerConnection.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpServerConnection.java
@@ -33,7 +33,6 @@ import java.net.Socket;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
-import com.fr.third.org.apache.http.impl.entity.StrictContentLengthStrategy;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpEntityEnclosingRequest;
import com.fr.third.org.apache.http.HttpException;
@@ -64,34 +63,34 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
/**
* Creates new instance of DefaultBHttpServerConnection.
*
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragmentSizeHint fragment size hint.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
+ * @param charDecoder decoder to be used for decoding HTTP protocol elements.
* If {@code null} simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder encoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
* @param constraints Message constraints. If {@code null}
* {@link MessageConstraints#DEFAULT} will be used.
* @param incomingContentStrategy incoming content length strategy. If {@code null}
* {@link DisallowIdentityContentLengthStrategy#INSTANCE} will be used.
* @param outgoingContentStrategy outgoing content length strategy. If {@code null}
- * {@link StrictContentLengthStrategy#INSTANCE} will be used.
+ * {@link com.fr.third.org.apache.http.impl.entity.StrictContentLengthStrategy#INSTANCE} will be used.
* @param requestParserFactory request parser factory. If {@code null}
* {@link DefaultHttpRequestParserFactory#INSTANCE} will be used.
* @param responseWriterFactory response writer factory. If {@code null}
* {@link DefaultHttpResponseWriterFactory#INSTANCE} will be used.
*/
public DefaultBHttpServerConnection(
- final int buffersize,
+ final int bufferSize,
final int fragmentSizeHint,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final HttpMessageParserFactory requestParserFactory,
final HttpMessageWriterFactory responseWriterFactory) {
- super(buffersize, fragmentSizeHint, chardecoder, charencoder, constraints,
+ super(bufferSize, fragmentSizeHint, charDecoder, charEncoder, constraints,
incomingContentStrategy != null ? incomingContentStrategy :
DisallowIdentityContentLengthStrategy.INSTANCE, outgoingContentStrategy);
this.requestParser = (requestParserFactory != null ? requestParserFactory :
@@ -101,15 +100,15 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
}
public DefaultBHttpServerConnection(
- final int buffersize,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
+ final int bufferSize,
+ final CharsetDecoder charDecoder,
+ final CharsetEncoder charEncoder,
final MessageConstraints constraints) {
- this(buffersize, buffersize, chardecoder, charencoder, constraints, null, null, null, null);
+ this(bufferSize, bufferSize, charDecoder, charEncoder, constraints, null, null, null, null);
}
- public DefaultBHttpServerConnection(final int buffersize) {
- this(buffersize, buffersize, null, null, null, null, null, null, null);
+ public DefaultBHttpServerConnection(final int bufferSize) {
+ this(bufferSize, bufferSize, null, null, null, null, null, null, null);
}
protected void onRequestReceived(final HttpRequest request) {
@@ -163,9 +162,9 @@ public class DefaultBHttpServerConnection extends BHttpConnectionBase implements
if (entity == null) {
return;
}
- final OutputStream outstream = prepareOutput(response);
- entity.writeTo(outstream);
- outstream.close();
+ final OutputStream outStream = prepareOutput(response);
+ entity.writeTo(outStream);
+ outStream.close();
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpServerConnectionFactory.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpServerConnectionFactory.java
index e6390d64c..4efc1ed7a 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpServerConnectionFactory.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultBHttpServerConnectionFactory.java
@@ -30,7 +30,6 @@ package com.fr.third.org.apache.http.impl;
import com.fr.third.org.apache.http.HttpConnectionFactory;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpResponse;
-import com.fr.third.org.apache.http.HttpServerConnection;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.config.ConnectionConfig;
@@ -42,7 +41,7 @@ import java.io.IOException;
import java.net.Socket;
/**
- * Default factory for {@link HttpServerConnection}s.
+ * Default factory for {@link com.fr.third.org.apache.http.HttpServerConnection}s.
*
* @since 4.3
*/
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultConnectionReuseStrategy.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultConnectionReuseStrategy.java
index 82cf4d9c9..d26c0e92b 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultConnectionReuseStrategy.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/DefaultConnectionReuseStrategy.java
@@ -80,6 +80,28 @@ public class DefaultConnectionReuseStrategy implements ConnectionReuseStrategy {
Args.notNull(response, "HTTP response");
Args.notNull(context, "HTTP context");
+ // If a HTTP 204 No Content response contains a Content-length with value > 0 or Transfer-Encoding,
+ // don't reuse the connection. This is to avoid getting out-of-sync if a misbehaved HTTP server
+ // returns content as part of a HTTP 204 response.
+ if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NO_CONTENT) {
+ final Header clh = response.getFirstHeader(HTTP.CONTENT_LEN);
+ if (clh != null) {
+ try {
+ final int contentLen = Integer.parseInt(clh.getValue());
+ if (contentLen > 0) {
+ return false;
+ }
+ } catch (final NumberFormatException ex) {
+ // fall through
+ }
+ }
+
+ final Header teh = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
+ if (teh != null) {
+ return false;
+ }
+ }
+
final HttpRequest request = (HttpRequest) context.getAttribute(HttpCoreContext.HTTP_REQUEST);
if (request != null) {
try {
@@ -111,7 +133,7 @@ public class DefaultConnectionReuseStrategy implements ConnectionReuseStrategy {
if (clhs.length == 1) {
final Header clh = clhs[0];
try {
- final int contentLen = Integer.parseInt(clh.getValue());
+ final long contentLen = Long.parseLong(clh.getValue());
if (contentLen < 0) {
return false;
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/EnglishReasonPhraseCatalog.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/EnglishReasonPhraseCatalog.java
index 6d506d69b..83015a4be 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/EnglishReasonPhraseCatalog.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/EnglishReasonPhraseCatalog.java
@@ -93,7 +93,7 @@ public class EnglishReasonPhraseCatalog implements ReasonPhraseCatalog {
new String[3], // 1xx
new String[8], // 2xx
new String[8], // 3xx
- new String[25], // 4xx
+ new String[30], // 4xx
new String[8] // 5xx
};
@@ -140,6 +140,8 @@ public class EnglishReasonPhraseCatalog implements ReasonPhraseCatalog {
"Forbidden");
setReason(HttpStatus.SC_NOT_FOUND,
"Not Found");
+ setReason(HttpStatus.SC_TOO_MANY_REQUESTS,
+ "Too Many Requests");
setReason(HttpStatus.SC_INTERNAL_SERVER_ERROR,
"Internal Server Error");
setReason(HttpStatus.SC_NOT_IMPLEMENTED,
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/HttpConnectionMetricsImpl.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/HttpConnectionMetricsImpl.java
index 704fb4aa0..2b38e6355 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/HttpConnectionMetricsImpl.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/HttpConnectionMetricsImpl.java
@@ -67,20 +67,12 @@ public class HttpConnectionMetricsImpl implements HttpConnectionMetrics {
@Override
public long getReceivedBytesCount() {
- if (this.inTransportMetric != null) {
- return this.inTransportMetric.getBytesTransferred();
- } else {
- return -1;
- }
+ return this.inTransportMetric != null ? this.inTransportMetric.getBytesTransferred() : -1;
}
@Override
public long getSentBytesCount() {
- if (this.outTransportMetric != null) {
- return this.outTransportMetric.getBytesTransferred();
- } else {
- return -1;
- }
+ return this.outTransportMetric != null ? this.outTransportMetric.getBytesTransferred() : -1;
}
@Override
@@ -113,17 +105,13 @@ public class HttpConnectionMetricsImpl implements HttpConnectionMetrics {
} else if (RESPONSE_COUNT.equals(metricName)) {
value = Long.valueOf(responseCount);
} else if (RECEIVED_BYTES_COUNT.equals(metricName)) {
- if (this.inTransportMetric != null) {
- return Long.valueOf(this.inTransportMetric.getBytesTransferred());
- } else {
- return null;
- }
+ return this.inTransportMetric != null
+ ? Long.valueOf(this.inTransportMetric.getBytesTransferred())
+ : null;
} else if (SENT_BYTES_COUNT.equals(metricName)) {
- if (this.outTransportMetric != null) {
- return Long.valueOf(this.outTransportMetric.getBytesTransferred());
- } else {
- return null;
- }
+ return this.outTransportMetric != null
+ ? Long.valueOf(this.outTransportMetric.getBytesTransferred())
+ : null;
}
}
return value;
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/bootstrap/HttpServer.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/bootstrap/HttpServer.java
index fea9e25aa..bb5ce919a 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/bootstrap/HttpServer.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/bootstrap/HttpServer.java
@@ -99,20 +99,12 @@ public class HttpServer {
public InetAddress getInetAddress() {
final ServerSocket localSocket = this.serverSocket;
- if (localSocket != null) {
- return localSocket.getInetAddress();
- } else {
- return null;
- }
+ return localSocket != null ? localSocket.getInetAddress() : null;
}
public int getLocalPort() {
final ServerSocket localSocket = this.serverSocket;
- if (localSocket != null) {
- return localSocket.getLocalPort();
- } else {
- return -1;
- }
+ return localSocket != null ? localSocket.getLocalPort() : -1;
}
public void start() throws IOException {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/bootstrap/SSLServerSetupHandler.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/bootstrap/SSLServerSetupHandler.java
index 65148cd94..1e204284b 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/bootstrap/SSLServerSetupHandler.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/bootstrap/SSLServerSetupHandler.java
@@ -34,7 +34,7 @@ import javax.net.ssl.SSLServerSocket;
* configure various SSL protocol aspects such as supported protocol versions, cypher suites,
* and mandatory / optional client authentication.
*
- * @see javax.net.ssl.SSLServerSocket
+ * @see SSLServerSocket
* @see javax.net.ssl.SSLSession
* @since 4.4
*/
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/bootstrap/ServerBootstrap.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/bootstrap/ServerBootstrap.java
index bad355009..74c753c9b 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/bootstrap/ServerBootstrap.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/bootstrap/ServerBootstrap.java
@@ -93,6 +93,8 @@ public class ServerBootstrap {
/**
* Sets listener port number.
+ *
+ * @return this
*/
public final ServerBootstrap setListenerPort(final int listenerPort) {
this.listenerPort = listenerPort;
@@ -101,6 +103,8 @@ public class ServerBootstrap {
/**
* Assigns local interface for the listener.
+ *
+ * @return this
*/
public final ServerBootstrap setLocalAddress(final InetAddress localAddress) {
this.localAddress = localAddress;
@@ -109,6 +113,8 @@ public class ServerBootstrap {
/**
* Sets socket configuration.
+ *
+ * @return this
*/
public final ServerBootstrap setSocketConfig(final SocketConfig socketConfig) {
this.socketConfig = socketConfig;
@@ -119,7 +125,10 @@ public class ServerBootstrap {
* Sets connection configuration.
*
* Please note this value can be overridden by the {@link #setConnectionFactory(
- *HttpConnectionFactory)} method.
+ * com.fr.third.org.apache.http.HttpConnectionFactory)} method.
+ *
+ *
+ * @return this
*/
public final ServerBootstrap setConnectionConfig(final ConnectionConfig connectionConfig) {
this.connectionConfig = connectionConfig;
@@ -128,6 +137,8 @@ public class ServerBootstrap {
/**
* Assigns {@link HttpProcessor} instance.
+ *
+ * @return this
*/
public final ServerBootstrap setHttpProcessor(final HttpProcessor httpProcessor) {
this.httpProcessor = httpProcessor;
@@ -138,7 +149,10 @@ public class ServerBootstrap {
* Adds this protocol interceptor to the head of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
+ *
+ *
+ * @return this
*/
public final ServerBootstrap addInterceptorFirst(final HttpResponseInterceptor itcp) {
if (itcp == null) {
@@ -155,7 +169,10 @@ public class ServerBootstrap {
* Adds this protocol interceptor to the tail of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
+ *
+ *
+ * @return this
*/
public final ServerBootstrap addInterceptorLast(final HttpResponseInterceptor itcp) {
if (itcp == null) {
@@ -172,7 +189,10 @@ public class ServerBootstrap {
* Adds this protocol interceptor to the head of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
+ *
+ *
+ * @return this
*/
public final ServerBootstrap addInterceptorFirst(final HttpRequestInterceptor itcp) {
if (itcp == null) {
@@ -189,7 +209,10 @@ public class ServerBootstrap {
* Adds this protocol interceptor to the tail of the protocol processing list.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
+ *
+ *
+ * @return this
*/
public final ServerBootstrap addInterceptorLast(final HttpRequestInterceptor itcp) {
if (itcp == null) {
@@ -206,7 +229,10 @@ public class ServerBootstrap {
* Assigns {@code Server} response header value.
*
* Please note this value can be overridden by the {@link #setHttpProcessor(
- *HttpProcessor)} method.
+ * com.fr.third.org.apache.http.protocol.HttpProcessor)} method.
+ *
+ *
+ * @return this
*/
public final ServerBootstrap setServerInfo(final String serverInfo) {
this.serverInfo = serverInfo;
@@ -215,6 +241,8 @@ public class ServerBootstrap {
/**
* Assigns {@link ConnectionReuseStrategy} instance.
+ *
+ * @return this
*/
public final ServerBootstrap setConnectionReuseStrategy(final ConnectionReuseStrategy connStrategy) {
this.connStrategy = connStrategy;
@@ -223,6 +251,8 @@ public class ServerBootstrap {
/**
* Assigns {@link HttpResponseFactory} instance.
+ *
+ * @return this
*/
public final ServerBootstrap setResponseFactory(final HttpResponseFactory responseFactory) {
this.responseFactory = responseFactory;
@@ -231,6 +261,8 @@ public class ServerBootstrap {
/**
* Assigns {@link HttpRequestHandlerMapper} instance.
+ *
+ * @return this
*/
public final ServerBootstrap setHandlerMapper(final HttpRequestHandlerMapper handlerMapper) {
this.handlerMapper = handlerMapper;
@@ -242,10 +274,12 @@ public class ServerBootstrap {
* matching the given pattern.
*
* Please note this value can be overridden by the {@link #setHandlerMapper(
- *HttpRequestHandlerMapper)} method.
+ * com.fr.third.org.apache.http.protocol.HttpRequestHandlerMapper)} method.
+ *
*
* @param pattern the pattern to register the handler for.
* @param handler the handler.
+ * @return this
*/
public final ServerBootstrap registerHandler(final String pattern, final HttpRequestHandler handler) {
if (pattern == null || handler == null) {
@@ -260,6 +294,8 @@ public class ServerBootstrap {
/**
* Assigns {@link HttpExpectationVerifier} instance.
+ *
+ * @return this
*/
public final ServerBootstrap setExpectationVerifier(final HttpExpectationVerifier expectationVerifier) {
this.expectationVerifier = expectationVerifier;
@@ -268,6 +304,8 @@ public class ServerBootstrap {
/**
* Assigns {@link HttpConnectionFactory} instance.
+ *
+ * @return this
*/
public final ServerBootstrap setConnectionFactory(
final HttpConnectionFactory extends DefaultBHttpServerConnection> connectionFactory) {
@@ -276,7 +314,9 @@ public class ServerBootstrap {
}
/**
- * Assigns {@link SSLServerSetupHandler} instance.
+ * Assigns {@link com.fr.third.org.apache.http.impl.bootstrap.SSLServerSetupHandler} instance.
+ *
+ * @return this
*/
public final ServerBootstrap setSslSetupHandler(final SSLServerSetupHandler sslSetupHandler) {
this.sslSetupHandler = sslSetupHandler;
@@ -284,7 +324,9 @@ public class ServerBootstrap {
}
/**
- * Assigns {@link javax.net.ServerSocketFactory} instance.
+ * Assigns {@link ServerSocketFactory} instance.
+ *
+ * @return this
*/
public final ServerBootstrap setServerSocketFactory(final ServerSocketFactory serverSocketFactory) {
this.serverSocketFactory = serverSocketFactory;
@@ -292,10 +334,13 @@ public class ServerBootstrap {
}
/**
- * Assigns {@link javax.net.ssl.SSLContext} instance.
+ * Assigns {@link SSLContext} instance.
*
* Please note this value can be overridden by the {@link #setServerSocketFactory(
- * javax.net.ServerSocketFactory)} method.
+ * ServerSocketFactory)} method.
+ *
+ *
+ * @return this
*/
public final ServerBootstrap setSslContext(final SSLContext sslContext) {
this.sslContext = sslContext;
@@ -303,7 +348,9 @@ public class ServerBootstrap {
}
/**
- * Assigns {@link ExceptionLogger} instance.
+ * Assigns {@link com.fr.third.org.apache.http.ExceptionLogger} instance.
+ *
+ * @return this
*/
public final ServerBootstrap setExceptionLogger(final ExceptionLogger exceptionLogger) {
this.exceptionLogger = exceptionLogger;
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/entity/LaxContentLengthStrategy.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/entity/LaxContentLengthStrategy.java
index 6a66e5a68..a011321e8 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/entity/LaxContentLengthStrategy.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/entity/LaxContentLengthStrategy.java
@@ -105,22 +105,18 @@ public class LaxContentLengthStrategy implements ContentLengthStrategy {
}
final Header contentLengthHeader = message.getFirstHeader(HTTP.CONTENT_LEN);
if (contentLengthHeader != null) {
- long contentlen = -1;
+ long contentLen = -1;
final Header[] headers = message.getHeaders(HTTP.CONTENT_LEN);
for (int i = headers.length - 1; i >= 0; i--) {
final Header header = headers[i];
try {
- contentlen = Long.parseLong(header.getValue());
+ contentLen = Long.parseLong(header.getValue());
break;
} catch (final NumberFormatException ignore) {
}
// See if we can have better luck with another header, if present
}
- if (contentlen >= 0) {
- return contentlen;
- } else {
- return IDENTITY;
- }
+ return contentLen >= 0 ? contentLen : IDENTITY;
}
return this.implicitLen;
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/AbstractMessageParser.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/AbstractMessageParser.java
index 3ba21ed44..8cb4521a8 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/AbstractMessageParser.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/AbstractMessageParser.java
@@ -119,7 +119,7 @@ public abstract class AbstractMessageParser implements Ht
* Parses HTTP headers from the data receiver stream according to the generic
* format as given in Section 3.1 of RFC 822, RFC-2616 Section 4 and 19.3.
*
- * @param inbuffer Session input buffer
+ * @param inBuffer Session input buffer
* @param maxHeaderCount maximum number of headers allowed. If the number
* of headers received from the data stream exceeds maxCount value, an
* IOException will be thrown. Setting this parameter to a negative value
@@ -135,12 +135,12 @@ public abstract class AbstractMessageParser implements Ht
* @throws HttpException in case of HTTP protocol violation
*/
public static Header[] parseHeaders(
- final SessionInputBuffer inbuffer,
+ final SessionInputBuffer inBuffer,
final int maxHeaderCount,
final int maxLineLen,
final LineParser parser) throws HttpException, IOException {
final List headerLines = new ArrayList();
- return parseHeaders(inbuffer, maxHeaderCount, maxLineLen,
+ return parseHeaders(inBuffer, maxHeaderCount, maxLineLen,
parser != null ? parser : BasicLineParser.INSTANCE,
headerLines);
}
@@ -149,7 +149,7 @@ public abstract class AbstractMessageParser implements Ht
* Parses HTTP headers from the data receiver stream according to the generic
* format as given in Section 3.1 of RFC 822, RFC-2616 Section 4 and 19.3.
*
- * @param inbuffer Session input buffer
+ * @param inBuffer Session input buffer
* @param maxHeaderCount maximum number of headers allowed. If the number
* of headers received from the data stream exceeds maxCount value, an
* IOException will be thrown. Setting this parameter to a negative value
@@ -170,12 +170,12 @@ public abstract class AbstractMessageParser implements Ht
* @since 4.1
*/
public static Header[] parseHeaders(
- final SessionInputBuffer inbuffer,
+ final SessionInputBuffer inBuffer,
final int maxHeaderCount,
final int maxLineLen,
final LineParser parser,
final List headerLines) throws HttpException, IOException {
- Args.notNull(inbuffer, "Session input buffer");
+ Args.notNull(inBuffer, "Session input buffer");
Args.notNull(parser, "Line parser");
Args.notNull(headerLines, "Header line list");
@@ -187,8 +187,8 @@ public abstract class AbstractMessageParser implements Ht
} else {
current.clear();
}
- final int l = inbuffer.readLine(current);
- if (l == -1 || current.length() < 1) {
+ final int readLen = inBuffer.readLine(current);
+ if (readLen == -1 || current.length() < 1) {
break;
}
// Parse the header name and value
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/ChunkedInputStream.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/ChunkedInputStream.java
index dde9ee454..d15de309a 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/ChunkedInputStream.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/ChunkedInputStream.java
@@ -119,9 +119,8 @@ public class ChunkedInputStream extends InputStream {
if (this.in instanceof BufferInfo) {
final int len = ((BufferInfo) this.in).length();
return (int) Math.min(len, this.chunkSize - this.pos);
- } else {
- return 0;
}
+ return 0;
}
/**
@@ -186,19 +185,17 @@ public class ChunkedInputStream extends InputStream {
return -1;
}
}
- final int bytesRead = in.read(b, off, (int) Math.min(len, chunkSize - pos));
- if (bytesRead != -1) {
- pos += bytesRead;
+ final int readLen = in.read(b, off, (int) Math.min(len, chunkSize - pos));
+ if (readLen != -1) {
+ pos += readLen;
if (pos >= chunkSize) {
state = CHUNK_CRLF;
}
- return bytesRead;
- } else {
- eof = true;
- throw new TruncatedChunkException("Truncated chunk "
- + "( expected size: " + chunkSize
- + "; actual size: " + pos + ")");
+ return readLen;
}
+ eof = true;
+ throw new TruncatedChunkException("Truncated chunk (expected size: %,d; actual size: %,d)",
+ chunkSize, pos);
}
/**
@@ -263,8 +260,8 @@ public class ChunkedInputStream extends InputStream {
this.buffer.clear();
final int bytesRead2 = this.in.readLine(this.buffer);
if (bytesRead2 == -1) {
- throw new ConnectionClosedException("Premature end of chunk coded message body: " +
- "closing chunk expected");
+ throw new ConnectionClosedException(
+ "Premature end of chunk coded message body: closing chunk expected");
}
int separator = this.buffer.indexOf(';');
if (separator < 0) {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/ContentLengthInputStream.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/ContentLengthInputStream.java
index 02f2c62e1..5a4a1dce3 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/ContentLengthInputStream.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/ContentLengthInputStream.java
@@ -99,6 +99,7 @@ public class ContentLengthInputStream extends InputStream {
if (pos < contentLength) {
final byte buffer[] = new byte[BUFFER_SIZE];
while (read(buffer) >= 0) {
+ // do nothing.
}
}
} finally {
@@ -114,16 +115,15 @@ public class ContentLengthInputStream extends InputStream {
if (this.in instanceof BufferInfo) {
final int len = ((BufferInfo) this.in).length();
return Math.min(len, (int) (this.contentLength - this.pos));
- } else {
- return 0;
}
+ return 0;
}
/**
* Read the next byte from the stream
* @return The next byte or -1 if the end of stream has been reached.
* @throws IOException If an IO problem occurs
- * @see java.io.InputStream#read()
+ * @see InputStream#read()
*/
@Override
public int read() throws IOException {
@@ -138,8 +138,8 @@ public class ContentLengthInputStream extends InputStream {
if (b == -1) {
if (pos < contentLength) {
throw new ConnectionClosedException(
- "Premature end of Content-Length delimited message body (expected: "
- + contentLength + "; received: " + pos);
+ "Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
+ contentLength, pos);
}
} else {
pos++;
@@ -157,10 +157,10 @@ public class ContentLengthInputStream extends InputStream {
* @return The number of bytes read, or -1 if the end of content has been
* reached.
*
- * @throws java.io.IOException Should an error occur on the wrapped stream.
+ * @throws IOException Should an error occur on the wrapped stream.
*/
@Override
- public int read (final byte[] b, final int off, final int len) throws java.io.IOException {
+ public int read(final byte[] b, final int off, final int len) throws IOException {
if (closed) {
throw new IOException("Attempted read from closed stream.");
}
@@ -173,16 +173,16 @@ public class ContentLengthInputStream extends InputStream {
if (pos + len > contentLength) {
chunk = (int) (contentLength - pos);
}
- final int count = this.in.read(b, off, chunk);
- if (count == -1 && pos < contentLength) {
+ final int readLen = this.in.read(b, off, chunk);
+ if (readLen == -1 && pos < contentLength) {
throw new ConnectionClosedException(
- "Premature end of Content-Length delimited message body (expected: "
- + contentLength + "; received: " + pos);
+ "Premature end of Content-Length delimited message body (expected: %,d; received: %,d)",
+ contentLength, pos);
}
- if (count > 0) {
- pos += count;
+ if (readLen > 0) {
+ pos += readLen;
}
- return count;
+ return readLen;
}
@@ -191,7 +191,7 @@ public class ContentLengthInputStream extends InputStream {
* @param b The byte array to put the new data in.
* @return The number of bytes read into the buffer.
* @throws IOException If an IO problem occurs
- * @see java.io.InputStream#read(byte[])
+ * @see InputStream#read(byte[])
*/
@Override
public int read(final byte[] b) throws IOException {
@@ -218,12 +218,12 @@ public class ContentLengthInputStream extends InputStream {
// skip and keep track of the bytes actually skipped
long count = 0;
while (remaining > 0) {
- final int l = read(buffer, 0, (int)Math.min(BUFFER_SIZE, remaining));
- if (l == -1) {
+ final int readLen = read(buffer, 0, (int)Math.min(BUFFER_SIZE, remaining));
+ if (readLen == -1) {
break;
}
- count += l;
- remaining -= l;
+ count += readLen;
+ remaining -= readLen;
}
return count;
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/ContentLengthOutputStream.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/ContentLengthOutputStream.java
index 25006a481..36173931e 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/ContentLengthOutputStream.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/ContentLengthOutputStream.java
@@ -60,10 +60,10 @@ public class ContentLengthOutputStream extends OutputStream {
private final long contentLength;
/** Total bytes written */
- private long total = 0;
+ private long total;
/** True if the stream is closed. */
- private boolean closed = false;
+ private boolean closed;
/**
* Wraps a session output buffer and cuts off output after a defined number
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/DefaultHttpRequestParser.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/DefaultHttpRequestParser.java
index 0d5d08c6c..6f9d450f0 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/DefaultHttpRequestParser.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/DefaultHttpRequestParser.java
@@ -29,7 +29,6 @@ package com.fr.third.org.apache.http.impl.io;
import java.io.IOException;
-import com.fr.third.org.apache.http.message.BasicLineParser;
import com.fr.third.org.apache.http.ConnectionClosedException;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpRequest;
@@ -86,7 +85,7 @@ public class DefaultHttpRequestParser extends AbstractMessageParser
*
* @param buffer the session input buffer.
* @param lineParser the line parser. If {@code null}
- * {@link BasicLineParser#INSTANCE} will be used.
+ * {@link com.fr.third.org.apache.http.message.BasicLineParser#INSTANCE} will be used.
* @param requestFactory the response factory. If {@code null}
* {@link DefaultHttpRequestFactory#INSTANCE} will be used.
* @param constraints the message constraints. If {@code null}
@@ -127,8 +126,8 @@ public class DefaultHttpRequestParser extends AbstractMessageParser
throws IOException, HttpException, ParseException {
this.lineBuf.clear();
- final int i = sessionBuffer.readLine(this.lineBuf);
- if (i == -1) {
+ final int readLen = sessionBuffer.readLine(this.lineBuf);
+ if (readLen == -1) {
throw new ConnectionClosedException("Client closed connection");
}
final ParserCursor cursor = new ParserCursor(0, this.lineBuf.length());
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/DefaultHttpRequestWriter.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/DefaultHttpRequestWriter.java
index 215bf6ca5..d73261a15 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/DefaultHttpRequestWriter.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/DefaultHttpRequestWriter.java
@@ -29,7 +29,6 @@ package com.fr.third.org.apache.http.impl.io;
import java.io.IOException;
-import com.fr.third.org.apache.http.message.BasicLineFormatter;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.io.SessionOutputBuffer;
import com.fr.third.org.apache.http.message.LineFormatter;
@@ -46,7 +45,7 @@ public class DefaultHttpRequestWriter extends AbstractMessageWriter
*
* @param buffer the session output buffer.
* @param formatter the line formatter If {@code null}
- * {@link BasicLineFormatter#INSTANCE}
+ * {@link com.fr.third.org.apache.http.message.BasicLineFormatter#INSTANCE}
* will be used.
*/
public DefaultHttpRequestWriter(
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/DefaultHttpResponseParser.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/DefaultHttpResponseParser.java
index a8405a2fd..1e5397d90 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/DefaultHttpResponseParser.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/DefaultHttpResponseParser.java
@@ -29,7 +29,6 @@ package com.fr.third.org.apache.http.impl.io;
import java.io.IOException;
-import com.fr.third.org.apache.http.message.BasicLineParser;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.HttpResponseFactory;
@@ -86,7 +85,7 @@ public class DefaultHttpResponseParser extends AbstractMessageParser= 0 ? minChunkLimit : 512;
this.constraints = constraints != null ? constraints : MessageConstraints.DEFAULT;
- this.linebuffer = new ByteArrayBuffer(buffersize);
- this.decoder = chardecoder;
+ this.lineBuffer = new ByteArrayBuffer(bufferSize);
+ this.decoder = charDecoder;
}
public SessionInputBufferImpl(
final HttpTransportMetricsImpl metrics,
- final int buffersize) {
- this(metrics, buffersize, buffersize, null, null);
+ final int bufferSize) {
+ this(metrics, bufferSize, bufferSize, null, null);
}
- public void bind(final InputStream instream) {
- this.instream = instream;
+ public void bind(final InputStream inputStream) {
+ this.inStream = inputStream;
}
public boolean isBound() {
- return this.instream != null;
+ return this.inStream != null;
}
@Override
@@ -124,7 +124,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
@Override
public int length() {
- return this.bufferlen - this.bufferpos;
+ return this.bufferLen - this.bufferPos;
}
@Override
@@ -133,40 +133,39 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
}
private int streamRead(final byte[] b, final int off, final int len) throws IOException {
- Asserts.notNull(this.instream, "Input stream");
- return this.instream.read(b, off, len);
+ Asserts.notNull(this.inStream, "Input stream");
+ return this.inStream.read(b, off, len);
}
public int fillBuffer() throws IOException {
// compact the buffer if necessary
- if (this.bufferpos > 0) {
- final int len = this.bufferlen - this.bufferpos;
+ if (this.bufferPos > 0) {
+ final int len = this.bufferLen - this.bufferPos;
if (len > 0) {
- System.arraycopy(this.buffer, this.bufferpos, this.buffer, 0, len);
+ System.arraycopy(this.buffer, this.bufferPos, this.buffer, 0, len);
}
- this.bufferpos = 0;
- this.bufferlen = len;
+ this.bufferPos = 0;
+ this.bufferLen = len;
}
- final int l;
- final int off = this.bufferlen;
+ final int readLen;
+ final int off = this.bufferLen;
final int len = this.buffer.length - off;
- l = streamRead(this.buffer, off, len);
- if (l == -1) {
+ readLen = streamRead(this.buffer, off, len);
+ if (readLen == -1) {
return -1;
- } else {
- this.bufferlen = off + l;
- this.metrics.incrementBytesTransferred(l);
- return l;
}
+ this.bufferLen = off + readLen;
+ this.metrics.incrementBytesTransferred(readLen);
+ return readLen;
}
public boolean hasBufferedData() {
- return this.bufferpos < this.bufferlen;
+ return this.bufferPos < this.bufferLen;
}
public void clear() {
- this.bufferpos = 0;
- this.bufferlen = 0;
+ this.bufferPos = 0;
+ this.bufferLen = 0;
}
@Override
@@ -178,7 +177,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
return -1;
}
}
- return this.buffer[this.bufferpos++] & 0xff;
+ return this.buffer[this.bufferPos++] & 0xff;
}
@Override
@@ -187,32 +186,31 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
return 0;
}
if (hasBufferedData()) {
- final int chunk = Math.min(len, this.bufferlen - this.bufferpos);
- System.arraycopy(this.buffer, this.bufferpos, b, off, chunk);
- this.bufferpos += chunk;
+ final int chunk = Math.min(len, this.bufferLen - this.bufferPos);
+ System.arraycopy(this.buffer, this.bufferPos, b, off, chunk);
+ this.bufferPos += chunk;
return chunk;
}
// If the remaining capacity is big enough, read directly from the
// underlying input stream bypassing the buffer.
if (len > this.minChunkLimit) {
- final int read = streamRead(b, off, len);
- if (read > 0) {
- this.metrics.incrementBytesTransferred(read);
+ final int readLen = streamRead(b, off, len);
+ if (readLen > 0) {
+ this.metrics.incrementBytesTransferred(readLen);
}
- return read;
- } else {
- // otherwise read to the buffer first
- while (!hasBufferedData()) {
- final int noRead = fillBuffer();
- if (noRead == -1) {
- return -1;
- }
+ return readLen;
+ }
+ // otherwise read to the buffer first
+ while (!hasBufferedData()) {
+ final int noRead = fillBuffer();
+ if (noRead == -1) {
+ return -1;
}
- final int chunk = Math.min(len, this.bufferlen - this.bufferpos);
- System.arraycopy(this.buffer, this.bufferpos, b, off, chunk);
- this.bufferpos += chunk;
- return chunk;
}
+ final int chunk = Math.min(len, this.bufferLen - this.bufferPos);
+ System.arraycopy(this.buffer, this.bufferPos, b, off, chunk);
+ this.bufferPos += chunk;
+ return chunk;
}
@Override
@@ -236,7 +234,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
*
* @param charbuffer the line buffer.
* @return one line of characters
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
@Override
public int readLine(final CharArrayBuffer charbuffer) throws IOException {
@@ -247,7 +245,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
while (retry) {
// attempt to find end of line (LF)
int pos = -1;
- for (int i = this.bufferpos; i < this.bufferlen; i++) {
+ for (int i = this.bufferPos; i < this.bufferLen; i++) {
if (this.buffer[i] == HTTP.LF) {
pos = i;
break;
@@ -255,8 +253,8 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
}
if (maxLineLen > 0) {
- final int currentLen = this.linebuffer.length()
- + (pos > 0 ? pos : this.bufferlen) - this.bufferpos;
+ final int currentLen = this.lineBuffer.length()
+ + (pos >= 0 ? pos : this.bufferLen) - this.bufferPos;
if (currentLen >= maxLineLen) {
throw new MessageConstraintException("Maximum line length limit exceeded");
}
@@ -264,20 +262,20 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
if (pos != -1) {
// end of line found.
- if (this.linebuffer.isEmpty()) {
+ if (this.lineBuffer.isEmpty()) {
// the entire line is preset in the read buffer
return lineFromReadBuffer(charbuffer, pos);
}
retry = false;
- final int len = pos + 1 - this.bufferpos;
- this.linebuffer.append(this.buffer, this.bufferpos, len);
- this.bufferpos = pos + 1;
+ final int len = pos + 1 - this.bufferPos;
+ this.lineBuffer.append(this.buffer, this.bufferPos, len);
+ this.bufferPos = pos + 1;
} else {
// end of line not found
if (hasBufferedData()) {
- final int len = this.bufferlen - this.bufferpos;
- this.linebuffer.append(this.buffer, this.bufferpos, len);
- this.bufferpos = this.bufferlen;
+ final int len = this.bufferLen - this.bufferPos;
+ this.lineBuffer.append(this.buffer, this.bufferPos, len);
+ this.bufferPos = this.bufferLen;
}
noRead = fillBuffer();
if (noRead == -1) {
@@ -285,7 +283,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
}
}
}
- if (noRead == -1 && this.linebuffer.isEmpty()) {
+ if (noRead == -1 && this.lineBuffer.isEmpty()) {
// indicate the end of stream
return -1;
}
@@ -303,39 +301,39 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
* to CR-LF required by the HTTP specification.
*
* @return HTTP line as a string
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
private int lineFromLineBuffer(final CharArrayBuffer charbuffer)
throws IOException {
// discard LF if found
- int len = this.linebuffer.length();
+ int len = this.lineBuffer.length();
if (len > 0) {
- if (this.linebuffer.byteAt(len - 1) == HTTP.LF) {
+ if (this.lineBuffer.byteAt(len - 1) == HTTP.LF) {
len--;
}
// discard CR if found
if (len > 0) {
- if (this.linebuffer.byteAt(len - 1) == HTTP.CR) {
+ if (this.lineBuffer.byteAt(len - 1) == HTTP.CR) {
len--;
}
}
}
if (this.decoder == null) {
- charbuffer.append(this.linebuffer, 0, len);
+ charbuffer.append(this.lineBuffer, 0, len);
} else {
- final ByteBuffer bbuf = ByteBuffer.wrap(this.linebuffer.buffer(), 0, len);
+ final ByteBuffer bbuf = ByteBuffer.wrap(this.lineBuffer.buffer(), 0, len);
len = appendDecoded(charbuffer, bbuf);
}
- this.linebuffer.clear();
+ this.lineBuffer.clear();
return len;
}
private int lineFromReadBuffer(final CharArrayBuffer charbuffer, final int position)
throws IOException {
int pos = position;
- final int off = this.bufferpos;
+ final int off = this.bufferPos;
int len;
- this.bufferpos = pos + 1;
+ this.bufferPos = pos + 1;
if (pos > off && this.buffer[pos - 1] == HTTP.CR) {
// skip CR if found
pos--;
@@ -389,12 +387,8 @@ public class SessionInputBufferImpl implements SessionInputBuffer, BufferInfo {
@Override
public String readLine() throws IOException {
final CharArrayBuffer charbuffer = new CharArrayBuffer(64);
- final int l = readLine(charbuffer);
- if (l != -1) {
- return charbuffer.toString();
- } else {
- return null;
- }
+ final int readLen = readLine(charbuffer);
+ return readLen != -1 ? charbuffer.toString() : null;
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/SessionOutputBufferImpl.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/SessionOutputBufferImpl.java
index 1144900a9..69880af20 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/SessionOutputBufferImpl.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/io/SessionOutputBufferImpl.java
@@ -62,46 +62,46 @@ public class SessionOutputBufferImpl implements SessionOutputBuffer, BufferInfo
private final int fragementSizeHint;
private final CharsetEncoder encoder;
- private OutputStream outstream;
+ private OutputStream outStream;
private ByteBuffer bbuf;
/**
* Creates new instance of SessionOutputBufferImpl.
*
* @param metrics HTTP transport metrics.
- * @param buffersize buffer size. Must be a positive number.
+ * @param bufferSize buffer size. Must be a positive number.
* @param fragementSizeHint fragment size hint defining a minimal size of a fragment
* that should be written out directly to the socket bypassing the session buffer.
* Value {@code 0} disables fragment buffering.
- * @param charencoder charencoder to be used for encoding HTTP protocol elements.
+ * @param charEncoder charEncoder to be used for encoding HTTP protocol elements.
* If {@code null} simple type cast will be used for char to byte conversion.
*/
public SessionOutputBufferImpl(
final HttpTransportMetricsImpl metrics,
- final int buffersize,
+ final int bufferSize,
final int fragementSizeHint,
- final CharsetEncoder charencoder) {
+ final CharsetEncoder charEncoder) {
super();
- Args.positive(buffersize, "Buffer size");
+ Args.positive(bufferSize, "Buffer size");
Args.notNull(metrics, "HTTP transport metrcis");
this.metrics = metrics;
- this.buffer = new ByteArrayBuffer(buffersize);
+ this.buffer = new ByteArrayBuffer(bufferSize);
this.fragementSizeHint = fragementSizeHint >= 0 ? fragementSizeHint : 0;
- this.encoder = charencoder;
+ this.encoder = charEncoder;
}
public SessionOutputBufferImpl(
final HttpTransportMetricsImpl metrics,
- final int buffersize) {
- this(metrics, buffersize, buffersize, null);
+ final int bufferSize) {
+ this(metrics, bufferSize, bufferSize, null);
}
- public void bind(final OutputStream outstream) {
- this.outstream = outstream;
+ public void bind(final OutputStream outStream) {
+ this.outStream = outStream;
}
public boolean isBound() {
- return this.outstream != null;
+ return this.outStream != null;
}
@Override
@@ -120,13 +120,13 @@ public class SessionOutputBufferImpl implements SessionOutputBuffer, BufferInfo
}
private void streamWrite(final byte[] b, final int off, final int len) throws IOException {
- Asserts.notNull(outstream, "Output stream");
- this.outstream.write(b, off, len);
+ Asserts.notNull(outStream, "Output stream");
+ this.outStream.write(b, off, len);
}
private void flushStream() throws IOException {
- if (this.outstream != null) {
- this.outstream.flush();
+ if (this.outStream != null) {
+ this.outStream.flush();
}
}
@@ -188,7 +188,7 @@ public class SessionOutputBufferImpl implements SessionOutputBuffer, BufferInfo
this.buffer.append(b);
} else {
flushBuffer();
- this.outstream.write(b);
+ this.outStream.write(b);
}
}
@@ -199,7 +199,7 @@ public class SessionOutputBufferImpl implements SessionOutputBuffer, BufferInfo
* This method uses CR-LF as a line delimiter.
*
* @param s the line.
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
@Override
public void writeLine(final String s) throws IOException {
@@ -226,7 +226,7 @@ public class SessionOutputBufferImpl implements SessionOutputBuffer, BufferInfo
* This method uses CR-LF as a line delimiter.
*
* @param charbuffer the buffer containing chars of the line.
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
@Override
public void writeLine(final CharArrayBuffer charbuffer) throws IOException {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/pool/BasicConnFactory.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/pool/BasicConnFactory.java
index 0540c888f..21d7f155a 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/pool/BasicConnFactory.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/pool/BasicConnFactory.java
@@ -29,6 +29,9 @@ package com.fr.third.org.apache.http.impl.pool;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
@@ -36,8 +39,8 @@ import javax.net.ssl.SSLSocketFactory;
import com.fr.third.org.apache.http.HttpClientConnection;
import com.fr.third.org.apache.http.HttpConnectionFactory;
import com.fr.third.org.apache.http.HttpHost;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.config.ConnectionConfig;
import com.fr.third.org.apache.http.config.SocketConfig;
import com.fr.third.org.apache.http.impl.DefaultBHttpClientConnection;
@@ -47,6 +50,7 @@ import com.fr.third.org.apache.http.params.HttpParamConfig;
import com.fr.third.org.apache.http.params.HttpParams;
import com.fr.third.org.apache.http.pool.ConnFactory;
import com.fr.third.org.apache.http.util.Args;
+import com.fr.third.org.apache.http.util.Asserts;
/**
* A very basic {@link ConnFactory} implementation that creates
@@ -145,15 +149,14 @@ public class BasicConnFactory implements ConnFactory() {
+ @Override
+ public Object run() throws IOException {
+ socket.connect(address, BasicConnFactory.this.connectTimeout);
+ return null;
+ }
+ });
+ } catch (final PrivilegedActionException e) {
+ Asserts.check(e.getCause() instanceof IOException,
+ "method contract violation only checked exceptions are wrapped: " + e.getCause());
+ // only checked exceptions are wrapped - error and RTExceptions are rethrown by doPrivileged
+ throw (IOException) e.getCause();
+ }
return this.connFactory.createConnection(socket);
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/pool/BasicConnPool.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/pool/BasicConnPool.java
index e46dd6238..4d417e32f 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/pool/BasicConnPool.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/pool/BasicConnPool.java
@@ -28,7 +28,6 @@ package com.fr.third.org.apache.http.impl.pool;
import java.util.concurrent.atomic.AtomicLong;
-import com.fr.third.org.apache.http.pool.ConnPool;
import com.fr.third.org.apache.http.HttpClientConnection;
import com.fr.third.org.apache.http.HttpHost;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
@@ -40,7 +39,7 @@ import com.fr.third.org.apache.http.pool.AbstractConnPool;
import com.fr.third.org.apache.http.pool.ConnFactory;
/**
- * A very basic {@link ConnPool} implementation that
+ * A very basic {@link com.fr.third.org.apache.http.pool.ConnPool} implementation that
* represents a pool of blocking {@link HttpClientConnection} connections
* identified by an {@link HttpHost} instance. Please note this pool
* implementation does not support complex routes via a proxy cannot
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/pool/BasicPoolEntry.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/pool/BasicPoolEntry.java
index 27189af76..d5409138e 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/pool/BasicPoolEntry.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/impl/pool/BasicPoolEntry.java
@@ -30,8 +30,8 @@ import java.io.IOException;
import com.fr.third.org.apache.http.HttpClientConnection;
import com.fr.third.org.apache.http.HttpHost;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.pool.PoolEntry;
/**
@@ -52,7 +52,16 @@ public class BasicPoolEntry extends PoolEntry {
@Override
public void close() {
try {
- this.getConnection().close();
+ final HttpClientConnection connection = getConnection();
+ try {
+ final int socketTimeout = connection.getSocketTimeout();
+ if (socketTimeout <= 0 || socketTimeout > 1000) {
+ connection.setSocketTimeout(1000);
+ }
+ connection.close();
+ } catch (final IOException ex) {
+ connection.shutdown();
+ }
} catch (final IOException ignore) {
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/io/SessionInputBuffer.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/io/SessionInputBuffer.java
index 8a5376d7e..7fce684ab 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/io/SessionInputBuffer.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/io/SessionInputBuffer.java
@@ -63,7 +63,7 @@ public interface SessionInputBuffer {
* @return the total number of bytes read into the buffer, or
* {@code -1} if there is no more data because the end of
* the stream has been reached.
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
int read(byte[] b, int off, int len) throws IOException;
@@ -77,7 +77,7 @@ public interface SessionInputBuffer {
* @return the total number of bytes read into the buffer, or
* {@code -1} is there is no more data because the end of
* the stream has been reached.
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
int read(byte[] b) throws IOException;
@@ -91,7 +91,7 @@ public interface SessionInputBuffer {
*
* @return the next byte of data, or {@code -1} if the end of the
* stream is reached.
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
int read() throws IOException;
@@ -108,7 +108,7 @@ public interface SessionInputBuffer {
*
* @param buffer the line buffer.
* @return one line of characters
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
int readLine(CharArrayBuffer buffer) throws IOException;
@@ -123,7 +123,7 @@ public interface SessionInputBuffer {
* specific implementations of this interface.
*
* @return HTTP line as a string
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
String readLine() throws IOException;
@@ -134,7 +134,7 @@ public interface SessionInputBuffer {
* @param timeout in milliseconds.
* @return {@code true} if some data is available in the session
* buffer or {@code false} otherwise.
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*
* @deprecated (4.3) do not use. This function should be provided at the
* connection level
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/io/SessionOutputBuffer.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/io/SessionOutputBuffer.java
index 8995bd8d8..7069f1dd8 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/io/SessionOutputBuffer.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/io/SessionOutputBuffer.java
@@ -53,7 +53,7 @@ public interface SessionOutputBuffer {
* @param b the data.
* @param off the start offset in the data.
* @param len the number of bytes to write.
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
void write(byte[] b, int off, int len) throws IOException;
@@ -62,7 +62,7 @@ public interface SessionOutputBuffer {
* to this session buffer.
*
* @param b the data.
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
void write(byte[] b) throws IOException;
@@ -70,7 +70,7 @@ public interface SessionOutputBuffer {
* Writes the specified byte to this session buffer.
*
* @param b the {@code byte}.
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
void write(int b) throws IOException;
@@ -82,7 +82,7 @@ public interface SessionOutputBuffer {
* specific implementations of this interface.
*
* @param s the line.
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
void writeLine(String s) throws IOException;
@@ -94,7 +94,7 @@ public interface SessionOutputBuffer {
* specific implementations of this interface.
*
* @param buffer the buffer containing chars of the line.
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
void writeLine(CharArrayBuffer buffer) throws IOException;
@@ -106,7 +106,7 @@ public interface SessionOutputBuffer {
* stream, such bytes should immediately be written to their
* intended destination.
*
- * @exception IOException if an I/O error occurs.
+ * @throws IOException if an I/O error occurs.
*/
void flush() throws IOException;
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/AbstractHttpMessage.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/AbstractHttpMessage.java
index f1501ef8b..1c67947d5 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/AbstractHttpMessage.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/AbstractHttpMessage.java
@@ -44,6 +44,9 @@ public abstract class AbstractHttpMessage implements HttpMessage {
protected HeaderGroup headergroup;
+ /**
+ * @deprecated Do not use.
+ */
@Deprecated
protected HttpParams params;
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeader.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeader.java
index d8d8e208f..0eef9806f 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeader.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeader.java
@@ -32,64 +32,64 @@ import java.io.Serializable;
import com.fr.third.org.apache.http.Header;
import com.fr.third.org.apache.http.HeaderElement;
import com.fr.third.org.apache.http.ParseException;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.util.Args;
/**
- * Basic implementation of {@link Header}.
+ * Implements a basic {@link Header}.
*
* @since 4.0
*/
@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class BasicHeader implements Header, Cloneable, Serializable {
+ private static final HeaderElement[] EMPTY_HEADER_ELEMENTS = new HeaderElement[] {};
+
private static final long serialVersionUID = -5427236326487562174L;
private final String name;
private final String value;
/**
- * Constructor with name and value
+ * Constructs with name and value.
*
* @param name the header name
* @param value the header value
*/
public BasicHeader(final String name, final String value) {
- super();
this.name = Args.notNull(name, "Name");
this.value = value;
}
@Override
- public String getName() {
- return this.name;
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
}
@Override
- public String getValue() {
- return this.value;
+ public HeaderElement[] getElements() throws ParseException {
+ if (this.getValue() != null) {
+ // result intentionally not cached, it's probably not used again
+ return BasicHeaderValueParser.parseElements(this.getValue(), null);
+ }
+ return EMPTY_HEADER_ELEMENTS;
}
@Override
- public String toString() {
- // no need for non-default formatting in toString()
- return BasicLineFormatter.INSTANCE.formatHeader(null, this).toString();
+ public String getName() {
+ return name;
}
@Override
- public HeaderElement[] getElements() throws ParseException {
- if (this.value != null) {
- // result intentionally not cached, it's probably not used again
- return BasicHeaderValueParser.parseElements(this.value, null);
- } else {
- return new HeaderElement[] {};
- }
+ public String getValue() {
+ return value;
}
@Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
+ public String toString() {
+ // no need for non-default formatting in toString()
+ return BasicLineFormatter.INSTANCE.formatHeader(null, this).toString();
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeaderElement.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeaderElement.java
index 5bc636507..de238bc15 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeaderElement.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeaderElement.java
@@ -124,9 +124,8 @@ public class BasicHeaderElement implements HeaderElement, Cloneable {
return this.name.equals(that.name)
&& LangUtils.equals(this.value, that.value)
&& LangUtils.equals(this.parameters, that.parameters);
- } else {
- return false;
}
+ return false;
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeaderElementIterator.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeaderElementIterator.java
index 29fd9e208..20a889a3b 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeaderElementIterator.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeaderElementIterator.java
@@ -77,14 +77,13 @@ public class BasicHeaderElementIterator implements HeaderElementIterator {
this.cursor = new ParserCursor(0, this.buffer.length());
this.cursor.updatePos(((FormattedHeader) h).getValuePos());
break;
- } else {
- final String value = h.getValue();
- if (value != null) {
- this.buffer = new CharArrayBuffer(value.length());
- this.buffer.append(value);
- this.cursor = new ParserCursor(0, this.buffer.length());
- break;
- }
+ }
+ final String value = h.getValue();
+ if (value != null) {
+ this.buffer = new CharArrayBuffer(value.length());
+ this.buffer.append(value);
+ this.cursor = new ParserCursor(0, this.buffer.length());
+ break;
}
}
}
@@ -101,7 +100,7 @@ public class BasicHeaderElementIterator implements HeaderElementIterator {
// loop while there is data in the buffer
while (!this.cursor.atEnd()) {
final HeaderElement e = this.parser.parseHeaderElement(this.buffer, this.cursor);
- if (!(e.getName().length() == 0 && e.getValue() == null)) {
+ if (!(e.getName().isEmpty() && e.getValue() == null)) {
// Found something
this.currentElement = e;
return;
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeaderValueParser.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeaderValueParser.java
index 6fa03eeff..6e4dd9580 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeaderValueParser.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHeaderValueParser.java
@@ -107,7 +107,7 @@ public class BasicHeaderValueParser implements HeaderValueParser {
final List elements = new ArrayList();
while (!cursor.atEnd()) {
final HeaderElement element = parseHeaderElement(buffer, cursor);
- if (!(element.getName().length() == 0 && element.getValue() == null)) {
+ if (!(element.getName().isEmpty() && element.getValue() == null)) {
elements.add(element);
}
}
@@ -254,7 +254,7 @@ public class BasicHeaderValueParser implements HeaderValueParser {
}
/**
- * @deprecated (4.4) use {@link TokenParser}
+ * @deprecated (4.4) use {@link com.fr.third.org.apache.http.message.TokenParser}
*/
@Deprecated
public NameValuePair parseNameValuePair(final CharArrayBuffer buffer,
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHttpResponse.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHttpResponse.java
index 1c3e5715b..af5fc3387 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHttpResponse.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicHttpResponse.java
@@ -29,7 +29,6 @@ package com.fr.third.org.apache.http.message;
import java.util.Locale;
-import com.fr.third.org.apache.http.impl.DefaultHttpResponseFactory;
import com.fr.third.org.apache.http.HttpEntity;
import com.fr.third.org.apache.http.HttpResponse;
import com.fr.third.org.apache.http.HttpVersion;
@@ -37,11 +36,12 @@ import com.fr.third.org.apache.http.ProtocolVersion;
import com.fr.third.org.apache.http.ReasonPhraseCatalog;
import com.fr.third.org.apache.http.StatusLine;
import com.fr.third.org.apache.http.util.Args;
+import com.fr.third.org.apache.http.util.TextUtils;
/**
* Basic implementation of {@link HttpResponse}.
*
- * @see DefaultHttpResponseFactory
+ * @see com.fr.third.org.apache.http.impl.DefaultHttpResponseFactory
*
* @since 4.0
*/
@@ -191,7 +191,7 @@ public class BasicHttpResponse extends AbstractHttpMessage implements HttpRespon
@Override
public void setReasonPhrase(final String reason) {
this.statusline = null;
- this.reasonPhrase = reason;
+ this.reasonPhrase = TextUtils.isBlank(reason) ? null : reason;
}
// non-javadoc, see interface HttpResponse
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicLineFormatter.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicLineFormatter.java
index 6bacc7517..bc852befc 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicLineFormatter.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicLineFormatter.java
@@ -32,8 +32,8 @@ import com.fr.third.org.apache.http.Header;
import com.fr.third.org.apache.http.ProtocolVersion;
import com.fr.third.org.apache.http.RequestLine;
import com.fr.third.org.apache.http.StatusLine;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.util.Args;
import com.fr.third.org.apache.http.util.CharArrayBuffer;
@@ -316,7 +316,17 @@ public class BasicLineFormatter implements LineFormatter {
buffer.append(name);
buffer.append(": ");
if (value != null) {
- buffer.append(value);
+ buffer.ensureCapacity(buffer.length() + value.length());
+ for (int valueIndex = 0; valueIndex < value.length(); valueIndex++) {
+ char valueChar = value.charAt(valueIndex);
+ if (valueChar == '\r'
+ || valueChar == '\n'
+ || valueChar == '\f'
+ || valueChar == 0x0b) {
+ valueChar = ' ';
+ }
+ buffer.append(valueChar);
+ }
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicTokenIterator.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicTokenIterator.java
index cf2e673f0..e1f2fcde6 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicTokenIterator.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BasicTokenIterator.java
@@ -192,7 +192,7 @@ public class BasicTokenIterator implements TokenIterator {
* Creates a new token to be returned.
* Called from {@link #findNext findNext} after the token is identified.
* The default implementation simply calls
- * {@link java.lang.String#substring String.substring}.
+ * {@link String#substring String.substring}.
*
* If header values are significantly longer than tokens, and some
* tokens are permanently referenced by the application, there can
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BufferedHeader.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BufferedHeader.java
index 0f029ede3..7f270bf46 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BufferedHeader.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/BufferedHeader.java
@@ -81,7 +81,7 @@ public class BufferedHeader implements FormattedHeader, Cloneable, Serializable
("Invalid header: " + buffer.toString());
}
final String s = buffer.substringTrimmed(0, colon);
- if (s.length() == 0) {
+ if (s.isEmpty()) {
throw new ParseException
("Invalid header: " + buffer.toString());
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/HeaderGroup.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/HeaderGroup.java
index 5210a4b99..84894931e 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/HeaderGroup.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/HeaderGroup.java
@@ -49,7 +49,7 @@ public class HeaderGroup implements Cloneable, Serializable {
private static final long serialVersionUID = 2608834160639271617L;
- private final Header[] EMPTY = new Header[] {};
+ private static final Header[] EMPTY = new Header[] {};
/** The list of headers for this group, in the order in which they were added */
private final List headers;
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/HeaderValueParser.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/HeaderValueParser.java
index 26933d481..04e02dd99 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/HeaderValueParser.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/HeaderValueParser.java
@@ -68,6 +68,12 @@ public interface HeaderValueParser {
* element or param will be stored as the empty {@link String};
* if the "=" is also missing null will be stored instead.
*
+ *
+ * Note that this parser does not apply to list-typed HTTP header fields in
+ * general; it is only suitable for fields that use the syntax described
+ * above. Counter-examples are "Link" (RFC 8288), "If-None-Match" (RFC 7232)
+ * or "Dav" (RFC 4918).
+ *
*
* @param buffer buffer holding the header value to parse
* @param cursor the parser cursor containing the current position and
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/LineFormatter.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/LineFormatter.java
index 57441704d..090fb0889 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/LineFormatter.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/LineFormatter.java
@@ -28,7 +28,6 @@
package com.fr.third.org.apache.http.message;
import com.fr.third.org.apache.http.Header;
-import com.fr.third.org.apache.http.ParseException;
import com.fr.third.org.apache.http.ProtocolVersion;
import com.fr.third.org.apache.http.RequestLine;
import com.fr.third.org.apache.http.StatusLine;
@@ -102,7 +101,7 @@ public interface LineFormatter {
*
* @return the formatted status line
*
- * @throws ParseException in case of a parse error
+ * @throws com.fr.third.org.apache.http.ParseException in case of a parse error
*/
CharArrayBuffer formatStatusLine(CharArrayBuffer buffer,
StatusLine statline);
@@ -125,7 +124,7 @@ public interface LineFormatter {
* @return a buffer holding the formatted header, never {@code null}.
* The returned buffer may be different from the argument buffer.
*
- * @throws ParseException in case of a parse error
+ * @throws com.fr.third.org.apache.http.ParseException in case of a parse error
*/
CharArrayBuffer formatHeader(CharArrayBuffer buffer,
Header header);
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/TokenParser.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/TokenParser.java
index 1979c894c..1cb4749f8 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/TokenParser.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/message/TokenParser.java
@@ -158,9 +158,8 @@ public class TokenParser {
final char current = buf.charAt(i);
if (!isWhitespace(current)) {
break;
- } else {
- pos++;
}
+ pos++;
}
cursor.updatePos(pos);
}
@@ -184,10 +183,9 @@ public class TokenParser {
final char current = buf.charAt(i);
if ((delimiters != null && delimiters.get(current)) || isWhitespace(current)) {
break;
- } else {
- pos++;
- dst.append(current);
}
+ pos++;
+ dst.append(current);
}
cursor.updatePos(pos);
}
@@ -212,10 +210,9 @@ public class TokenParser {
if ((delimiters != null && delimiters.get(current))
|| isWhitespace(current) || current == DQUOTE) {
break;
- } else {
- pos++;
- dst.append(current);
}
+ pos++;
+ dst.append(current);
}
cursor.updatePos(pos);
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/AbstractHttpParams.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/AbstractHttpParams.java
index 83d9c3546..b850ef77a 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/AbstractHttpParams.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/AbstractHttpParams.java
@@ -36,8 +36,8 @@ import java.util.Set;
*
* @since 4.0
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Deprecated
public abstract class AbstractHttpParams implements HttpParams, HttpParamsNames {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/BasicHttpParams.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/BasicHttpParams.java
index cd029de15..ed3fbef5a 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/BasicHttpParams.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/BasicHttpParams.java
@@ -44,8 +44,8 @@ import java.util.concurrent.ConcurrentHashMap;
*
* @since 4.0
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Deprecated
@Contract(threading = ThreadingBehavior.SAFE)
@@ -84,9 +84,8 @@ public class BasicHttpParams extends AbstractHttpParams implements Serializable,
if (this.parameters.containsKey(name)) {
this.parameters.remove(name);
return true;
- } else {
- return false;
}
+ return false;
}
/**
@@ -192,4 +191,9 @@ public class BasicHttpParams extends AbstractHttpParams implements Serializable,
public Set getNames() {
return new HashSet(this.parameters.keySet());
}
+
+ @Override
+ public String toString() {
+ return "[parameters=" + parameters + "]";
+ }
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/CoreConnectionPNames.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/CoreConnectionPNames.java
index 5f501ae3a..8d9c2c8ed 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/CoreConnectionPNames.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/CoreConnectionPNames.java
@@ -32,8 +32,8 @@ package com.fr.third.org.apache.http.params;
*
* @since 4.0
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Deprecated
public interface CoreConnectionPNames {
@@ -48,7 +48,7 @@ public interface CoreConnectionPNames {
*
* @see java.net.SocketOptions#SO_TIMEOUT
*/
- public static final String SO_TIMEOUT = "http.socket.timeout";
+ String SO_TIMEOUT = "http.socket.timeout";
/**
* Determines whether Nagle's algorithm is to be used. The Nagle's algorithm
@@ -62,7 +62,7 @@ public interface CoreConnectionPNames {
*
* @see java.net.SocketOptions#TCP_NODELAY
*/
- public static final String TCP_NODELAY = "http.tcp.nodelay";
+ String TCP_NODELAY = "http.tcp.nodelay";
/**
* Determines the size of the internal socket buffer used to buffer data
@@ -71,7 +71,7 @@ public interface CoreConnectionPNames {
* This parameter expects a value of type {@link Integer}.
*
*/
- public static final String SOCKET_BUFFER_SIZE = "http.socket.buffer-size";
+ String SOCKET_BUFFER_SIZE = "http.socket.buffer-size";
/**
* Sets SO_LINGER with the specified linger time in seconds. The maximum
@@ -83,7 +83,7 @@ public interface CoreConnectionPNames {
*
* @see java.net.SocketOptions#SO_LINGER
*/
- public static final String SO_LINGER = "http.socket.linger";
+ String SO_LINGER = "http.socket.linger";
/**
* Defines whether the socket can be bound even though a previous connection is
@@ -95,7 +95,7 @@ public interface CoreConnectionPNames {
*
* @since 4.1
*/
- public static final String SO_REUSEADDR = "http.socket.reuseaddr";
+ String SO_REUSEADDR = "http.socket.reuseaddr";
/**
* Determines the timeout in milliseconds until a connection is established.
@@ -107,7 +107,7 @@ public interface CoreConnectionPNames {
* This parameter expects a value of type {@link Integer}.
*
*/
- public static final String CONNECTION_TIMEOUT = "http.connection.timeout";
+ String CONNECTION_TIMEOUT = "http.connection.timeout";
/**
* Determines whether stale connection check is to be used. The stale
@@ -118,7 +118,7 @@ public interface CoreConnectionPNames {
* This parameter expects a value of type {@link Boolean}.
*
*/
- public static final String STALE_CONNECTION_CHECK = "http.connection.stalecheck";
+ String STALE_CONNECTION_CHECK = "http.connection.stalecheck";
/**
* Determines the maximum line length limit. If set to a positive value,
@@ -128,7 +128,7 @@ public interface CoreConnectionPNames {
* This parameter expects a value of type {@link Integer}.
*
*/
- public static final String MAX_LINE_LENGTH = "http.connection.max-line-length";
+ String MAX_LINE_LENGTH = "http.connection.max-line-length";
/**
* Determines the maximum HTTP header count allowed. If set to a positive
@@ -139,7 +139,7 @@ public interface CoreConnectionPNames {
* This parameter expects a value of type {@link Integer}.
*
*/
- public static final String MAX_HEADER_COUNT = "http.connection.max-header-count";
+ String MAX_HEADER_COUNT = "http.connection.max-header-count";
/**
* Defines the size limit below which data chunks should be buffered in a session I/O buffer
@@ -152,7 +152,7 @@ public interface CoreConnectionPNames {
*
* @since 4.1
*/
- public static final String MIN_CHUNK_LIMIT = "http.connection.min-chunk-limit";
+ String MIN_CHUNK_LIMIT = "http.connection.min-chunk-limit";
/**
@@ -165,6 +165,6 @@ public interface CoreConnectionPNames {
* @see java.net.SocketOptions#SO_KEEPALIVE
* @since 4.2
*/
- public static final String SO_KEEPALIVE = "http.socket.keepalive";
+ String SO_KEEPALIVE = "http.socket.keepalive";
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/CoreProtocolPNames.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/CoreProtocolPNames.java
index 0202c5f56..d8d9870b9 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/CoreProtocolPNames.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/params/CoreProtocolPNames.java
@@ -27,26 +27,24 @@
package com.fr.third.org.apache.http.params;
-import com.fr.third.org.apache.http.ProtocolVersion;
-
/**
* Defines parameter names for protocol execution in HttpCore.
*
* @since 4.0
*
- * @deprecated (4.3) use configuration classes provided 'com.fr.third.org.apache.http.config'
- * and 'com.fr.third.org.apache.http.client.config'
+ * @deprecated (4.3) use configuration classes provided 'org.apache.http.config'
+ * and 'org.apache.http.client.config'
*/
@Deprecated
public interface CoreProtocolPNames {
/**
- * Defines the {@link ProtocolVersion} used per default.
+ * Defines the {@link com.fr.third.org.apache.http.ProtocolVersion} used per default.
*
- * This parameter expects a value of type {@link ProtocolVersion}.
+ * This parameter expects a value of type {@link com.fr.third.org.apache.http.ProtocolVersion}.
*
*/
- public static final String PROTOCOL_VERSION = "http.protocol.version";
+ String PROTOCOL_VERSION = "http.protocol.version";
/**
* Defines the charset to be used for encoding HTTP protocol elements.
@@ -54,7 +52,7 @@ public interface CoreProtocolPNames {
* This parameter expects a value of type {@link String}.
*
*/
- public static final String HTTP_ELEMENT_CHARSET = "http.protocol.element-charset";
+ String HTTP_ELEMENT_CHARSET = "http.protocol.element-charset";
/**
* Defines the charset to be used per default for encoding content body.
@@ -62,7 +60,7 @@ public interface CoreProtocolPNames {
* This parameter expects a value of type {@link String}.
*
*/
- public static final String HTTP_CONTENT_CHARSET = "http.protocol.content-charset";
+ String HTTP_CONTENT_CHARSET = "http.protocol.content-charset";
/**
* Defines the content of the {@code User-Agent} header.
@@ -70,7 +68,7 @@ public interface CoreProtocolPNames {
* This parameter expects a value of type {@link String}.
*
*/
- public static final String USER_AGENT = "http.useragent";
+ String USER_AGENT = "http.useragent";
/**
* Defines the content of the {@code Server} header.
@@ -78,7 +76,7 @@ public interface CoreProtocolPNames {
* This parameter expects a value of type {@link String}.
*
*/
- public static final String ORIGIN_SERVER = "http.origin-server";
+ String ORIGIN_SERVER = "http.origin-server";
/**
* Defines whether responses with an invalid {@code Transfer-Encoding}
@@ -87,7 +85,7 @@ public interface CoreProtocolPNames {
* This parameter expects a value of type {@link Boolean}.
*
*/
- public static final String STRICT_TRANSFER_ENCODING = "http.protocol.strict-transfer-encoding";
+ String STRICT_TRANSFER_ENCODING = "http.protocol.strict-transfer-encoding";
/**
*
@@ -114,7 +112,7 @@ public interface CoreProtocolPNames {
*
* This parameter expects a value of type {@link Boolean}.
*/
- public static final String USE_EXPECT_CONTINUE = "http.protocol.expect-continue";
+ String USE_EXPECT_CONTINUE = "http.protocol.expect-continue";
/**
*
@@ -124,7 +122,7 @@ public interface CoreProtocolPNames {
*
* This parameter expects a value of type {@link Integer}.
*/
- public static final String WAIT_FOR_CONTINUE = "http.protocol.wait-for-continue";
+ String WAIT_FOR_CONTINUE = "http.protocol.wait-for-continue";
/**
*
@@ -136,7 +134,7 @@ public interface CoreProtocolPNames {
*
* @since 4.2
*/
- public static final String HTTP_MALFORMED_INPUT_ACTION = "http.malformed.input.action";
+ String HTTP_MALFORMED_INPUT_ACTION = "http.malformed.input.action";
/**
*
@@ -190,57 +197,60 @@ public abstract class AbstractConnPool>
return new Future() {
- private volatile boolean cancelled;
- private volatile boolean done;
- private volatile E entry;
+ private final AtomicBoolean cancelled = new AtomicBoolean(false);
+ private final AtomicBoolean done = new AtomicBoolean(false);
+ private final AtomicReference entryRef = new AtomicReference(null);
@Override
public boolean cancel(final boolean mayInterruptIfRunning) {
- cancelled = true;
- lock.lock();
- try {
- condition.signalAll();
- } finally {
- lock.unlock();
- }
- synchronized (this) {
- final boolean result = !done;
- done = true;
+ if (done.compareAndSet(false, true)) {
+ cancelled.set(true);
+ lock.lock();
+ try {
+ condition.signalAll();
+ } finally {
+ lock.unlock();
+ }
if (callback != null) {
callback.cancelled();
}
- return result;
+ return true;
}
+ return false;
}
@Override
public boolean isCancelled() {
- return cancelled;
+ return cancelled.get();
}
@Override
public boolean isDone() {
- return done;
+ return done.get();
}
@Override
public E get() throws InterruptedException, ExecutionException {
try {
return get(0L, TimeUnit.MILLISECONDS);
- } catch (TimeoutException ex) {
+ } catch (final TimeoutException ex) {
throw new ExecutionException(ex);
}
}
@Override
- public E get(final long timeout, final TimeUnit tunit) throws InterruptedException, ExecutionException, TimeoutException {
- if (entry != null) {
- return entry;
- }
- synchronized (this) {
- try {
- for (;;) {
- final E leasedEntry = getPoolEntryBlocking(route, state, timeout, tunit, this);
+ public E get(final long timeout, final TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
+ for (;;) {
+ synchronized (this) {
+ try {
+ final E entry = entryRef.get();
+ if (entry != null) {
+ return entry;
+ }
+ if (done.get()) {
+ throw new ExecutionException(operationAborted());
+ }
+ final E leasedEntry = getPoolEntryBlocking(route, state, timeout, timeUnit, this);
if (validateAfterInactivity > 0) {
if (leasedEntry.getUpdated() + validateAfterInactivity <= System.currentTimeMillis()) {
if (!validate(leasedEntry)) {
@@ -250,20 +260,26 @@ public abstract class AbstractConnPool>
}
}
}
- entry = leasedEntry;
- done = true;
- onLease(entry);
- if (callback != null) {
- callback.completed(entry);
+ if (done.compareAndSet(false, true)) {
+ entryRef.set(leasedEntry);
+ done.set(true);
+ onLease(leasedEntry);
+ if (callback != null) {
+ callback.completed(leasedEntry);
+ }
+ return leasedEntry;
+ } else {
+ release(leasedEntry, true);
+ throw new ExecutionException(operationAborted());
}
- return entry;
- }
- } catch (IOException ex) {
- done = true;
- if (callback != null) {
- callback.failed(ex);
+ } catch (final IOException ex) {
+ if (done.compareAndSet(false, true)) {
+ if (callback != null) {
+ callback.failed(ex);
+ }
+ }
+ throw new ExecutionException(ex);
}
- throw new ExecutionException(ex);
}
}
}
@@ -293,19 +309,22 @@ public abstract class AbstractConnPool>
private E getPoolEntryBlocking(
final T route, final Object state,
- final long timeout, final TimeUnit tunit,
- final Future future) throws IOException, InterruptedException, TimeoutException {
+ final long timeout, final TimeUnit timeUnit,
+ final Future future) throws IOException, InterruptedException, ExecutionException, TimeoutException {
Date deadline = null;
if (timeout > 0) {
- deadline = new Date (System.currentTimeMillis() + tunit.toMillis(timeout));
+ deadline = new Date (System.currentTimeMillis() + timeUnit.toMillis(timeout));
}
this.lock.lock();
try {
- final RouteSpecificPool pool = getPool(route);
E entry;
for (;;) {
Asserts.check(!this.isShutDown, "Connection pool shut down");
+ if (future.isCancelled()) {
+ throw new ExecutionException(operationAborted());
+ }
+ final RouteSpecificPool pool = getPool(route);
for (;;) {
entry = pool.getFree(state);
if (entry == null) {
@@ -366,9 +385,6 @@ public abstract class AbstractConnPool>
boolean success = false;
try {
- if (future.isCancelled()) {
- throw new InterruptedException("Operation interrupted");
- }
pool.queue(future);
this.pending.add(future);
if (deadline != null) {
@@ -378,7 +394,7 @@ public abstract class AbstractConnPool>
success = true;
}
if (future.isCancelled()) {
- throw new InterruptedException("Operation interrupted");
+ throw new ExecutionException(operationAborted());
}
} finally {
// In case of 'success', we were woken up by the
@@ -429,11 +445,7 @@ public abstract class AbstractConnPool>
private int getMax(final T route) {
final Integer v = this.maxPerRoute.get(route);
- if (v != null) {
- return v.intValue();
- } else {
- return this.defaultMaxPerRoute;
- }
+ return v != null ? v.intValue() : this.defaultMaxPerRoute;
}
@Override
@@ -481,10 +493,13 @@ public abstract class AbstractConnPool>
@Override
public void setMaxPerRoute(final T route, final int max) {
Args.notNull(route, "Route");
- Args.positive(max, "Max per route value");
this.lock.lock();
try {
- this.maxPerRoute.put(route, Integer.valueOf(max));
+ if (max > -1) {
+ this.maxPerRoute.put(route, Integer.valueOf(max));
+ } else {
+ this.maxPerRoute.remove(route);
+ }
} finally {
this.lock.unlock();
}
@@ -604,11 +619,11 @@ public abstract class AbstractConnPool>
* of time and evicts them from the pool.
*
* @param idletime maximum idle time.
- * @param tunit time unit.
+ * @param timeUnit time unit.
*/
- public void closeIdle(final long idletime, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
- long time = tunit.toMillis(idletime);
+ public void closeIdle(final long idletime, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
+ long time = timeUnit.toMillis(idletime);
if (time < 0) {
time = 0;
}
@@ -660,15 +675,20 @@ public abstract class AbstractConnPool>
@Override
public String toString() {
- final StringBuilder buffer = new StringBuilder();
- buffer.append("[leased: ");
- buffer.append(this.leased);
- buffer.append("][available: ");
- buffer.append(this.available);
- buffer.append("][pending: ");
- buffer.append(this.pending);
- buffer.append("]");
- return buffer.toString();
+ this.lock.lock();
+ try {
+ final StringBuilder buffer = new StringBuilder();
+ buffer.append("[leased: ");
+ buffer.append(this.leased);
+ buffer.append("][available: ");
+ buffer.append(this.available);
+ buffer.append("][pending: ");
+ buffer.append(this.pending);
+ buffer.append("]");
+ return buffer.toString();
+ } finally {
+ this.lock.unlock();
+ }
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/pool/PoolEntry.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/pool/PoolEntry.java
index a782644c9..0edc8f2b6 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/pool/PoolEntry.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/pool/PoolEntry.java
@@ -26,12 +26,12 @@
*/
package com.fr.third.org.apache.http.pool;
-import java.util.concurrent.TimeUnit;
-
import com.fr.third.org.apache.http.annotation.Contract;
import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.util.Args;
+import java.util.concurrent.TimeUnit;
+
/**
* Pool entry containing a pool connection object along with its route.
*
@@ -71,21 +71,23 @@ public abstract class PoolEntry {
* @param conn the connection.
* @param timeToLive maximum time to live. May be zero if the connection
* does not have an expiry deadline.
- * @param tunit time unit.
+ * @param timeUnit time unit.
*/
public PoolEntry(final String id, final T route, final C conn,
- final long timeToLive, final TimeUnit tunit) {
+ final long timeToLive, final TimeUnit timeUnit) {
super();
Args.notNull(route, "Route");
Args.notNull(conn, "Connection");
- Args.notNull(tunit, "Time unit");
+ Args.notNull(timeUnit, "Time unit");
this.id = id;
this.route = route;
this.conn = conn;
this.created = System.currentTimeMillis();
this.updated = this.created;
if (timeToLive > 0) {
- this.validityDeadline = this.created + tunit.toMillis(timeToLive);
+ final long deadline = this.created + timeUnit.toMillis(timeToLive);
+ // If the above overflows then default to Long.MAX_VALUE
+ this.validityDeadline = deadline > 0 ? deadline : Long.MAX_VALUE;
} else {
this.validityDeadline = Long.MAX_VALUE;
}
@@ -150,12 +152,12 @@ public abstract class PoolEntry {
return this.expiry;
}
- public synchronized void updateExpiry(final long time, final TimeUnit tunit) {
- Args.notNull(tunit, "Time unit");
+ public synchronized void updateExpiry(final long time, final TimeUnit timeUnit) {
+ Args.notNull(timeUnit, "Time unit");
this.updated = System.currentTimeMillis();
final long newExpiry;
if (time > 0) {
- newExpiry = this.updated + tunit.toMillis(time);
+ newExpiry = this.updated + timeUnit.toMillis(time);
} else {
newExpiry = Long.MAX_VALUE;
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/pool/RouteSpecificPool.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/pool/RouteSpecificPool.java
index 727b271b8..5b6e4d900 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/pool/RouteSpecificPool.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/pool/RouteSpecificPool.java
@@ -99,11 +99,7 @@ abstract class RouteSpecificPool> {
}
public E getLastUsed() {
- if (!this.available.isEmpty()) {
- return this.available.getLast();
- } else {
- return null;
- }
+ return this.available.isEmpty() ? null : this.available.getLast();
}
public boolean remove(final E entry) {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HTTP.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HTTP.java
index c86dedd96..489a1f3bf 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HTTP.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HTTP.java
@@ -74,51 +74,61 @@ public final class HTTP {
*/
@Deprecated
public static final String UTF_8 = "UTF-8";
+
/**
* @deprecated (4.2)
*/
@Deprecated
public static final String UTF_16 = "UTF-16";
+
/**
* @deprecated (4.2)
*/
@Deprecated
public static final String US_ASCII = "US-ASCII";
+
/**
* @deprecated (4.2)
*/
@Deprecated
public static final String ASCII = "ASCII";
+
/**
* @deprecated (4.2)
*/
@Deprecated
public static final String ISO_8859_1 = "ISO-8859-1";
+
/**
* @deprecated (4.2)
*/
@Deprecated
public static final String DEFAULT_CONTENT_CHARSET = ISO_8859_1;
+
/**
* @deprecated (4.2)
*/
@Deprecated
public static final String DEFAULT_PROTOCOL_CHARSET = US_ASCII;
+
/**
* @deprecated (4.2)
*/
@Deprecated
public final static String OCTET_STREAM_TYPE = "application/octet-stream";
+
/**
* @deprecated (4.2)
*/
@Deprecated
public final static String PLAIN_TEXT_TYPE = "text/plain";
+
/**
* @deprecated (4.2)
*/
@Deprecated
public final static String CHARSET_PARAM = "; charset=";
+
/**
* @deprecated (4.2)
*/
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpContext.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpContext.java
index 08248d164..6738c1ce4 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpContext.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpContext.java
@@ -36,17 +36,19 @@ package com.fr.third.org.apache.http.protocol;
* to store a processing state for one message or several consecutive messages.
* Multiple logically related messages can participate in a logical session
* if the same context is reused between consecutive messages.
- *
/
+ *
+ *
* IMPORTANT: Please note HTTP context implementation, even when thread safe,
* may not be used concurrently by multiple threads, as the context may contain
* thread unsafe attributes.
+ *
*
* @since 4.0
*/
public interface HttpContext {
/** The prefix reserved for use by HTTP components. "http." */
- public static final String RESERVED_PREFIX = "http.";
+ String RESERVED_PREFIX = "http.";
/**
* Obtains attribute with the given name.
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpCoreContext.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpCoreContext.java
index b39597d5a..967daf27c 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpCoreContext.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpCoreContext.java
@@ -42,25 +42,25 @@ import com.fr.third.org.apache.http.util.Args;
public class HttpCoreContext implements HttpContext {
/**
- * Attribute name of a {@link HttpConnection} object that
+ * Attribute name of a {@link com.fr.third.org.apache.http.HttpConnection} object that
* represents the actual HTTP connection.
*/
public static final String HTTP_CONNECTION = "http.connection";
/**
- * Attribute name of a {@link HttpRequest} object that
+ * Attribute name of a {@link com.fr.third.org.apache.http.HttpRequest} object that
* represents the actual HTTP request.
*/
public static final String HTTP_REQUEST = "http.request";
/**
- * Attribute name of a {@link HttpResponse} object that
+ * Attribute name of a {@link com.fr.third.org.apache.http.HttpResponse} object that
* represents the actual HTTP response.
*/
public static final String HTTP_RESPONSE = "http.response";
/**
- * Attribute name of a {@link HttpHost} object that
+ * Attribute name of a {@link com.fr.third.org.apache.http.HttpHost} object that
* represents the connection target.
*/
public static final String HTTP_TARGET_HOST = "http.target_host";
@@ -78,11 +78,9 @@ public class HttpCoreContext implements HttpContext {
public static HttpCoreContext adapt(final HttpContext context) {
Args.notNull(context, "HTTP context");
- if (context instanceof HttpCoreContext) {
- return (HttpCoreContext) context;
- } else {
- return new HttpCoreContext(context);
- }
+ return context instanceof HttpCoreContext
+ ? (HttpCoreContext) context
+ : new HttpCoreContext(context);
}
private final HttpContext context;
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpRequestExecutor.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpRequestExecutor.java
index da42e024c..eb08a3d53 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpRequestExecutor.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpRequestExecutor.java
@@ -29,8 +29,6 @@ package com.fr.third.org.apache.http.protocol;
import java.io.IOException;
-import com.fr.third.org.apache.http.HttpEntity;
-import com.fr.third.org.apache.http.util.EntityUtils;
import com.fr.third.org.apache.http.HttpClientConnection;
import com.fr.third.org.apache.http.HttpEntityEnclosingRequest;
import com.fr.third.org.apache.http.HttpException;
@@ -40,8 +38,8 @@ import com.fr.third.org.apache.http.HttpStatus;
import com.fr.third.org.apache.http.HttpVersion;
import com.fr.third.org.apache.http.ProtocolException;
import com.fr.third.org.apache.http.ProtocolVersion;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.util.Args;
/**
@@ -273,10 +271,13 @@ public class HttpRequestExecutor {
while (response == null || statusCode < HttpStatus.SC_OK) {
response = conn.receiveResponseHeader();
+ statusCode = response.getStatusLine().getStatusCode();
+ if (statusCode < HttpStatus.SC_CONTINUE) {
+ throw new ProtocolException("Invalid response: " + response.getStatusLine());
+ }
if (canResponseHaveBody(request, response)) {
conn.receiveResponseEntity(response);
}
- statusCode = response.getStatusLine().getStatusCode();
} // while intermediate response
@@ -290,7 +291,7 @@ public class HttpRequestExecutor {
* This method does not read the response entity, if any.
* The connection over which content of the response entity is being
* streamed from cannot be reused until
- * {@link EntityUtils#consume(HttpEntity)}
+ * {@link com.fr.third.org.apache.http.util.EntityUtils#consume(org.apache.http.HttpEntity)}
* has been invoked.
*
* @param response the response object to post-process
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpService.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpService.java
index b86ef2cd6..c3d4851bf 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpService.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/HttpService.java
@@ -442,6 +442,8 @@ public class HttpService {
/**
* Adaptor class to transition from HttpRequestHandlerResolver to HttpRequestHandlerMapper.
+ *
+ * @deprecated Do not use.
*/
@Deprecated
private static class HttpRequestHandlerResolverAdapter implements HttpRequestHandlerMapper {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/RequestConnControl.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/RequestConnControl.java
index a61318879..613c3255d 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/RequestConnControl.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/RequestConnControl.java
@@ -32,8 +32,8 @@ import java.io.IOException;
import com.fr.third.org.apache.http.HttpException;
import com.fr.third.org.apache.http.HttpRequest;
import com.fr.third.org.apache.http.HttpRequestInterceptor;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.util.Args;
/**
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/RequestExpectContinue.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/RequestExpectContinue.java
index 3f925ff8d..fd552735e 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/RequestExpectContinue.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/RequestExpectContinue.java
@@ -55,7 +55,7 @@ public class RequestExpectContinue implements HttpRequestInterceptor {
private final boolean activeByDefault;
/**
- * @deprecated (4.3) use {@link RequestExpectContinue#RequestExpectContinue(boolean)}
+ * @deprecated (4.3) use {@link com.fr.third.org.apache.http.protocol.RequestExpectContinue#RequestExpectContinue(boolean)}
*/
@Deprecated
public RequestExpectContinue() {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/RequestTargetHost.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/RequestTargetHost.java
index 7c7c71cbf..5ed8ee4c3 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/RequestTargetHost.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/RequestTargetHost.java
@@ -61,7 +61,7 @@ public class RequestTargetHost implements HttpRequestInterceptor {
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
- final HttpCoreContext corecontext = HttpCoreContext.adapt(context);
+ final HttpCoreContext coreContext = HttpCoreContext.adapt(context);
final ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
final String method = request.getRequestLine().getMethod();
@@ -70,27 +70,26 @@ public class RequestTargetHost implements HttpRequestInterceptor {
}
if (!request.containsHeader(HTTP.TARGET_HOST)) {
- HttpHost targethost = corecontext.getTargetHost();
- if (targethost == null) {
- final HttpConnection conn = corecontext.getConnection();
+ HttpHost targetHost = coreContext.getTargetHost();
+ if (targetHost == null) {
+ final HttpConnection conn = coreContext.getConnection();
if (conn instanceof HttpInetConnection) {
// Populate the context with a default HTTP host based on the
// inet address of the target host
final InetAddress address = ((HttpInetConnection) conn).getRemoteAddress();
final int port = ((HttpInetConnection) conn).getRemotePort();
if (address != null) {
- targethost = new HttpHost(address.getHostName(), port);
+ targetHost = new HttpHost(address.getHostName(), port);
}
}
- if (targethost == null) {
+ if (targetHost == null) {
if (ver.lessEquals(HttpVersion.HTTP_1_0)) {
return;
- } else {
- throw new ProtocolException("Target host missing");
}
+ throw new ProtocolException("Target host missing");
}
}
- request.addHeader(HTTP.TARGET_HOST, targethost.toHostString());
+ request.addHeader(HTTP.TARGET_HOST, targetHost.toHostString());
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/UriHttpRequestHandlerMapper.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/UriHttpRequestHandlerMapper.java
index 0ca0a6c1e..2996c356e 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/UriHttpRequestHandlerMapper.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/UriHttpRequestHandlerMapper.java
@@ -90,11 +90,11 @@ public class UriHttpRequestHandlerMapper implements HttpRequestHandlerMapper {
*/
protected String getRequestPath(final HttpRequest request) {
String uriPath = request.getRequestLine().getUri();
- int index = uriPath.indexOf("?");
+ int index = uriPath.indexOf('?');
if (index != -1) {
uriPath = uriPath.substring(0, index);
} else {
- index = uriPath.indexOf("#");
+ index = uriPath.indexOf('#');
if (index != -1) {
uriPath = uriPath.substring(0, index);
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/UriPatternMatcher.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/UriPatternMatcher.java
index 49e7a4a59..2eb9b9816 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/UriPatternMatcher.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/protocol/UriPatternMatcher.java
@@ -27,11 +27,14 @@
package com.fr.third.org.apache.http.protocol;
-import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
-import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.annotation.Contract;
+import com.fr.third.org.apache.http.annotation.ThreadingBehavior;
import com.fr.third.org.apache.http.util.Args;
/**
@@ -40,13 +43,14 @@ import com.fr.third.org.apache.http.util.Args;
* Patterns may have three formats:
*
*
{@code *}
- *
{@code *<uri>}
- *
{@code <uri>*}
+ *
{@code *}
+ *
{@code *}
*
*
* This class can be used to resolve an object matching a particular request
* URI.
*
+ * @param The type of registered objects.
* @since 4.0
*/
@Contract(threading = ThreadingBehavior.SAFE)
@@ -56,7 +60,19 @@ public class UriPatternMatcher {
public UriPatternMatcher() {
super();
- this.map = new HashMap();
+ this.map = new LinkedHashMap();
+ }
+
+ /**
+ * Returns a {@link Set} view of the mappings contained in this matcher.
+ *
+ * @return a set view of the mappings contained in this matcher.
+ *
+ * @see Map#entrySet()
+ * @since 4.4.9
+ */
+ public synchronized Set> entrySet() {
+ return new HashSet>(map.entrySet());
}
/**
@@ -149,11 +165,10 @@ public class UriPatternMatcher {
protected boolean matchUriRequestPattern(final String pattern, final String path) {
if (pattern.equals("*")) {
return true;
- } else {
- return
- (pattern.endsWith("*") && path.startsWith(pattern.substring(0, pattern.length() - 1))) ||
- (pattern.startsWith("*") && path.endsWith(pattern.substring(1, pattern.length())));
}
+ return
+ (pattern.endsWith("*") && path.startsWith(pattern.substring(0, pattern.length() - 1))) ||
+ (pattern.startsWith("*") && path.endsWith(pattern.substring(1, pattern.length())));
}
@Override
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ssl/SSLContextBuilder.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ssl/SSLContextBuilder.java
index a2b7db7d7..a2327606d 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ssl/SSLContextBuilder.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ssl/SSLContextBuilder.java
@@ -39,11 +39,14 @@ import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.Principal;
import java.security.PrivateKey;
+import java.security.Provider;
import java.security.SecureRandom;
+import java.security.Security;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
@@ -61,7 +64,7 @@ import javax.net.ssl.X509TrustManager;
import com.fr.third.org.apache.http.util.Args;
/**
- * Builder for {@link javax.net.ssl.SSLContext} instances.
+ * Builder for {@link SSLContext} instances.
*
* Please note: the default Oracle JSSE implementation of {@link SSLContext#init(KeyManager[], TrustManager[], SecureRandom)}
* accepts multiple key and trust managers, however only only first matching type is ever used.
@@ -69,7 +72,9 @@ import com.fr.third.org.apache.http.util.Args;
*
* SSLContext.html#init
*
- *
+ *
+ * TODO Specify which Oracle JSSE versions the above has been verified.
+ *
* @since 4.4
*/
public class SSLContextBuilder {
@@ -77,9 +82,13 @@ public class SSLContextBuilder {
static final String TLS = "TLS";
private String protocol;
- private final Set keymanagers;
- private final Set trustmanagers;
+ private final Set keyManagers;
+ private String keyManagerFactoryAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
+ private String keyStoreType = KeyStore.getDefaultType();
+ private final Set trustManagers;
+ private String trustManagerFactoryAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
private SecureRandom secureRandom;
+ private Provider provider;
public static SSLContextBuilder create() {
return new SSLContextBuilder();
@@ -87,25 +96,132 @@ public class SSLContextBuilder {
public SSLContextBuilder() {
super();
- this.keymanagers = new LinkedHashSet();
- this.trustmanagers = new LinkedHashSet();
+ this.keyManagers = new LinkedHashSet();
+ this.trustManagers = new LinkedHashSet();
}
+ /**
+ * Sets the SSLContext protocol algorithm name.
+ *
+ * @param protocol
+ * the SSLContext protocol algorithm name of the requested protocol. See
+ * the SSLContext section in the Java
+ * Cryptography Architecture Standard Algorithm Name
+ * Documentation for more information.
+ * @return this builder
+ * @see Java
+ * Cryptography Architecture Standard Algorithm Name Documentation
+ * @deprecated Use {@link #setProtocol(String)}.
+ */
+ @Deprecated
public SSLContextBuilder useProtocol(final String protocol) {
this.protocol = protocol;
return this;
}
+ /**
+ * Sets the SSLContext protocol algorithm name.
+ *
+ * @param protocol
+ * the SSLContext protocol algorithm name of the requested protocol. See
+ * the SSLContext section in the Java
+ * Cryptography Architecture Standard Algorithm Name
+ * Documentation for more information.
+ * @return this builder
+ * @see Java
+ * Cryptography Architecture Standard Algorithm Name Documentation
+ * @since 4.4.7
+ */
+ public SSLContextBuilder setProtocol(final String protocol) {
+ this.protocol = protocol;
+ return this;
+ }
+
public SSLContextBuilder setSecureRandom(final SecureRandom secureRandom) {
this.secureRandom = secureRandom;
return this;
}
+ public SSLContextBuilder setProvider(final Provider provider) {
+ this.provider = provider;
+ return this;
+ }
+
+ public SSLContextBuilder setProvider(final String name) {
+ this.provider = Security.getProvider(name);
+ return this;
+ }
+
+ /**
+ * Sets the key store type.
+ *
+ * @param keyStoreType
+ * the SSLkey store type. See
+ * the KeyStore section in the Java
+ * Cryptography Architecture Standard Algorithm Name
+ * Documentation for more information.
+ * @return this builder
+ * @see Java
+ * Cryptography Architecture Standard Algorithm Name Documentation
+ * @since 4.4.7
+ */
+ public SSLContextBuilder setKeyStoreType(final String keyStoreType) {
+ this.keyStoreType = keyStoreType;
+ return this;
+ }
+
+ /**
+ * Sets the key manager factory algorithm name.
+ *
+ * @param keyManagerFactoryAlgorithm
+ * the key manager factory algorithm name of the requested protocol. See
+ * the KeyManagerFactory section in the Java
+ * Cryptography Architecture Standard Algorithm Name
+ * Documentation for more information.
+ * @return this builder
+ * @see Java
+ * Cryptography Architecture Standard Algorithm Name Documentation
+ * @since 4.4.7
+ */
+ public SSLContextBuilder setKeyManagerFactoryAlgorithm(final String keyManagerFactoryAlgorithm) {
+ this.keyManagerFactoryAlgorithm = keyManagerFactoryAlgorithm;
+ return this;
+ }
+
+ /**
+ * Sets the trust manager factory algorithm name.
+ *
+ * @param trustManagerFactoryAlgorithm
+ * the trust manager algorithm name of the requested protocol. See
+ * the TrustManagerFactory section in the Java
+ * Cryptography Architecture Standard Algorithm Name
+ * Documentation for more information.
+ * @return this builder
+ * @see Java
+ * Cryptography Architecture Standard Algorithm Name Documentation
+ * @since 4.4.7
+ */
+ public SSLContextBuilder setTrustManagerFactoryAlgorithm(final String trustManagerFactoryAlgorithm) {
+ this.trustManagerFactoryAlgorithm = trustManagerFactoryAlgorithm;
+ return this;
+ }
+
public SSLContextBuilder loadTrustMaterial(
final KeyStore truststore,
final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException {
- final TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(
- TrustManagerFactory.getDefaultAlgorithm());
+ final TrustManagerFactory tmfactory = TrustManagerFactory
+ .getInstance(trustManagerFactoryAlgorithm == null ? TrustManagerFactory.getDefaultAlgorithm()
+ : trustManagerFactoryAlgorithm);
tmfactory.init(truststore);
final TrustManager[] tms = tmfactory.getTrustManagers();
if (tms != null) {
@@ -113,14 +229,11 @@ public class SSLContextBuilder {
for (int i = 0; i < tms.length; i++) {
final TrustManager tm = tms[i];
if (tm instanceof X509TrustManager) {
- tms[i] = new TrustManagerDelegate(
- (X509TrustManager) tm, trustStrategy);
+ tms[i] = new TrustManagerDelegate((X509TrustManager) tm, trustStrategy);
}
}
}
- for (final TrustManager tm : tms) {
- this.trustmanagers.add(tm);
- }
+ Collections.addAll(this.trustManagers, tms);
}
return this;
}
@@ -135,12 +248,12 @@ public class SSLContextBuilder {
final char[] storePassword,
final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException {
Args.notNull(file, "Truststore file");
- final KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
- final FileInputStream instream = new FileInputStream(file);
+ final KeyStore trustStore = KeyStore.getInstance(keyStoreType);
+ final FileInputStream inStream = new FileInputStream(file);
try {
- trustStore.load(instream, storePassword);
+ trustStore.load(inStream, storePassword);
} finally {
- instream.close();
+ inStream.close();
}
return loadTrustMaterial(trustStore, trustStrategy);
}
@@ -161,12 +274,12 @@ public class SSLContextBuilder {
final char[] storePassword,
final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException {
Args.notNull(url, "Truststore URL");
- final KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
- final InputStream instream = url.openStream();
+ final KeyStore trustStore = KeyStore.getInstance(keyStoreType);
+ final InputStream inStream = url.openStream();
try {
- trustStore.load(instream, storePassword);
+ trustStore.load(inStream, storePassword);
} finally {
- instream.close();
+ inStream.close();
}
return loadTrustMaterial(trustStore, trustStrategy);
}
@@ -182,10 +295,11 @@ public class SSLContextBuilder {
final char[] keyPassword,
final PrivateKeyStrategy aliasStrategy)
throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
- final KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
- KeyManagerFactory.getDefaultAlgorithm());
+ final KeyManagerFactory kmfactory = KeyManagerFactory
+ .getInstance(keyManagerFactoryAlgorithm == null ? KeyManagerFactory.getDefaultAlgorithm()
+ : keyManagerFactoryAlgorithm);
kmfactory.init(keystore, keyPassword);
- final KeyManager[] kms = kmfactory.getKeyManagers();
+ final KeyManager[] kms = kmfactory.getKeyManagers();
if (kms != null) {
if (aliasStrategy != null) {
for (int i = 0; i < kms.length; i++) {
@@ -195,9 +309,7 @@ public class SSLContextBuilder {
}
}
}
- for (final KeyManager km : kms) {
- keymanagers.add(km);
- }
+ Collections.addAll(keyManagers, kms);
}
return this;
}
@@ -214,12 +326,12 @@ public class SSLContextBuilder {
final char[] keyPassword,
final PrivateKeyStrategy aliasStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException {
Args.notNull(file, "Keystore file");
- final KeyStore identityStore = KeyStore.getInstance(KeyStore.getDefaultType());
- final FileInputStream instream = new FileInputStream(file);
+ final KeyStore identityStore = KeyStore.getInstance(keyStoreType);
+ final FileInputStream inStream = new FileInputStream(file);
try {
- identityStore.load(instream, storePassword);
+ identityStore.load(inStream, storePassword);
} finally {
- instream.close();
+ inStream.close();
}
return loadKeyMaterial(identityStore, keyPassword, aliasStrategy);
}
@@ -237,12 +349,12 @@ public class SSLContextBuilder {
final char[] keyPassword,
final PrivateKeyStrategy aliasStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, CertificateException, IOException {
Args.notNull(url, "Keystore URL");
- final KeyStore identityStore = KeyStore.getInstance(KeyStore.getDefaultType());
- final InputStream instream = url.openStream();
+ final KeyStore identityStore = KeyStore.getInstance(keyStoreType);
+ final InputStream inStream = url.openStream();
try {
- identityStore.load(instream, storePassword);
+ identityStore.load(inStream, storePassword);
} finally {
- instream.close();
+ inStream.close();
}
return loadKeyMaterial(identityStore, keyPassword, aliasStrategy);
}
@@ -255,21 +367,26 @@ public class SSLContextBuilder {
}
protected void initSSLContext(
- final SSLContext sslcontext,
+ final SSLContext sslContext,
final Collection keyManagers,
final Collection trustManagers,
final SecureRandom secureRandom) throws KeyManagementException {
- sslcontext.init(
+ sslContext.init(
!keyManagers.isEmpty() ? keyManagers.toArray(new KeyManager[keyManagers.size()]) : null,
!trustManagers.isEmpty() ? trustManagers.toArray(new TrustManager[trustManagers.size()]) : null,
secureRandom);
}
public SSLContext build() throws NoSuchAlgorithmException, KeyManagementException {
- final SSLContext sslcontext = SSLContext.getInstance(
- this.protocol != null ? this.protocol : TLS);
- initSSLContext(sslcontext, keymanagers, trustmanagers, secureRandom);
- return sslcontext;
+ final SSLContext sslContext;
+ final String protocolStr = this.protocol != null ? this.protocol : TLS;
+ if (this.provider != null) {
+ sslContext = SSLContext.getInstance(protocolStr, this.provider);
+ } else {
+ sslContext = SSLContext.getInstance(protocolStr);
+ }
+ initSSLContext(sslContext, keyManagers, trustManagers, secureRandom);
+ return sslContext;
}
static class TrustManagerDelegate implements X509TrustManager {
@@ -395,4 +512,12 @@ public class SSLContextBuilder {
}
+ @Override
+ public String toString() {
+ return "[provider=" + provider + ", protocol=" + protocol + ", keyStoreType=" + keyStoreType
+ + ", keyManagerFactoryAlgorithm=" + keyManagerFactoryAlgorithm + ", keyManagers=" + keyManagers
+ + ", trustManagerFactoryAlgorithm=" + trustManagerFactoryAlgorithm + ", trustManagers=" + trustManagers
+ + ", secureRandom=" + secureRandom + "]";
+ }
+
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ssl/SSLContexts.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ssl/SSLContexts.java
index 8208e26a1..db367a19a 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ssl/SSLContexts.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/ssl/SSLContexts.java
@@ -33,7 +33,7 @@ import java.security.NoSuchAlgorithmException;
import javax.net.ssl.SSLContext;
/**
- * {@link javax.net.ssl.SSLContext} factory methods.
+ * {@link SSLContext} factory methods.
*
* @since 4.4
*/
@@ -48,9 +48,9 @@ public class SSLContexts {
*/
public static SSLContext createDefault() throws SSLInitializationException {
try {
- final SSLContext sslcontext = SSLContext.getInstance(SSLContextBuilder.TLS);
- sslcontext.init(null, null, null);
- return sslcontext;
+ final SSLContext sslContext = SSLContext.getInstance(SSLContextBuilder.TLS);
+ sslContext.init(null, null, null);
+ return sslContext;
} catch (final NoSuchAlgorithmException ex) {
throw new SSLInitializationException(ex.getMessage(), ex);
} catch (final KeyManagementException ex) {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/Args.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/Args.java
index e7658630d..c2df92dcd 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/Args.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/Args.java
@@ -80,6 +80,9 @@ public class Args {
if (argument == null) {
throw new IllegalArgumentException(name + " may not be null");
}
+ if (argument.length() == 0) {
+ throw new IllegalArgumentException(name + " may not be empty");
+ }
if (TextUtils.containsBlanks(argument)) {
throw new IllegalArgumentException(name + " may not contain blanks");
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/ByteArrayBuffer.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/ByteArrayBuffer.java
index c67aab166..90f51ad62 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/ByteArrayBuffer.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/ByteArrayBuffer.java
@@ -135,8 +135,16 @@ public final class ByteArrayBuffer implements Serializable {
if (newlen > this.buffer.length) {
expand(newlen);
}
+
for (int i1 = off, i2 = oldlen; i2 < newlen; i1++, i2++) {
- this.buffer[i2] = (byte) b[i1];
+ final int c = b[i1];
+ if ((c >= 0x20 && c <= 0x7E) || // Visible ASCII
+ (c >= 0xA0 && c <= 0xFF) || // Visible ISO-8859-1
+ c == 0x09) { // TAB
+ this.buffer[i2] = (byte) c;
+ } else {
+ this.buffer[i2] = '?';
+ }
}
this.len = newlen;
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/CharArrayBuffer.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/CharArrayBuffer.java
index b290679e4..6daa78592 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/CharArrayBuffer.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/CharArrayBuffer.java
@@ -257,6 +257,7 @@ public final class CharArrayBuffer implements CharSequence, Serializable {
* @throws IndexOutOfBoundsException if {@code index} is
* negative or greater than or equal to {@link #length()}.
*/
+ @Override
public char charAt(final int i) {
return this.buffer[i];
}
@@ -286,6 +287,7 @@ public final class CharArrayBuffer implements CharSequence, Serializable {
*
* @return the length of the buffer
*/
+ @Override
public int length() {
return this.len;
}
@@ -408,7 +410,7 @@ public final class CharArrayBuffer implements CharSequence, Serializable {
* @param beginIndex the beginning index, inclusive.
* @param endIndex the ending index, exclusive.
* @return the specified substring.
- * @exception StringIndexOutOfBoundsException if the
+ * @throws StringIndexOutOfBoundsException if the
* {@code beginIndex} is negative, or
* {@code endIndex} is larger than the length of this
* buffer, or {@code beginIndex} is larger than
@@ -437,7 +439,7 @@ public final class CharArrayBuffer implements CharSequence, Serializable {
* @param beginIndex the beginning index, inclusive.
* @param endIndex the ending index, exclusive.
* @return the specified substring.
- * @exception IndexOutOfBoundsException if the
+ * @throws IndexOutOfBoundsException if the
* {@code beginIndex} is negative, or
* {@code endIndex} is larger than the length of this
* buffer, or {@code beginIndex} is larger than
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/EntityUtils.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/EntityUtils.java
index 7de5eb8e0..f38e5efb8 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/EntityUtils.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/EntityUtils.java
@@ -50,6 +50,8 @@ import com.fr.third.org.apache.http.protocol.HTTP;
*/
public final class EntityUtils {
+ private static final int DEFAULT_BUFFER_SIZE = 4096;
+
private EntityUtils() {
}
@@ -83,9 +85,9 @@ public final class EntityUtils {
return;
}
if (entity.isStreaming()) {
- final InputStream instream = entity.getContent();
- if (instream != null) {
- instream.close();
+ final InputStream inStream = entity.getContent();
+ if (inStream != null) {
+ inStream.close();
}
}
}
@@ -119,26 +121,26 @@ public final class EntityUtils {
*/
public static byte[] toByteArray(final HttpEntity entity) throws IOException {
Args.notNull(entity, "Entity");
- final InputStream instream = entity.getContent();
- if (instream == null) {
+ final InputStream inStream = entity.getContent();
+ if (inStream == null) {
return null;
}
try {
Args.check(entity.getContentLength() <= Integer.MAX_VALUE,
"HTTP entity too large to be buffered in memory");
- int i = (int)entity.getContentLength();
- if (i < 0) {
- i = 4096;
+ int capacity = (int)entity.getContentLength();
+ if (capacity < 0) {
+ capacity = DEFAULT_BUFFER_SIZE;
}
- final ByteArrayBuffer buffer = new ByteArrayBuffer(i);
- final byte[] tmp = new byte[4096];
+ final ByteArrayBuffer buffer = new ByteArrayBuffer(capacity);
+ final byte[] tmp = new byte[DEFAULT_BUFFER_SIZE];
int l;
- while((l = instream.read(tmp)) != -1) {
+ while((l = inStream.read(tmp)) != -1) {
buffer.append(tmp, 0, l);
}
return buffer.toByteArray();
} finally {
- instream.close();
+ inStream.close();
}
}
@@ -196,16 +198,16 @@ public final class EntityUtils {
private static String toString(
final HttpEntity entity,
final ContentType contentType) throws IOException {
- final InputStream instream = entity.getContent();
- if (instream == null) {
+ final InputStream inStream = entity.getContent();
+ if (inStream == null) {
return null;
}
try {
Args.check(entity.getContentLength() <= Integer.MAX_VALUE,
"HTTP entity too large to be buffered in memory");
- int i = (int)entity.getContentLength();
- if (i < 0) {
- i = 4096;
+ int capacity = (int)entity.getContentLength();
+ if (capacity < 0) {
+ capacity = DEFAULT_BUFFER_SIZE;
}
Charset charset = null;
if (contentType != null) {
@@ -218,8 +220,8 @@ public final class EntityUtils {
if (charset == null) {
charset = HTTP.DEF_CONTENT_CHARSET;
}
- final Reader reader = new InputStreamReader(instream, charset);
- final CharArrayBuffer buffer = new CharArrayBuffer(i);
+ final Reader reader = new InputStreamReader(inStream, charset);
+ final CharArrayBuffer buffer = new CharArrayBuffer(capacity);
final char[] tmp = new char[1024];
int l;
while((l = reader.read(tmp)) != -1) {
@@ -227,7 +229,7 @@ public final class EntityUtils {
}
return buffer.toString();
} finally {
- instream.close();
+ inStream.close();
}
}
@@ -244,7 +246,7 @@ public final class EntityUtils {
* @throws ParseException if header elements cannot be parsed
* @throws IllegalArgumentException if entity is null or if content length > Integer.MAX_VALUE
* @throws IOException if an error occurs reading the input stream
- * @throws java.nio.charset.UnsupportedCharsetException Thrown when the named entity's charset is not available in
+ * @throws UnsupportedCharsetException Thrown when the named entity's charset is not available in
* this instance of the Java virtual machine and no defaultCharset is provided.
*/
public static String toString(
@@ -280,7 +282,7 @@ public final class EntityUtils {
* @throws ParseException if header elements cannot be parsed
* @throws IllegalArgumentException if entity is null or if content length > Integer.MAX_VALUE
* @throws IOException if an error occurs reading the input stream
- * @throws java.nio.charset.UnsupportedCharsetException Thrown when the named charset is not available in
+ * @throws UnsupportedCharsetException Thrown when the named charset is not available in
* this instance of the Java virtual machine
*/
public static String toString(
@@ -298,7 +300,7 @@ public final class EntityUtils {
* @throws ParseException if header elements cannot be parsed
* @throws IllegalArgumentException if entity is null or if content length > Integer.MAX_VALUE
* @throws IOException if an error occurs reading the input stream
- * @throws java.nio.charset.UnsupportedCharsetException Thrown when the named charset is not available in
+ * @throws UnsupportedCharsetException Thrown when the named charset is not available in
* this instance of the Java virtual machine
*/
public static String toString(final HttpEntity entity) throws IOException, ParseException {
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/LangUtils.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/LangUtils.java
index 5473fab56..5f28a10d5 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/LangUtils.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/LangUtils.java
@@ -83,18 +83,16 @@ public final class LangUtils {
public static boolean equals(final Object[] a1, final Object[] a2) {
if (a1 == null) {
return a2 == null;
- } else {
- if (a2 != null && a1.length == a2.length) {
- for (int i = 0; i < a1.length; i++) {
- if (!equals(a1[i], a2[i])) {
- return false;
- }
+ }
+ if (a2 != null && a1.length == a2.length) {
+ for (int i = 0; i < a1.length; i++) {
+ if (!equals(a1[i], a2[i])) {
+ return false;
}
- return true;
- } else {
- return false;
}
+ return true;
}
+ return false;
}
}
diff --git a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/VersionInfo.java b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/VersionInfo.java
index c5194b650..d0e44cc72 100644
--- a/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/VersionInfo.java
+++ b/fine-httpcomponents/http-core/httpcore/src/main/java/com/fr/third/org/apache/http/util/VersionInfo.java
@@ -213,7 +213,7 @@ public class VersionInfo {
* Loads version information for a package.
*
* @param pckg the package for which to load version information,
- * for example "com.fr.third.org.apache.http".
+ * for example "org.apache.http".
* The package name should NOT end with a dot.
* @param clsldr the classloader to load from, or
* {@code null} for the thread context classloader
@@ -228,7 +228,7 @@ public class VersionInfo {
Properties vip = null; // version info properties, if available
try {
- // org.apache.http becomes
+ // com.fr.third.org.apache.http becomes
// org/apache/http/version.properties
final InputStream is = cl.getResourceAsStream
(pckg.replace('.', '/') + "/" + VERSION_PROPERTY_FILE);
@@ -259,7 +259,7 @@ public class VersionInfo {
*
* @param pckg the package for the version information
* @param info the map from string keys to string values,
- * for example {@link java.util.Properties}
+ * for example {@link Properties}
* @param clsldr the classloader, or {@code null}
*
* @return the version information
@@ -308,7 +308,7 @@ public class VersionInfo {
*
* @param name the component name, like "Apache-HttpClient".
* @param pkg
- * the package for which to load version information, for example "com.fr.third.org.apache.http". The package name
+ * the package for which to load version information, for example "org.apache.http". The package name
* should NOT end with a dot.
* @param cls
* the class' class loader to load from, or {@code null} for the thread context class loader