[maven-release-plugin] copy for tag 4.0-alpha4
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.0-alpha4@653242 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 9440d15..9e7fd64 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -23,6 +23,11 @@
Changelog:
-------------------
+* [HTTPCLIENT-765] String.toLowerCase() / toUpperCase() should specify Locale.ENGLISH
+
+* [HTTPCLIENT-769] Do not pool connection marked non-reusable.
+ Contributed by Oleg Kalnichevski <olegk at apache.org>
+
* [HTTPCLIENT-763] Fixed problem with AbstractClientConnAdapter#abortConnection()
not releasing the connection if called from the main execution thread while
there is no blocking I/O operation.
diff --git a/module-client/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java b/module-client/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
index aac5f03..30e2d54 100644
--- a/module-client/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
+++ b/module-client/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
@@ -103,10 +103,10 @@
*/
static class GetThread extends Thread {
- private HttpClient httpClient;
- private HttpContext context;
- private HttpGet httpget;
- private int id;
+ private final HttpClient httpClient;
+ private final HttpContext context;
+ private final HttpGet httpget;
+ private final int id;
public GetThread(HttpClient httpClient, HttpGet httpget, int id) {
this.httpClient = httpClient;
diff --git a/module-client/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java b/module-client/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
index 198fd9e..59ff7ae 100644
--- a/module-client/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
+++ b/module-client/src/main/java/org/apache/http/auth/AuthSchemeRegistry.java
@@ -33,6 +33,7 @@
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import org.apache.http.params.HttpParams;
@@ -80,7 +81,7 @@
if (factory == null) {
throw new IllegalArgumentException("Authentication scheme factory may not be null");
}
- registeredSchemes.put(name.toLowerCase(), factory);
+ registeredSchemes.put(name.toLowerCase(Locale.ENGLISH), factory);
}
/**
@@ -93,7 +94,7 @@
if (name == null) {
throw new IllegalArgumentException("Name may not be null");
}
- registeredSchemes.remove(name.toLowerCase());
+ registeredSchemes.remove(name.toLowerCase(Locale.ENGLISH));
}
/**
@@ -113,7 +114,7 @@
if (name == null) {
throw new IllegalArgumentException("Name may not be null");
}
- AuthSchemeFactory factory = registeredSchemes.get(name.toLowerCase());
+ AuthSchemeFactory factory = registeredSchemes.get(name.toLowerCase(Locale.ENGLISH));
if (factory != null) {
return factory.newInstance(params);
} else {
diff --git a/module-client/src/main/java/org/apache/http/auth/AuthScope.java b/module-client/src/main/java/org/apache/http/auth/AuthScope.java
index 5fa19fc..344d6ff 100644
--- a/module-client/src/main/java/org/apache/http/auth/AuthScope.java
+++ b/module-client/src/main/java/org/apache/http/auth/AuthScope.java
@@ -30,6 +30,8 @@
package org.apache.http.auth;
+import java.util.Locale;
+
import org.apache.http.util.LangUtils;
/**
@@ -73,16 +75,16 @@
public static final AuthScope ANY = new AuthScope(ANY_HOST, ANY_PORT, ANY_REALM, ANY_SCHEME);
/** The authentication scheme the credentials apply to. */
- private String scheme = null;
+ private final String scheme;
/** The realm the credentials apply to. */
- private String realm = null;
+ private final String realm;
/** The host the credentials apply to. */
- private String host = null;
+ private final String host;
/** The port the credentials apply to. */
- private int port = -1;
+ private final int port;
/** Creates a new credentials scope for the given
* <tt>host</tt>, <tt>port</tt>, <tt>realm</tt>, and
@@ -104,10 +106,10 @@
public AuthScope(final String host, int port,
final String realm, final String scheme)
{
- this.host = (host == null) ? ANY_HOST: host.toLowerCase();
+ this.host = (host == null) ? ANY_HOST: host.toLowerCase(Locale.ENGLISH);
this.port = (port < 0) ? ANY_PORT: port;
this.realm = (realm == null) ? ANY_REALM: realm;
- this.scheme = (scheme == null) ? ANY_SCHEME: scheme.toUpperCase();
+ this.scheme = (scheme == null) ? ANY_SCHEME: scheme.toUpperCase(Locale.ENGLISH);
}
/** Creates a new credentials scope for the given
@@ -254,7 +256,7 @@
public String toString() {
StringBuffer buffer = new StringBuffer();
if (this.scheme != null) {
- buffer.append(this.scheme.toUpperCase());
+ buffer.append(this.scheme.toUpperCase(Locale.ENGLISH));
buffer.append(' ');
}
if (this.realm != null) {
diff --git a/module-client/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java b/module-client/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java
index a2d8399..6a0e736 100644
--- a/module-client/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java
+++ b/module-client/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java
@@ -64,6 +64,7 @@
this.password = usernamePassword.substring(atColon + 1);
} else {
this.userName = usernamePassword;
+ this.password = null;
}
}
@@ -88,13 +89,13 @@
/**
* User name.
*/
- private String userName;
+ private final String userName;
/**
* Password.
*/
- private String password;
+ private final String password;
// ------------------------------------------------------------- Properties
@@ -132,9 +133,9 @@
*/
@Override
public String toString() {
- StringBuffer result = new StringBuffer();
+ StringBuilder result = new StringBuilder();
result.append(this.userName);
- result.append(":");
+ result.append(':');
result.append((this.password == null) ? "null" : this.password);
return result.toString();
}
diff --git a/module-client/src/main/java/org/apache/http/client/AuthState.java b/module-client/src/main/java/org/apache/http/client/AuthState.java
index 24ce911..d30d397 100644
--- a/module-client/src/main/java/org/apache/http/client/AuthState.java
+++ b/module-client/src/main/java/org/apache/http/client/AuthState.java
@@ -45,13 +45,13 @@
public class AuthState {
/** Actual authentication scheme */
- private AuthScheme authScheme = null;
+ private AuthScheme authScheme;
/** Actual authentication scope */
- private AuthScope authScope = null;
+ private AuthScope authScope;
/** Credentials selected for authentication */
- private Credentials credentials = null;
+ private Credentials credentials;
/**
* Default constructor.
diff --git a/module-client/src/main/java/org/apache/http/client/methods/HttpDelete.java b/module-client/src/main/java/org/apache/http/client/methods/HttpDelete.java
index 517111c..4a4c3ef 100644
--- a/module-client/src/main/java/org/apache/http/client/methods/HttpDelete.java
+++ b/module-client/src/main/java/org/apache/http/client/methods/HttpDelete.java
@@ -66,6 +66,7 @@
setURI(new URI(uri));
}
+ @Override
public String getMethod() {
return METHOD_NAME;
}
diff --git a/module-client/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java b/module-client/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java
index 33343c0..79be0cf 100644
--- a/module-client/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java
+++ b/module-client/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java
@@ -48,7 +48,7 @@
abstract class HttpEntityEnclosingRequestBase
extends HttpRequestBase implements HttpEntityEnclosingRequest {
- private HttpEntity entity = null;
+ private HttpEntity entity;
public HttpEntityEnclosingRequestBase() {
super();
diff --git a/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java b/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java
index 28b7faa..1fba84b 100644
--- a/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java
+++ b/module-client/src/main/java/org/apache/http/client/methods/HttpOptions.java
@@ -93,8 +93,8 @@
while (it.hasNext()) {
Header header = it.nextHeader();
HeaderElement[] elements = header.getElements();
- for (int i = 0; i < elements.length; i++) {
- methods.add(elements[i].getName());
+ for (HeaderElement element : elements) {
+ methods.add(element.getName());
}
}
return methods;
diff --git a/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java b/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
index d4996f6..1aa8211 100644
--- a/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
+++ b/module-client/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
@@ -146,11 +146,10 @@
// Get an instance of the selected cookie policy
CookieSpec cookieSpec = registry.getCookieSpec(policy, request.getParams());
// Get all cookies available in the HTTP state
- List<Cookie> cookies = cookieStore.getCookies();
+ List<Cookie> cookies = new ArrayList<Cookie>(cookieStore.getCookies());
// Find cookies matching the given origin
List<Cookie> matchedCookies = new ArrayList<Cookie>();
- for (int i = 0; i < cookies.size(); i++) {
- Cookie cookie = cookies.get(i);
+ for (Cookie cookie : cookies) {
if (cookieSpec.match(cookie, cookieOrigin)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Cookie " + cookie + " match " + cookieOrigin);
@@ -161,16 +160,15 @@
// Generate Cookie request headers
if (!matchedCookies.isEmpty()) {
List<Header> headers = cookieSpec.formatCookies(matchedCookies);
- for (int i = 0; i < headers.size(); i++) {
- request.addHeader(headers.get(i));
+ for (Header header : headers) {
+ request.addHeader(header);
}
}
int ver = cookieSpec.getVersion();
if (ver > 0) {
boolean needVersionHeader = false;
- for (int i = 0; i < matchedCookies.size(); i++) {
- Cookie cookie = matchedCookies.get(i);
+ for (Cookie cookie : matchedCookies) {
if (ver != cookie.getVersion()) {
needVersionHeader = true;
}
diff --git a/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java b/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java
index 268a219..b228fc0 100644
--- a/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java
+++ b/module-client/src/main/java/org/apache/http/client/protocol/RequestDefaultHeaders.java
@@ -33,7 +33,6 @@
import java.io.IOException;
import java.util.Collection;
-import java.util.Iterator;
import org.apache.http.Header;
import org.apache.http.HttpException;
@@ -66,8 +65,8 @@
Collection<?> defHeaders = (Collection<?>) request.getParams().getParameter(
ClientPNames.DEFAULT_HEADERS);
if (defHeaders != null) {
- for (Iterator<?> it = defHeaders.iterator(); it.hasNext(); ) {
- request.addHeader((Header) it.next());
+ for (Object defHeader : defHeaders) {
+ request.addHeader((Header) defHeader);
}
}
}
diff --git a/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java b/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java
index d54aa80..c4fb986 100644
--- a/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java
+++ b/module-client/src/main/java/org/apache/http/client/protocol/ResponseProcessCookies.java
@@ -118,12 +118,11 @@
Header header = iterator.nextHeader();
try {
List<Cookie> cookies = cookieSpec.parse(header, cookieOrigin);
- for (int c = 0; c < cookies.size(); c++) {
- Cookie cookie = cookies.get(c);
+ for (Cookie cookie : cookies) {
try {
cookieSpec.validate(cookie, cookieOrigin);
cookieStore.addCookie(cookie);
-
+
if (LOG.isDebugEnabled()) {
LOG.debug("Cookie accepted: \""
+ cookie + "\". ");
diff --git a/module-client/src/main/java/org/apache/http/client/utils/URIUtils.java b/module-client/src/main/java/org/apache/http/client/utils/URIUtils.java
index ef70c58..79101df 100644
--- a/module-client/src/main/java/org/apache/http/client/utils/URIUtils.java
+++ b/module-client/src/main/java/org/apache/http/client/utils/URIUtils.java
@@ -86,22 +86,22 @@
}
buffer.append(host);
if (port > 0) {
- buffer.append(":");
+ buffer.append(':');
buffer.append(port);
}
}
if (path == null || !path.startsWith("/")) {
- buffer.append("/");
+ buffer.append('/');
}
if (path != null) {
buffer.append(path);
}
if (query != null) {
- buffer.append("?");
+ buffer.append('?');
buffer.append(query);
}
if (fragment != null) {
- buffer.append("#");
+ buffer.append('#');
buffer.append(fragment);
}
return new URI(buffer.toString());
diff --git a/module-client/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java b/module-client/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java
index adb3ca3..ab19dbc 100644
--- a/module-client/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java
+++ b/module-client/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java
@@ -39,6 +39,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Arrays;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.SocketFactory;
@@ -64,7 +65,7 @@
* Gets the singleton instance of this class.
* @return the one and only plain socket factory
*/
- public static final MultihomePlainSocketFactory getSocketFactory() {
+ public static MultihomePlainSocketFactory getSocketFactory() {
return DEFAULT_FACTORY;
}
@@ -126,9 +127,7 @@
InetAddress[] inetadrs = InetAddress.getAllByName(host);
List<InetAddress> addresses = new ArrayList<InetAddress>(inetadrs.length);
- for (InetAddress inetadr: inetadrs) {
- addresses.add(inetadr);
- }
+ addresses.addAll(Arrays.asList(inetadrs));
Collections.shuffle(addresses);
IOException lastEx = null;
diff --git a/module-client/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java b/module-client/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java
index 9bb068a..3c2155c 100644
--- a/module-client/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java
+++ b/module-client/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java
@@ -1,7 +1,7 @@
/*
- * $HeadURL:$
- * $Revision:$
- * $Date:$
+ * $HeadURL$
+ * $Revision$
+ * $Date$
*
* ====================================================================
*
@@ -43,7 +43,7 @@
*
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
*
- * @version $Revision:$
+ * @version $Revision$
*
* @since 4.0
*/
@@ -52,7 +52,7 @@
/** The default maximum number of connections allowed per host */
public static final int DEFAULT_MAX_CONNECTIONS_PER_ROUTE = 2; // Per RFC 2616 sec 8.1.4
- private Map<HttpRoute, Integer> maxPerHostMap;
+ private final Map<HttpRoute, Integer> maxPerHostMap;
private int defaultMax;
diff --git a/module-client/src/main/java/org/apache/http/conn/params/HttpRouteParams.java b/module-client/src/main/java/org/apache/http/conn/params/HttpRouteParams.java
index d514a1d..f2b16e5 100644
--- a/module-client/src/main/java/org/apache/http/conn/params/HttpRouteParams.java
+++ b/module-client/src/main/java/org/apache/http/conn/params/HttpRouteParams.java
@@ -84,7 +84,7 @@
* @return the default proxy set in the argument parameters, or
* <code>null</code> if not set
*/
- public final static HttpHost getDefaultProxy(HttpParams params) {
+ public static HttpHost getDefaultProxy(HttpParams params) {
if (params == null) {
throw new IllegalArgumentException("Parameters must not be null.");
}
@@ -108,7 +108,7 @@
* <code>null</code> by {@link #getDefaultProxy},
* to allow for explicit unsetting in hierarchies.
*/
- public final static void setDefaultProxy(HttpParams params,
+ public static void setDefaultProxy(HttpParams params,
HttpHost proxy) {
if (params == null) {
throw new IllegalArgumentException("Parameters must not be null.");
@@ -128,7 +128,7 @@
* @return the forced route set in the argument parameters, or
* <code>null</code> if not set
*/
- public final static HttpRoute getForcedRoute(HttpParams params) {
+ public static HttpRoute getForcedRoute(HttpParams params) {
if (params == null) {
throw new IllegalArgumentException("Parameters must not be null.");
}
@@ -152,7 +152,7 @@
* <code>null</code> by {@link #getForcedRoute},
* to allow for explicit unsetting in hierarchies.
*/
- public final static void setForcedRoute(HttpParams params,
+ public static void setForcedRoute(HttpParams params,
HttpRoute route) {
if (params == null) {
throw new IllegalArgumentException("Parameters must not be null.");
@@ -173,7 +173,7 @@
* @return the local address set in the argument parameters, or
* <code>null</code> if not set
*/
- public final static InetAddress getLocalAddress(HttpParams params) {
+ public static InetAddress getLocalAddress(HttpParams params) {
if (params == null) {
throw new IllegalArgumentException("Parameters must not be null.");
}
@@ -191,7 +191,7 @@
* @param params the parameters in which to set the value
* @param local the value to set, may be <code>null</code>
*/
- public final static void setLocalAddress(HttpParams params,
+ public static void setLocalAddress(HttpParams params,
InetAddress local) {
if (params == null) {
throw new IllegalArgumentException("Parameters must not be null.");
diff --git a/module-client/src/main/java/org/apache/http/conn/routing/HttpRoute.java b/module-client/src/main/java/org/apache/http/conn/routing/HttpRoute.java
index e23de45..c1f6d9a 100644
--- a/module-client/src/main/java/org/apache/http/conn/routing/HttpRoute.java
+++ b/module-client/src/main/java/org/apache/http/conn/routing/HttpRoute.java
@@ -239,10 +239,10 @@
if ((proxies == null) || (proxies.length < 1))
return null;
- for (int i=0; i<proxies.length; i++) {
- if (proxies[i] == null)
+ for (HttpHost proxy : proxies) {
+ if (proxy == null)
throw new IllegalArgumentException
- ("Proxy chain may not contain null elements.");
+ ("Proxy chain may not contain null elements.");
}
// copy the proxy chain, the traditional way
@@ -281,7 +281,7 @@
if (hop >= hopcount)
throw new IllegalArgumentException
("Hop index " + hop +
- " exceeds route length " + hopcount +".");
+ " exceeds route length " + hopcount);
HttpHost result = null;
if (hop < hopcount-1)
@@ -385,8 +385,7 @@
hc ^= localAddress.hashCode();
if (this.proxyChain != null) {
hc ^= proxyChain.length;
- for (int i=0; i<proxyChain.length; i++)
- hc ^= proxyChain[i].hashCode();
+ for (HttpHost aProxyChain : proxyChain) hc ^= aProxyChain.hashCode();
}
if (this.secure)
@@ -422,8 +421,8 @@
cab.append('s');
cab.append("}->");
if (this.proxyChain != null) {
- for (int i=0; i<this.proxyChain.length; i++) {
- cab.append(this.proxyChain[i]);
+ for (HttpHost aProxyChain : this.proxyChain) {
+ cab.append(aProxyChain);
cab.append("->");
}
}
diff --git a/module-client/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java b/module-client/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java
index a5b9c60..48ca22d 100644
--- a/module-client/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java
+++ b/module-client/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java
@@ -57,7 +57,7 @@
* Gets the singleton instance of this class.
* @return the one and only plain socket factory
*/
- public static final PlainSocketFactory getSocketFactory() {
+ public static PlainSocketFactory getSocketFactory() {
return DEFAULT_FACTORY;
}
diff --git a/module-client/src/main/java/org/apache/http/conn/scheme/Scheme.java b/module-client/src/main/java/org/apache/http/conn/scheme/Scheme.java
index ee854b7..f352fa4 100644
--- a/module-client/src/main/java/org/apache/http/conn/scheme/Scheme.java
+++ b/module-client/src/main/java/org/apache/http/conn/scheme/Scheme.java
@@ -30,6 +30,8 @@
*/
package org.apache.http.conn.scheme;
+import java.util.Locale;
+
import org.apache.http.util.LangUtils;
/**
@@ -99,7 +101,7 @@
("Port is invalid: " + port);
}
- this.name = name.toLowerCase();
+ this.name = name.toLowerCase(Locale.ENGLISH);
this.socketFactory = factory;
this.defaultPort = port;
this.layered = (factory instanceof LayeredSocketFactory);
diff --git a/module-client/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java b/module-client/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java
index 59b20f2..9d791d3 100644
--- a/module-client/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java
+++ b/module-client/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java
@@ -43,6 +43,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Locale;
import java.util.StringTokenizer;
import javax.net.ssl.SSLException;
@@ -161,9 +162,9 @@
names.add(cns[0]);
}
if(subjectAlts != null) {
- for(int i = 0; i < subjectAlts.length; i++) {
- if(subjectAlts[i] != null) {
- names.add(subjectAlts[i]);
+ for (String subjectAlt : subjectAlts) {
+ if (subjectAlt != null) {
+ names.add(subjectAlt);
}
}
}
@@ -178,12 +179,12 @@
// We're can be case-insensitive when comparing the host we used to
// establish the socket to the hostname in the certificate.
- String hostName = host.trim().toLowerCase();
+ String hostName = host.trim().toLowerCase(Locale.ENGLISH);
boolean match = false;
for(Iterator<String> it = names.iterator(); it.hasNext();) {
// Don't trim the CN, though!
String cn = it.next();
- cn = cn.toLowerCase();
+ cn = cn.toLowerCase(Locale.ENGLISH);
// Store CN in StringBuffer in case we need to report an error.
buf.append(" <");
buf.append(cn);
@@ -302,12 +303,11 @@
cpe.printStackTrace();
}
if(c != null) {
- Iterator<List<?>> it = c.iterator();
- while(it.hasNext()) {
- List<?> list = it.next();
+ for (List<?> aC : c) {
+ List<?> list = aC;
int type = ((Integer) list.get(0)).intValue();
// If type is 2, then we've got a dNSName
- if(type == 2) {
+ if (type == 2) {
String s = (String) list.get(1);
subjectAltList.add(s);
}
diff --git a/module-client/src/main/java/org/apache/http/cookie/CookieOrigin.java b/module-client/src/main/java/org/apache/http/cookie/CookieOrigin.java
index 4ac5f36..c985aee 100644
--- a/module-client/src/main/java/org/apache/http/cookie/CookieOrigin.java
+++ b/module-client/src/main/java/org/apache/http/cookie/CookieOrigin.java
@@ -30,6 +30,8 @@
*/
package org.apache.http.cookie;
+import java.util.Locale;
+
/**
* CookieOrigin class incapsulates details of an origin server that
* are relevant when parsing, validating or matching HTTP cookies.
@@ -51,7 +53,7 @@
throw new IllegalArgumentException(
"Host of origin may not be null");
}
- if (host.trim().equals("")) {
+ if (host.trim().length() == 0) {
throw new IllegalArgumentException(
"Host of origin may not be blank");
}
@@ -62,9 +64,9 @@
throw new IllegalArgumentException(
"Path of origin may not be null.");
}
- this.host = host.toLowerCase();
+ this.host = host.toLowerCase(Locale.ENGLISH);
this.port = port;
- if (!path.trim().equals("")) {
+ if (path.trim().length() != 0) {
this.path = path;
} else {
this.path = "/";
@@ -91,15 +93,15 @@
@Override
public String toString() {
StringBuilder buffer = new StringBuilder();
- buffer.append("[");
+ buffer.append('[');
if (this.secure) {
buffer.append("(secure)");
}
buffer.append(this.host);
- buffer.append(":");
+ buffer.append(':');
buffer.append(Integer.toString(this.port));
buffer.append(this.path);
- buffer.append("]");
+ buffer.append(']');
return buffer.toString();
}
diff --git a/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java b/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java
index 749ddae..a6aa186 100644
--- a/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java
+++ b/module-client/src/main/java/org/apache/http/cookie/CookiePathComparator.java
@@ -58,7 +58,7 @@
path = "/";
}
if (!path.endsWith("/")) {
- path = path + "/";
+ path = path + '/';
}
return path;
}
diff --git a/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java b/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
index bc56882..4cdafe7 100644
--- a/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
+++ b/module-client/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
@@ -34,6 +34,7 @@
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import org.apache.http.params.HttpParams;
@@ -75,7 +76,7 @@
if (factory == null) {
throw new IllegalArgumentException("Cookie spec factory may not be null");
}
- registeredSpecs.put(name.toLowerCase(), factory);
+ registeredSpecs.put(name.toLowerCase(Locale.ENGLISH), factory);
}
/**
@@ -87,7 +88,7 @@
if (id == null) {
throw new IllegalArgumentException("Id may not be null");
}
- registeredSpecs.remove(id.toLowerCase());
+ registeredSpecs.remove(id.toLowerCase(Locale.ENGLISH));
}
/**
@@ -107,7 +108,7 @@
if (name == null) {
throw new IllegalArgumentException("Name may not be null");
}
- CookieSpecFactory factory = registeredSpecs.get(name.toLowerCase());
+ CookieSpecFactory factory = registeredSpecs.get(name.toLowerCase(Locale.ENGLISH));
if (factory != null) {
return factory.newInstance(params);
} else {
diff --git a/module-client/src/main/java/org/apache/http/impl/auth/BasicScheme.java b/module-client/src/main/java/org/apache/http/impl/auth/BasicScheme.java
index 23320d4..4786bcb 100644
--- a/module-client/src/main/java/org/apache/http/impl/auth/BasicScheme.java
+++ b/module-client/src/main/java/org/apache/http/impl/auth/BasicScheme.java
@@ -120,7 +120,7 @@
*
* @param credentials The set of credentials to be used for athentication
* @param request The request being authenticated
- * @throws InvalidCredentialsException if authentication credentials
+ * @throws 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/module-client/src/main/java/org/apache/http/impl/auth/DigestScheme.java b/module-client/src/main/java/org/apache/http/impl/auth/DigestScheme.java
index 7a3ae52..7bb39f0 100644
--- a/module-client/src/main/java/org/apache/http/impl/auth/DigestScheme.java
+++ b/module-client/src/main/java/org/apache/http/impl/auth/DigestScheme.java
@@ -198,7 +198,7 @@
* @param credentials A set of credentials to be used for athentication
* @param request The request being authenticated
*
- * @throws InvalidCredentialsException if authentication credentials
+ * @throws 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
@@ -242,10 +242,6 @@
/**
* Creates an MD5 response digest.
*
- * @param uname Username
- * @param pwd Password
- * @param charset The credential charset
- *
* @return The created digest as string. This will be the response tag's
* value in the Authentication HTTP header.
* @throws AuthenticationException when MD5 is an unsupported algorithm
@@ -311,7 +307,7 @@
//we do not have access to the entity-body or its hash
//TODO: add Method ":" digest-uri-value ":" H(entity-body)
} else {
- a2 = method + ":" + uri;
+ a2 = method + ':' + uri;
}
String md5a2 = encode(md5Helper.digest(EncodingUtils.getAsciiBytes(a2)));
diff --git a/module-client/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java b/module-client/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java
index 013f5c2..fac825e 100644
--- a/module-client/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java
+++ b/module-client/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java
@@ -31,6 +31,7 @@
package org.apache.http.impl.auth;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
import org.apache.http.Header;
@@ -59,7 +60,7 @@
/**
* Authentication parameter map.
*/
- private Map<String, String> params = null;
+ private Map<String, String> params;
/**
* Flag whether authenticating against a proxy.
@@ -130,8 +131,7 @@
}
this.params = new HashMap<String, String>(elements.length);
- for (int i = 0; i < elements.length; i++) {
- HeaderElement element = elements[i];
+ for (HeaderElement element : elements) {
this.params.put(element.getName(), element.getValue());
}
}
@@ -159,7 +159,7 @@
if (this.params == null) {
return null;
}
- return this.params.get(name.toLowerCase());
+ return this.params.get(name.toLowerCase(Locale.ENGLISH));
}
/**
diff --git a/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java b/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java
index 4c114fd..ea7f6fe 100644
--- a/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java
+++ b/module-client/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java
@@ -33,8 +33,8 @@
import java.util.Arrays;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import org.apache.commons.logging.Log;
@@ -72,8 +72,7 @@
final Header[] headers) throws MalformedChallengeException {
Map<String, Header> map = new HashMap<String, Header>(headers.length);
- for (int i = 0; i < headers.length; i++) {
- Header header = headers[i];
+ for (Header header : headers) {
CharArrayBuffer buffer;
int pos;
if (header instanceof FormattedHeader) {
@@ -97,7 +96,7 @@
}
int endIndex = pos;
String s = buffer.substring(beginIndex, endIndex);
- map.put(s.toLowerCase(), header);
+ map.put(s.toLowerCase(Locale.ENGLISH), header);
}
return map;
}
@@ -124,9 +123,9 @@
}
AuthScheme authScheme = null;
- for (Iterator<String> it = authPrefs.iterator(); it.hasNext(); ) {
- String id = it.next();
- Header challenge = challenges.get(id.toLowerCase());
+ for (String id : authPrefs) {
+ Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
+
if (challenge != null) {
if (LOG.isDebugEnabled()) {
LOG.debug(id + " authentication scheme selected");
diff --git a/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java b/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java
index c0f283b..2bb84b9 100644
--- a/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java
+++ b/module-client/src/main/java/org/apache/http/impl/client/BasicCookieStore.java
@@ -109,8 +109,8 @@
*/
public synchronized void addCookies(Cookie[] cookies) {
if (cookies != null) {
- for (int i = 0; i < cookies.length; i++) {
- this.addCookie(cookies[i]);
+ for (Cookie cooky : cookies) {
+ this.addCookie(cooky);
}
}
}
diff --git a/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java b/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
index fedbf6a..038842b 100644
--- a/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
+++ b/module-client/src/main/java/org/apache/http/impl/client/BasicCredentialsProvider.java
@@ -85,7 +85,7 @@
* Find matching {@link Credentials credentials} for the given authentication scope.
*
* @param map the credentials hash map
- * @param token the {@link AuthScope authentication scope}
+ * @param authscope the {@link AuthScope authentication scope}
* @return the credentials
*
*/
diff --git a/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java b/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
index 7e73130..b70f22e 100644
--- a/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
+++ b/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java
@@ -35,6 +35,7 @@
import java.io.InterruptedIOException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.Locale;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@@ -760,7 +761,7 @@
StringBuilder buffer = new StringBuilder(host.length() + 6);
buffer.append(host);
- buffer.append(":");
+ buffer.append(':');
buffer.append(Integer.toString(port));
String authority = buffer.toString();
@@ -942,7 +943,7 @@
}
String id = authScheme.getSchemeName();
- Header challenge = challenges.get(id.toLowerCase());
+ Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
if (challenge == null) {
throw new AuthenticationException(id +
" authorization challenge expected, but not found");
diff --git a/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java b/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
index 06b625e..746156d 100644
--- a/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
+++ b/module-client/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
@@ -51,10 +51,10 @@
public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler {
/** the number of times a method will be retried */
- private int retryCount;
+ private final int retryCount;
/** Whether or not methods that have successfully sent their request will be retried */
- private boolean requestSentRetryEnabled;
+ private final boolean requestSentRetryEnabled;
/**
* Default constructor
diff --git a/module-client/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java b/module-client/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
index 67c51f2..9246416 100644
--- a/module-client/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
+++ b/module-client/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
@@ -54,7 +54,7 @@
class EntityEnclosingRequestWrapper extends RequestWrapper
implements HttpEntityEnclosingRequest {
- private HttpEntity entity = null;
+ private HttpEntity entity;
public EntityEnclosingRequestWrapper(final HttpEntityEnclosingRequest request)
throws ProtocolException {
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java b/module-client/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
index 101a371..dcabdfe 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
+++ b/module-client/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java
@@ -359,30 +359,25 @@
}
aborted = true;
unmarkReusable();
-
- OperatedClientConnection conn = getWrappedConnection();
-
- if (conn != null) {
- try {
- conn.shutdown();
- } catch (IOException ignore) {
- }
- // Usually #abortConnection() is expected to be called from
- // a helper thread in order to unblock the main execution thread
- // blocked in an I/O operation. It may be unsafe to call
- // #releaseConnection() from the helper thread, so we have to rely
- // on an IOException thrown by the closed socket on the main thread
- // to trigger the release of the connection back to the
- // connection manager.
- //
- // However, if this method is called from the main execution thread
- // it should be safe to release the connection immediately. Besides,
- // this also helps ensure the connection gets released back to the
- // manager if #abortConnection() is called from the main execution
- // thread while there is no blocking I/O operation.
- if (executionThread.equals(Thread.currentThread())) {
- releaseConnection();
- }
+ try {
+ shutdown();
+ } catch (IOException ignore) {
+ }
+ // Usually #abortConnection() is expected to be called from
+ // a helper thread in order to unblock the main execution thread
+ // blocked in an I/O operation. It may be unsafe to call
+ // #releaseConnection() from the helper thread, so we have to rely
+ // on an IOException thrown by the closed socket on the main thread
+ // to trigger the release of the connection back to the
+ // connection manager.
+ //
+ // However, if this method is called from the main execution thread
+ // it should be safe to release the connection immediately. Besides,
+ // this also helps ensure the connection gets released back to the
+ // manager if #abortConnection() is called from the main execution
+ // thread while there is no blocking I/O operation.
+ if (executionThread.equals(Thread.currentThread())) {
+ releaseConnection();
}
}
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/AbstractPoolEntry.java b/module-client/src/main/java/org/apache/http/impl/conn/AbstractPoolEntry.java
index 50ee50e..3328f2a 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/AbstractPoolEntry.java
+++ b/module-client/src/main/java/org/apache/http/impl/conn/AbstractPoolEntry.java
@@ -90,7 +90,7 @@
/**
* Creates a new pool entry.
*
- * @param occ the underlying connection for this entry
+ * @param connOperator the Connection Operator for this entry
* @param route the planned route for the connection,
* or <code>null</code>
*/
@@ -299,12 +299,9 @@
/**
- * Tracks close or shutdown of the connection.
- * There is no distinction between the two, the route is dropped
- * in both cases. This method should be called regardless of
- * whether the close or shutdown succeeds or triggers an error.
+ * Resets tracked route.
*/
- public void closing() {
+ protected void resetTrackedRoute() {
tracker = null;
}
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java b/module-client/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
index 806a22a..7876f27 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
+++ b/module-client/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
@@ -151,7 +151,7 @@
// non-javadoc, see interface HttpConnection
public void close() throws IOException {
if (poolEntry != null)
- poolEntry.closing();
+ poolEntry.resetTrackedRoute();
OperatedClientConnection conn = getWrappedConnection();
if (conn != null) {
@@ -162,7 +162,7 @@
// non-javadoc, see interface HttpConnection
public void shutdown() throws IOException {
if (poolEntry != null)
- poolEntry.closing();
+ poolEntry.resetTrackedRoute();
OperatedClientConnection conn = getWrappedConnection();
if (conn != null) {
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java b/module-client/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
index 5ffa0cd..4ce8a52 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
+++ b/module-client/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
@@ -223,8 +223,8 @@
if (HEADERS_LOG.isDebugEnabled()) {
HEADERS_LOG.debug("<< " + response.getStatusLine().toString());
Header[] headers = response.getAllHeaders();
- for (int i = 0; i < headers.length; i++) {
- HEADERS_LOG.debug("<< " + headers[i].toString());
+ for (Header header : headers) {
+ HEADERS_LOG.debug("<< " + header.toString());
}
}
return response;
@@ -237,8 +237,8 @@
if (HEADERS_LOG.isDebugEnabled()) {
HEADERS_LOG.debug(">> " + request.getRequestLine().toString());
Header[] headers = request.getAllHeaders();
- for (int i = 0; i < headers.length; i++) {
- HEADERS_LOG.debug(">> " + headers[i].toString());
+ for (Header header : headers) {
+ HEADERS_LOG.debug(">> " + header.toString());
}
}
}
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java b/module-client/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java
index cb5f9f4..48c8e32 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java
+++ b/module-client/src/main/java/org/apache/http/impl/conn/IdleConnectionHandler.java
@@ -53,7 +53,7 @@
private final Log LOG = LogFactory.getLog(IdleConnectionHandler.class);
/** Holds connections and the time they were added. */
- private Map<HttpConnection,Long> connectionToAdded;
+ private final Map<HttpConnection,Long> connectionToAdded;
public IdleConnectionHandler() {
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java b/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
index 55e3689..b7ecc1e 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
+++ b/module-client/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java
@@ -283,7 +283,6 @@
} finally {
sca.detach();
managedConn = null;
- uniquePoolEntry.tracker = null;
lastReleaseTime = System.currentTimeMillis();
}
} // releaseConnection
@@ -362,7 +361,6 @@
/**
* Creates a new pool entry.
*
- * @param occ the underlying connection for this entry
*/
protected PoolEntry() {
super(SingleClientConnManager.this.connOperator, null);
@@ -374,7 +372,7 @@
protected void close()
throws IOException {
- closing();
+ resetTrackedRoute();
if (connection.isOpen())
connection.close();
}
@@ -386,7 +384,7 @@
protected void shutdown()
throws IOException {
- closing();
+ resetTrackedRoute();
if (connection.isOpen())
connection.shutdown();
}
@@ -404,7 +402,7 @@
* Creates a new connection adapter.
*
* @param entry the pool entry for the connection being wrapped
- * @param plan the planned route for this connection
+ * @param route the planned route for this connection
*/
protected ConnAdapter(PoolEntry entry, HttpRoute route) {
super(SingleClientConnManager.this, entry);
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/Wire.java b/module-client/src/main/java/org/apache/http/impl/conn/Wire.java
index 167701e..4812d01 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/Wire.java
+++ b/module-client/src/main/java/org/apache/http/impl/conn/Wire.java
@@ -44,7 +44,7 @@
*/
public class Wire {
- private Log log;
+ private final Log log;
public Wire(Log log) {
this.log = log;
@@ -52,7 +52,7 @@
private void wire(String header, InputStream instream)
throws IOException {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
int ch;
while ((ch = instream.read()) != -1) {
if (ch == 13) {
@@ -72,8 +72,8 @@
}
}
if (buffer.length() > 0) {
- buffer.append("\"");
- buffer.insert(0, "\"");
+ buffer.append('\"');
+ buffer.insert(0, '\"');
buffer.insert(0, header);
log.debug(buffer.toString());
}
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
index edf5f16..3df138e 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
+++ b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java
@@ -97,8 +97,6 @@
/**
* Creates a new connection pool.
- *
- * @param mgr the connection manager
*/
protected AbstractConnPool() {
issuedConnections = new HashSet<BasicPoolEntryRef>();
@@ -183,8 +181,10 @@
* attempt to determine whether it can be re-used or not.
*
* @param entry the entry for the connection to release
+ * @param reusable <code>true</code> if the entry is deemed
+ * reusable, <code>false</code> otherwise.
*/
- public abstract void freeEntry(BasicPoolEntry entry)
+ public abstract void freeEntry(BasicPoolEntry entry, boolean reusable)
;
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntry.java b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntry.java
index 5094f5e..fff0bb4 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntry.java
+++ b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPoolEntry.java
@@ -50,7 +50,7 @@
* Pool entries can only be GCed when they are allocated by an application
* and therefore not referenced with a hard link in the manager.
*/
- private BasicPoolEntryRef reference;
+ private final BasicPoolEntryRef reference;
/**
* Creates a new pool entry.
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPooledConnAdapter.java b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPooledConnAdapter.java
index 4dfc097..faec091 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPooledConnAdapter.java
+++ b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/BasicPooledConnAdapter.java
@@ -57,6 +57,7 @@
}
+ @Override
protected ClientConnectionManager getManager() {
// override needed only to make method visible in this package
return super.getManager();
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
index e9bbb08..9252154 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
+++ b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java
@@ -251,8 +251,6 @@
* @param timeout the timeout, 0 or negative for no timeout
* @param tunit the unit for the <code>timeout</code>,
* may be <code>null</code> only if there is no timeout
- * @param operator the connection operator, in case
- * a connection has to be created
* @param aborter an object which can abort a {@link WaitingThread}.
*
* @return pool entry holding a connection for the route
@@ -369,7 +367,7 @@
// non-javadoc, see base class AbstractConnPool
@Override
- public void freeEntry(BasicPoolEntry entry) {
+ public void freeEntry(BasicPoolEntry entry, boolean reusable) {
HttpRoute route = entry.getPlannedRoute();
if (LOG.isDebugEnabled()) {
@@ -391,17 +389,15 @@
RouteSpecificPool rospl = getRoutePool(route, true);
- rospl.freeEntry(entry);
- freeConnections.add(entry);
-
- if (numConnections == 0) {
- // for some reason this pool didn't already exist
- LOG.error("Master connection pool not found: " + route);
- numConnections = 1;
+ if (reusable) {
+ rospl.freeEntry(entry);
+ freeConnections.add(entry);
+ idleConnHandler.add(entry.getConnection());
+ } else {
+ rospl.dropEntry();
+ numConnections--;
}
- idleConnHandler.add(entry.getConnection());
-
notifyWaitingThread(rospl);
} finally {
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
index f5fcab8..9dbf309 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
+++ b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java
@@ -62,10 +62,10 @@
* This list is managed LIFO, to increase idle times and
* allow for closing connections that are not really needed.
*/
- protected LinkedList<BasicPoolEntry> freeEntries;
+ protected final LinkedList<BasicPoolEntry> freeEntries;
/** The list of threads waiting for this pool. */
- protected Queue<WaitingThread> waitingThreads;
+ protected final Queue<WaitingThread> waitingThreads;
/** The number of created entries. */
protected int numEntries;
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
index c5e55d0..0b276b3 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
+++ b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java
@@ -222,9 +222,11 @@
iox);
} finally {
BasicPoolEntry entry = (BasicPoolEntry) hca.getPoolEntry();
+ boolean reusable = hca.isMarkedReusable();
hca.detach();
- if (entry != null) // is it worth to bother with this check? @@@
- connectionPool.freeEntry(entry);
+ if (entry != null) {
+ connectionPool.freeEntry(entry, reusable);
+ }
}
}
diff --git a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/package.html b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/package.html
index 1ddcce1..7d3bb6a 100644
--- a/module-client/src/main/java/org/apache/http/impl/conn/tsccm/package.html
+++ b/module-client/src/main/java/org/apache/http/impl/conn/tsccm/package.html
@@ -37,7 +37,7 @@
The implementation of a thread-safe client connection manager.
<center>
-<image src="doc-files/tsccm-structure.png" alt="Relation Diagram"/>
+<img src="doc-files/tsccm-structure.png" alt="Relation Diagram"/>
</center>
<p>
@@ -48,7 +48,7 @@
Both Manager and Pool rely on <i>Operations</i> (cyan) to provide the
actual connections.
</p>
-</p>
+<p>
In order to allow connection garbage collection, it is
imperative that hard object references between the areas are
restricted to the relations indicated by arrows in the diagram:
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java b/module-client/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java
index 6980a91..376cc06 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/BasicClientCookie.java
@@ -33,6 +33,7 @@
import java.util.Date;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
import org.apache.http.cookie.ClientCookie;
@@ -197,7 +198,7 @@
*/
public void setDomain(String domain) {
if (domain != null) {
- cookieDomain = domain.toLowerCase();
+ cookieDomain = domain.toLowerCase(Locale.ENGLISH);
} else {
cookieDomain = null;
}
@@ -362,7 +363,7 @@
private boolean isSecure;
/** The version of the cookie specification I was created from. */
- private int cookieVersion = 0;
+ private int cookieVersion;
}
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java b/module-client/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java
index 0af2c0f..0b586d7 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/BasicDomainHandler.java
@@ -50,7 +50,7 @@
if (value == null) {
throw new MalformedCookieException("Missing value for domain attribute");
}
- if (value.trim().equals("")) {
+ if (value.trim().length() == 0) {
throw new MalformedCookieException("Blank value for domain attribute");
}
cookie.setDomain(value);
@@ -74,7 +74,7 @@
if (domain == null) {
throw new MalformedCookieException("Cookie domain may not be null");
}
- if (host.indexOf(".") >= 0) {
+ if (host.contains(".")) {
// Not required to have at least two dots. RFC 2965.
// A Set-Cookie2 with Domain=ajax.com will be accepted.
@@ -114,7 +114,7 @@
return true;
}
if (!domain.startsWith(".")) {
- domain = "." + domain;
+ domain = '.' + domain;
}
return host.endsWith(domain) || host.equals(domain.substring(1));
}
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java b/module-client/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
index 3c608c7..757dee5 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/BasicPathHandler.java
@@ -47,7 +47,7 @@
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
}
- if (value == null || value.trim().equals("")) {
+ if (value == null || value.trim().length() == 0) {
value = "/";
}
cookie.setPath(value);
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java b/module-client/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java
index b08988b..b7c9125 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/BasicSecureHandler.java
@@ -57,7 +57,7 @@
if (origin == null) {
throw new IllegalArgumentException("Cookie origin may not be null");
}
- return cookie.isSecure() ? origin.isSecure() : true;
+ return !cookie.isSecure() || origin.isSecure();
}
}
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java b/module-client/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java
index c0ade88..b39becf 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/BestMatchSpec.java
@@ -53,9 +53,9 @@
private final String[] datepatterns;
private final boolean oneHeader;
- private RFC2965Spec strict = null;
- private BrowserCompatSpec compat = null;
- private NetscapeDraftSpec netscape = null;
+ private RFC2965Spec strict;
+ private BrowserCompatSpec compat;
+ private NetscapeDraftSpec netscape;
public BestMatchSpec(final String[] datepatterns, boolean oneHeader) {
super();
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java b/module-client/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
index 86e30e4..96793bb 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/BrowserCompatSpec.java
@@ -33,6 +33,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import org.apache.http.FormattedHeader;
import org.apache.http.Header;
@@ -109,10 +110,10 @@
}
String headervalue = header.getValue();
boolean isNetscapeCookie = false;
- int i1 = headervalue.toLowerCase().indexOf("expires=");
+ int i1 = headervalue.toLowerCase(Locale.ENGLISH).indexOf("expires=");
if (i1 != -1) {
i1 += "expires=".length();
- int i2 = headervalue.indexOf(";", i1);
+ int i2 = headervalue.indexOf(';', i1);
if (i2 == -1) {
i2 = headervalue.length();
}
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java b/module-client/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
index 91f6466..96626af 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/CookieSpecBase.java
@@ -33,6 +33,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
import org.apache.http.HeaderElement;
import org.apache.http.NameValuePair;
@@ -70,27 +71,25 @@
protected List<Cookie> parse(final HeaderElement[] elems, final CookieOrigin origin)
throws MalformedCookieException {
List<Cookie> cookies = new ArrayList<Cookie>(elems.length);
- for (int i = 0; i < elems.length; i++) {
- HeaderElement headerelement = elems[i];
-
+ for (HeaderElement headerelement : elems) {
String name = headerelement.getName();
String value = headerelement.getValue();
- if (name == null || name.equals("")) {
+ if (name == null || name.length() == 0) {
throw new MalformedCookieException("Cookie name may not be empty");
}
-
+
BasicClientCookie cookie = new BasicClientCookie(name, value);
cookie.setPath(getDefaultPath(origin));
cookie.setDomain(getDefaultDomain(origin));
-
+
// cycle through the parameters
NameValuePair[] attribs = headerelement.getParameters();
for (int j = attribs.length - 1; j >= 0; j--) {
NameValuePair attrib = attribs[j];
- String s = attrib.getName().toLowerCase();
-
+ String s = attrib.getName().toLowerCase(Locale.ENGLISH);
+
cookie.setAttribute(s, attrib.getValue());
-
+
CookieAttributeHandler handler = findAttribHandler(s);
if (handler != null) {
handler.parse(cookie, attrib.getValue());
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/DateUtils.java b/module-client/src/main/java/org/apache/http/impl/cookie/DateUtils.java
index 5a1fa30..59a45a3 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/DateUtils.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/DateUtils.java
@@ -151,16 +151,16 @@
) {
dateValue = dateValue.substring (1, dateValue.length() - 1);
}
-
- for (int i = 0; i < dateFormats.length; i++) {
- SimpleDateFormat dateParser = DateFormatHolder.formatFor(dateFormats[i]);
+
+ for (String dateFormat : dateFormats) {
+ SimpleDateFormat dateParser = DateFormatHolder.formatFor(dateFormat);
dateParser.set2DigitYearStart(startDate);
try {
return dateParser.parse(dateValue);
} catch (ParseException pe) {
// ignore this exception, we will try the next format
- }
+ }
}
// we were unable to parse the date
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java b/module-client/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java
index 78a4489..2411c44 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/NetscapeDomainHandler.java
@@ -30,6 +30,7 @@
*/
package org.apache.http.impl.cookie;
+import java.util.Locale;
import java.util.StringTokenizer;
import org.apache.http.cookie.Cookie;
@@ -49,7 +50,7 @@
// Perform Netscape Cookie draft specific validation
String host = origin.getHost();
String domain = cookie.getDomain();
- if (host.indexOf(".") >= 0) {
+ if (host.contains(".")) {
int domainParts = new StringTokenizer(domain, ".").countTokens();
if (isSpecialDomain(domain)) {
@@ -76,17 +77,14 @@
* @return True if the specified domain is "special"
*/
private static boolean isSpecialDomain(final String domain) {
- final String ucDomain = domain.toUpperCase();
- if (ucDomain.endsWith(".COM")
- || ucDomain.endsWith(".EDU")
- || ucDomain.endsWith(".NET")
- || ucDomain.endsWith(".GOV")
- || ucDomain.endsWith(".MIL")
- || ucDomain.endsWith(".ORG")
- || ucDomain.endsWith(".INT")) {
- return true;
- }
- return false;
+ final String ucDomain = domain.toUpperCase(Locale.ENGLISH);
+ return ucDomain.endsWith(".COM")
+ || ucDomain.endsWith(".EDU")
+ || ucDomain.endsWith(".NET")
+ || ucDomain.endsWith(".GOV")
+ || ucDomain.endsWith(".MIL")
+ || ucDomain.endsWith(".ORG")
+ || ucDomain.endsWith(".INT");
}
@Override
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java b/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java
index bb1040d..d0040b0 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109DomainHandler.java
@@ -30,6 +30,8 @@
*/
package org.apache.http.impl.cookie;
+import java.util.Locale;
+
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieAttributeHandler;
import org.apache.http.cookie.CookieOrigin;
@@ -50,7 +52,7 @@
if (value == null) {
throw new MalformedCookieException("Missing value for domain attribute");
}
- if (value.trim().equals("")) {
+ if (value.trim().length() == 0) {
throw new MalformedCookieException("Blank value for domain attribute");
}
cookie.setDomain(value);
@@ -90,7 +92,7 @@
+ domain
+ "\" violates RFC 2109: domain must contain an embedded dot");
}
- host = host.toLowerCase();
+ host = host.toLowerCase(Locale.ENGLISH);
if (!host.endsWith(domain)) {
throw new MalformedCookieException(
"Illegal domain attribute \"" + domain
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java b/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
index 65c2879..4b4d1d4 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109Spec.java
@@ -146,8 +146,7 @@
private List<Header> doFormatOneHeader(final List<Cookie> cookies) {
int version = Integer.MAX_VALUE;
// Pick the lowest common denominator
- for (int i = 0; i < cookies.size(); i++) {
- Cookie cookie = cookies.get(i);
+ for (Cookie cookie : cookies) {
if (cookie.getVersion() < version) {
version = cookie.getVersion();
}
@@ -157,9 +156,9 @@
buffer.append(": ");
buffer.append("$Version=");
buffer.append(Integer.toString(version));
- for (int i = 0; i < cookies.size(); i++) {
+ for (Cookie cooky : cookies) {
buffer.append("; ");
- Cookie cookie = cookies.get(i);
+ Cookie cookie = cooky;
formatCookieAsVer(buffer, cookie, version);
}
List<Header> headers = new ArrayList<Header>(1);
@@ -168,9 +167,8 @@
}
private List<Header> doFormatManyHeaders(final List<Cookie> cookies) {
- List<Header> headers = new ArrayList<Header>(cookies.size());
- for (int i = 0; i < cookies.size(); i++) {
- Cookie cookie = cookies.get(i);
+ List<Header> headers = new ArrayList<Header>(cookies.size());
+ for (Cookie cookie : cookies) {
int version = cookie.getVersion();
CharArrayBuffer buffer = new CharArrayBuffer(40);
buffer.append("Cookie: ");
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java b/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java
index f7f99ea..121dd8e 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/RFC2109VersionHandler.java
@@ -49,7 +49,7 @@
if (value == null) {
throw new MalformedCookieException("Missing value for version attribute");
}
- if (value.trim().equals("")) {
+ if (value.trim().length() == 0) {
throw new MalformedCookieException("Blank value for version attribute");
}
try {
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java b/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java
index 382b786..d2819c9 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965DomainAttributeHandler.java
@@ -31,6 +31,8 @@
package org.apache.http.impl.cookie;
+import java.util.Locale;
+
import org.apache.http.cookie.ClientCookie;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieAttributeHandler;
@@ -63,18 +65,18 @@
throw new MalformedCookieException(
"Missing value for domain attribute");
}
- if (domain.trim().equals("")) {
+ if (domain.trim().length() == 0) {
throw new MalformedCookieException(
"Blank value for domain attribute");
}
- domain = domain.toLowerCase();
+ domain = domain.toLowerCase(Locale.ENGLISH);
if (!domain.startsWith(".")) {
// Per RFC 2965 section 3.2.2
// "... If an explicitly specified value does not start with
// a dot, the user agent supplies a leading dot ..."
// That effectively implies that the domain attribute
// MAY NOT be an IP address of a host name
- domain = "." + domain;
+ domain = '.' + domain;
}
cookie.setDomain(domain);
}
@@ -112,12 +114,12 @@
if (origin == null) {
throw new IllegalArgumentException("Cookie origin may not be null");
}
- String host = origin.getHost().toLowerCase();
+ String host = origin.getHost().toLowerCase(Locale.ENGLISH);
if (cookie.getDomain() == null) {
throw new MalformedCookieException("Invalid cookie state: " +
"domain not specified");
}
- String cookieDomain = cookie.getDomain().toLowerCase();
+ String cookieDomain = cookie.getDomain().toLowerCase(Locale.ENGLISH);
if (cookie instanceof ClientCookie
&& ((ClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR)) {
@@ -176,7 +178,7 @@
if (origin == null) {
throw new IllegalArgumentException("Cookie origin may not be null");
}
- String host = origin.getHost().toLowerCase();
+ String host = origin.getHost().toLowerCase(Locale.ENGLISH);
String cookieDomain = cookie.getDomain();
// The effective host name MUST domain-match the Domain
@@ -187,10 +189,7 @@
// effective host name minus domain must not contain any dots
String effectiveHostWithoutDomain = host.substring(
0, host.length() - cookieDomain.length());
- if (effectiveHostWithoutDomain.indexOf('.') != -1) {
- return false;
- }
- return true;
+ return effectiveHostWithoutDomain.indexOf('.') == -1;
}
}
\ No newline at end of file
diff --git a/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java b/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
index afbb5cc..19f587c 100644
--- a/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
+++ b/module-client/src/main/java/org/apache/http/impl/cookie/RFC2965Spec.java
@@ -33,6 +33,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import org.apache.http.Header;
@@ -107,12 +108,10 @@
HeaderElement[] elems = header.getElements();
List<Cookie> cookies = new ArrayList<Cookie>(elems.length);
- for (int i = 0; i < elems.length; i++) {
- HeaderElement headerelement = elems[i];
-
+ for (HeaderElement headerelement : elems) {
String name = headerelement.getName();
String value = headerelement.getValue();
- if (name == null || name.equals("")) {
+ if (name == null || name.length() == 0) {
throw new MalformedCookieException("Cookie name may not be empty");
}
@@ -122,24 +121,24 @@
} else {
cookie = createCookie(name, value, origin);
}
-
+
// cycle through the parameters
NameValuePair[] attribs = headerelement.getParameters();
-
+
// Eliminate duplicate attributes. The first occurrence takes precedence
// See RFC2965: 3.2 Origin Server Role
- Map<String, NameValuePair> attribmap =
- new HashMap<String, NameValuePair>(attribs.length);
+ Map<String, NameValuePair> attribmap =
+ new HashMap<String, NameValuePair>(attribs.length);
for (int j = attribs.length - 1; j >= 0; j--) {
NameValuePair param = attribs[j];
- attribmap.put(param.getName().toLowerCase(), param);
+ attribmap.put(param.getName().toLowerCase(Locale.ENGLISH), param);
}
- for (Map.Entry<String, NameValuePair> entry: attribmap.entrySet()) {
+ for (Map.Entry<String, NameValuePair> entry : attribmap.entrySet()) {
NameValuePair attrib = entry.getValue();
- String s = attrib.getName().toLowerCase();
-
+ String s = attrib.getName().toLowerCase(Locale.ENGLISH);
+
cookie.setAttribute(s, attrib.getValue());
-
+
CookieAttributeHandler handler = findAttribHandler(s);
if (handler != null) {
handler.parse(cookie, attrib.getValue());
@@ -213,7 +212,7 @@
* the effective host name is the same as the host name. Note
* that all effective host names contain at least one dot.
*
- * @param host host name where cookie is received from or being sent to.
+ * @param origin origin where cookie is received from or being sent to.
* @return
*/
private static CookieOrigin adjustEffectiveHost(final CookieOrigin origin) {
diff --git a/module-client/src/test/java/org/apache/http/conn/TestAllConn.java b/module-client/src/test/java/org/apache/http/conn/TestAllConn.java
index dc39099..ab13424 100644
--- a/module-client/src/test/java/org/apache/http/conn/TestAllConn.java
+++ b/module-client/src/test/java/org/apache/http/conn/TestAllConn.java
@@ -50,6 +50,7 @@
suite.addTest(TestScheme.suite());
suite.addTest(TestExceptions.suite());
+ suite.addTest(TestConnectionReuse.suite());
suite.addTest(TestConnectionAutoRelease.suite());
suite.addTest(TestAllConnParams.suite());
suite.addTest(TestAllRouting.suite());
diff --git a/module-client/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java b/module-client/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java
index eb26daf..03b6653 100644
--- a/module-client/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java
+++ b/module-client/src/test/java/org/apache/http/conn/TestConnectionAutoRelease.java
@@ -200,8 +200,8 @@
assertNotNull(e);
httpget.abort();
- // Expect one connection in the pool
- assertEquals(1, mgr.getConnectionsInPool());
+ // Expect zero connections in the pool
+ assertEquals(0, mgr.getConnectionsInPool());
// Make sure one connection is available
connreq = mgr.requestConnection(new HttpRoute(target), null);
@@ -281,8 +281,8 @@
}
- // Expect one connection in the pool
- assertEquals(1, mgr.getConnectionsInPool());
+ // Expect zero connections in the pool
+ assertEquals(0, mgr.getConnectionsInPool());
// Make sure one connection is available
connreq = mgr.requestConnection(new HttpRoute(target), null);
diff --git a/module-client/src/test/java/org/apache/http/conn/TestConnectionReuse.java b/module-client/src/test/java/org/apache/http/conn/TestConnectionReuse.java
new file mode 100644
index 0000000..73c1f2e
--- /dev/null
+++ b/module-client/src/test/java/org/apache/http/conn/TestConnectionReuse.java
@@ -0,0 +1,345 @@
+/*
+ * $HeadURL:$
+ * $Revision:$
+ * $Date:$
+ *
+ * ====================================================================
+ * 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
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.conn;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.URI;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpException;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpResponseInterceptor;
+import org.apache.http.HttpVersion;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.conn.params.ConnPerRouteBean;
+import org.apache.http.conn.params.HttpConnectionManagerParams;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.scheme.SocketFactory;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.localserver.LocalTestServer;
+import org.apache.http.localserver.RandomHandler;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.protocol.BasicHttpProcessor;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.ResponseConnControl;
+import org.apache.http.protocol.ResponseContent;
+import org.apache.http.protocol.ResponseDate;
+import org.apache.http.protocol.ResponseServer;
+
+public class TestConnectionReuse extends TestCase {
+
+ public TestConnectionReuse(String testName) {
+ super(testName);
+ }
+
+ public static void main(String args[]) {
+ String[] testCaseName = { TestConnectionReuse.class.getName() };
+ junit.textui.TestRunner.main(testCaseName);
+ }
+
+ public static Test suite() {
+ return new TestSuite(TestConnectionReuse.class);
+ }
+
+ protected LocalTestServer localServer;
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (this.localServer != null) {
+ this.localServer.stop();
+ }
+ }
+
+
+ public void testReuseOfPersistentConnections() throws Exception {
+ BasicHttpProcessor httpproc = new BasicHttpProcessor();
+ httpproc.addInterceptor(new ResponseDate());
+ httpproc.addInterceptor(new ResponseServer());
+ httpproc.addInterceptor(new ResponseContent());
+ httpproc.addInterceptor(new ResponseConnControl());
+
+ this.localServer = new LocalTestServer(httpproc, null);
+ this.localServer.register("/random/*", new RandomHandler());
+ this.localServer.start();
+
+ InetSocketAddress saddress = (InetSocketAddress) this.localServer.getServiceAddress();
+
+ HttpParams params = new BasicHttpParams();
+ HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+ HttpProtocolParams.setContentCharset(params, "UTF-8");
+ HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
+ HttpProtocolParams.setUseExpectContinue(params, false);
+ HttpConnectionParams.setStaleCheckingEnabled(params, false);
+ HttpConnectionManagerParams.setMaxTotalConnections(params, 5);
+ HttpConnectionManagerParams.setMaxConnectionsPerRoute(params,
+ new ConnPerRouteBean(5));
+
+ SchemeRegistry supportedSchemes = new SchemeRegistry();
+ SocketFactory sf = PlainSocketFactory.getSocketFactory();
+ supportedSchemes.register(new Scheme("http", sf, 80));
+
+ ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(
+ params, supportedSchemes);
+
+ DefaultHttpClient client = new DefaultHttpClient(mgr, params);
+
+ HttpHost target = new HttpHost(saddress.getHostName(), saddress.getPort(), "http");
+
+ WorkerThread[] workers = new WorkerThread[10];
+ for (int i = 0; i < workers.length; i++) {
+ workers[i] = new WorkerThread(
+ client,
+ target,
+ new URI("/random/2000"),
+ 10, false);
+ }
+
+ for (int i = 0; i < workers.length; i++) {
+ WorkerThread worker = workers[i];
+ worker.start();
+ }
+ for (int i = 0; i < workers.length; i++) {
+ WorkerThread worker = workers[i];
+ workers[i].join(10000);
+ Exception ex = worker.getException();
+ if (ex != null) {
+ throw ex;
+ }
+ }
+
+ // Expect some connection in the pool
+ assertTrue(mgr.getConnectionsInPool() > 0);
+
+ mgr.shutdown();
+ }
+
+ private static class AlwaysCloseConn implements HttpResponseInterceptor {
+
+ public void process(
+ final HttpResponse response,
+ final HttpContext context) throws HttpException, IOException {
+ response.setHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE);
+ }
+
+ }
+
+ public void testReuseOfClosedConnections() throws Exception {
+ BasicHttpProcessor httpproc = new BasicHttpProcessor();
+ httpproc.addInterceptor(new ResponseDate());
+ httpproc.addInterceptor(new ResponseServer());
+ httpproc.addInterceptor(new ResponseContent());
+ httpproc.addInterceptor(new AlwaysCloseConn());
+
+ this.localServer = new LocalTestServer(httpproc, null);
+ this.localServer.register("/random/*", new RandomHandler());
+ this.localServer.start();
+
+ InetSocketAddress saddress = (InetSocketAddress) this.localServer.getServiceAddress();
+
+ HttpParams params = new BasicHttpParams();
+ HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+ HttpProtocolParams.setContentCharset(params, "UTF-8");
+ HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
+ HttpProtocolParams.setUseExpectContinue(params, false);
+ HttpConnectionParams.setStaleCheckingEnabled(params, false);
+ HttpConnectionManagerParams.setMaxTotalConnections(params, 5);
+ HttpConnectionManagerParams.setMaxConnectionsPerRoute(params,
+ new ConnPerRouteBean(5));
+
+ SchemeRegistry supportedSchemes = new SchemeRegistry();
+ SocketFactory sf = PlainSocketFactory.getSocketFactory();
+ supportedSchemes.register(new Scheme("http", sf, 80));
+
+ ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(
+ params, supportedSchemes);
+
+ DefaultHttpClient client = new DefaultHttpClient(mgr, params);
+
+ HttpHost target = new HttpHost(saddress.getHostName(), saddress.getPort(), "http");
+
+ WorkerThread[] workers = new WorkerThread[10];
+ for (int i = 0; i < workers.length; i++) {
+ workers[i] = new WorkerThread(
+ client,
+ target,
+ new URI("/random/2000"),
+ 10, false);
+ }
+
+ for (int i = 0; i < workers.length; i++) {
+ WorkerThread worker = workers[i];
+ worker.start();
+ }
+ for (int i = 0; i < workers.length; i++) {
+ WorkerThread worker = workers[i];
+ workers[i].join(10000);
+ Exception ex = worker.getException();
+ if (ex != null) {
+ throw ex;
+ }
+ }
+
+ // Expect zero connections in the pool
+ assertEquals(0, mgr.getConnectionsInPool());
+
+ mgr.shutdown();
+ }
+
+ public void testReuseOfAbortedConnections() throws Exception {
+ BasicHttpProcessor httpproc = new BasicHttpProcessor();
+ httpproc.addInterceptor(new ResponseDate());
+ httpproc.addInterceptor(new ResponseServer());
+ httpproc.addInterceptor(new ResponseContent());
+ httpproc.addInterceptor(new ResponseConnControl());
+
+ this.localServer = new LocalTestServer(httpproc, null);
+ this.localServer.register("/random/*", new RandomHandler());
+ this.localServer.start();
+
+ InetSocketAddress saddress = (InetSocketAddress) this.localServer.getServiceAddress();
+
+ HttpParams params = new BasicHttpParams();
+ HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+ HttpProtocolParams.setContentCharset(params, "UTF-8");
+ HttpProtocolParams.setUserAgent(params, "TestAgent/1.1");
+ HttpProtocolParams.setUseExpectContinue(params, false);
+ HttpConnectionParams.setStaleCheckingEnabled(params, false);
+ HttpConnectionManagerParams.setMaxTotalConnections(params, 5);
+ HttpConnectionManagerParams.setMaxConnectionsPerRoute(params,
+ new ConnPerRouteBean(5));
+
+ SchemeRegistry supportedSchemes = new SchemeRegistry();
+ SocketFactory sf = PlainSocketFactory.getSocketFactory();
+ supportedSchemes.register(new Scheme("http", sf, 80));
+
+ ThreadSafeClientConnManager mgr = new ThreadSafeClientConnManager(
+ params, supportedSchemes);
+
+ DefaultHttpClient client = new DefaultHttpClient(mgr, params);
+
+ HttpHost target = new HttpHost(saddress.getHostName(), saddress.getPort(), "http");
+
+ WorkerThread[] workers = new WorkerThread[10];
+ for (int i = 0; i < workers.length; i++) {
+ workers[i] = new WorkerThread(
+ client,
+ target,
+ new URI("/random/2000"),
+ 10, true);
+ }
+
+ for (int i = 0; i < workers.length; i++) {
+ WorkerThread worker = workers[i];
+ worker.start();
+ }
+ for (int i = 0; i < workers.length; i++) {
+ WorkerThread worker = workers[i];
+ workers[i].join(10000);
+ Exception ex = worker.getException();
+ if (ex != null) {
+ throw ex;
+ }
+ }
+
+ // Expect zero connections in the pool
+ assertEquals(0, mgr.getConnectionsInPool());
+
+ mgr.shutdown();
+ }
+
+ private static class WorkerThread extends Thread {
+
+ private final URI requestURI;
+ private final HttpHost target;
+ private final HttpClient httpclient;
+ private final int repetitions;
+ private final boolean forceClose;
+
+ private volatile Exception exception;
+
+ public WorkerThread(
+ final HttpClient httpclient,
+ final HttpHost target,
+ final URI requestURI,
+ int repetitions,
+ boolean forceClose) {
+ super();
+ this.httpclient = httpclient;
+ this.requestURI = requestURI;
+ this.target = target;
+ this.repetitions = repetitions;
+ this.forceClose = forceClose;
+ }
+
+ @Override
+ public void run() {
+ try {
+ for (int i = 0; i < this.repetitions; i++) {
+ HttpGet httpget = new HttpGet(this.requestURI);
+ HttpResponse response = this.httpclient.execute(
+ this.target,
+ httpget);
+ if (this.forceClose) {
+ httpget.abort();
+ } else {
+ HttpEntity entity = response.getEntity();
+ if (entity != null) {
+ entity.consumeContent();
+ }
+ }
+ }
+ } catch (Exception ex) {
+ this.exception = ex;
+ }
+ }
+
+ public Exception getException() {
+ return exception;
+ }
+
+ }
+
+}
diff --git a/module-client/src/test/java/org/apache/http/cookie/TestCookiePolicy.java b/module-client/src/test/java/org/apache/http/cookie/TestCookiePolicy.java
index 79dfca0..7ae8c23 100644
--- a/module-client/src/test/java/org/apache/http/cookie/TestCookiePolicy.java
+++ b/module-client/src/test/java/org/apache/http/cookie/TestCookiePolicy.java
@@ -31,6 +31,7 @@
package org.apache.http.cookie;
import java.util.List;
+import java.util.Locale;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -85,9 +86,9 @@
names = registry.getSpecNames();
assertNotNull(names);
assertEquals(3, names.size());
- assertEquals(BROWSER_COMPATIBILITY.toLowerCase(), names.get(0));
- assertEquals(NETSCAPE.toLowerCase(), names.get(1));
- assertEquals(RFC_2109.toLowerCase(), names.get(2));
+ assertEquals(BROWSER_COMPATIBILITY.toLowerCase(Locale.ENGLISH), names.get(0));
+ assertEquals(NETSCAPE.toLowerCase(Locale.ENGLISH), names.get(1));
+ assertEquals(RFC_2109.toLowerCase(Locale.ENGLISH), names.get(2));
registry.unregister(NETSCAPE);
registry.unregister(NETSCAPE);
diff --git a/module-client/src/test/java/org/apache/http/impl/conn/ClientConnAdapterMockup.java b/module-client/src/test/java/org/apache/http/impl/conn/ClientConnAdapterMockup.java
index dcc6f20..7c5628f 100644
--- a/module-client/src/test/java/org/apache/http/impl/conn/ClientConnAdapterMockup.java
+++ b/module-client/src/test/java/org/apache/http/impl/conn/ClientConnAdapterMockup.java
@@ -64,7 +64,6 @@
}
public void shutdown() {
- throw new UnsupportedOperationException("just a mockup");
}
public void tunnelTarget(boolean secure, HttpParams params) {
diff --git a/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java b/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java
index 9353e01..95a0bf0 100644
--- a/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java
+++ b/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestConnPoolByRoute.java
@@ -1,7 +1,7 @@
/*
- * $HeadURL:$
- * $Revision:$
- * $Date:$
+ * $HeadURL$
+ * $Revision$
+ * $Date$
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -95,7 +95,7 @@
}
// Free one
- connPool.freeEntry(e3);
+ connPool.freeEntry(e3, true);
// This time the request should succeed
PoolEntryRequest r5 = connPool.requestPoolEntry(route, null);
@@ -136,9 +136,9 @@
e3.setState(Integer.valueOf(3));
// Release entries
- connPool.freeEntry(e1);
- connPool.freeEntry(e2);
- connPool.freeEntry(e3);
+ connPool.freeEntry(e1, true);
+ connPool.freeEntry(e2, true);
+ connPool.freeEntry(e3, true);
// Request statefull entries
PoolEntryRequest r4 = connPool.requestPoolEntry(route, Integer.valueOf(2));
@@ -160,9 +160,9 @@
assertTrue(e6 == e1);
// Release entries again
- connPool.freeEntry(e4);
- connPool.freeEntry(e5);
- connPool.freeEntry(e6);
+ connPool.freeEntry(e4, true);
+ connPool.freeEntry(e5, true);
+ connPool.freeEntry(e6, true);
// Request an entry with a state not avaialable in the pool
PoolEntryRequest r7 = connPool.requestPoolEntry(route, Integer.valueOf(4));
diff --git a/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java b/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
index 46a13c1..53b392c 100644
--- a/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
+++ b/module-client/src/test/java/org/apache/http/impl/conn/tsccm/TestSpuriousWakeup.java
@@ -101,6 +101,7 @@
super(operator, params);
}
+ @Override
protected synchronized
WaitingThread newWaitingThread(Condition cond,
RouteSpecificPool rospl) {
@@ -125,6 +126,7 @@
super(params, schreg);
}
+ @Override
protected AbstractConnPool createConnectionPool(HttpParams params) {
extendedCPBR = new XConnPoolByRoute(connOperator, params);
// no connection GC required
diff --git a/module-client/src/test/java/org/apache/http/localserver/EchoHandler.java b/module-client/src/test/java/org/apache/http/localserver/EchoHandler.java
index 88a8bf7..24c70f6 100644
--- a/module-client/src/test/java/org/apache/http/localserver/EchoHandler.java
+++ b/module-client/src/test/java/org/apache/http/localserver/EchoHandler.java
@@ -32,6 +32,7 @@
package org.apache.http.localserver;
import java.io.IOException;
+import java.util.Locale;
import org.apache.http.HttpEntity;
import org.apache.http.HttpEntityEnclosingRequest;
@@ -78,7 +79,7 @@
final HttpContext context)
throws HttpException, IOException {
- String method = request.getRequestLine().getMethod().toUpperCase();
+ String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
if (!"GET".equals(method) &&
!"POST".equals(method) &&
!"PUT".equals(method)
diff --git a/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java b/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java
index 74e8bf6..64c087d 100644
--- a/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java
+++ b/module-client/src/test/java/org/apache/http/localserver/LocalTestServer.java
@@ -35,6 +35,7 @@
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
+import java.net.SocketAddress;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -157,7 +158,7 @@
.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY,
true)
.setParameter(CoreProtocolPNames.ORIGIN_SERVER,
- "Jakarta-HttpComponents-LocalTestServer/1.1");
+ "LocalTestServer/1.1");
return params;
}
@@ -280,6 +281,19 @@
/**
+ * Obtains the local address the server is listening on
+ *
+ * @return the service address
+ */
+ public SocketAddress getServiceAddress() {
+ ServerSocket ssock = servicedSocket; // avoid synchronization
+ if (ssock == null)
+ throw new IllegalStateException("not running");
+
+ return ssock.getLocalSocketAddress();
+ }
+
+ /**
* The request listener.
* Accepts incoming connections and launches a service thread.
*/
diff --git a/module-client/src/test/java/org/apache/http/localserver/RandomHandler.java b/module-client/src/test/java/org/apache/http/localserver/RandomHandler.java
index 54fbea6..d0e9f8d 100644
--- a/module-client/src/test/java/org/apache/http/localserver/RandomHandler.java
+++ b/module-client/src/test/java/org/apache/http/localserver/RandomHandler.java
@@ -35,6 +35,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
+import java.util.Locale;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
@@ -82,7 +83,7 @@
final HttpContext context)
throws HttpException, IOException {
- String method = request.getRequestLine().getMethod().toUpperCase();
+ String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
if (!"GET".equals(method) && !"HEAD".equals(method)) {
throw new MethodNotSupportedException
(method + " not supported by " + getClass().getName());
diff --git a/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java b/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java
index c524c78..ab32720 100644
--- a/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java
+++ b/module-client/src/test/java/org/apache/http/localserver/ServerTestBase.java
@@ -119,7 +119,7 @@
HttpProtocolParams.setContentCharset
(defaultParams, "UTF-8");
HttpProtocolParams.setUserAgent
- (defaultParams, "Jakarta-HttpComponents-Test/1.1");
+ (defaultParams, "TestAgent/1.1");
HttpProtocolParams.setUseExpectContinue
(defaultParams, false);
}
diff --git a/module-client/src/test/java/org/apache/http/mockup/ProxySelectorMockup.java b/module-client/src/test/java/org/apache/http/mockup/ProxySelectorMockup.java
index 9be9c96..a0816ee 100644
--- a/module-client/src/test/java/org/apache/http/mockup/ProxySelectorMockup.java
+++ b/module-client/src/test/java/org/apache/http/mockup/ProxySelectorMockup.java
@@ -79,6 +79,7 @@
* @return the list passed to the constructor,
* or a default list with "DIRECT" as the only element
*/
+ @Override
public List<Proxy> select(URI ignored) {
return proxyList;
}
@@ -87,6 +88,7 @@
/**
* Does nothing.
*/
+ @Override
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
// no body
}
diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt
index cf954be..3d6d147 100644
--- a/src/site/apt/index.apt
+++ b/src/site/apt/index.apt
@@ -113,16 +113,16 @@
HttpClient strives to conform to the following specifications endorsed by the Internet
Engineering Task Force (IETF) and the internet at large:
- * {{{http://www.ietf.org/rfc/rfc1945.txt}RFC 1945}} - Hypertext Transfer Protocol -- HTTP/1.0
+ * {{{http://www.ietf.org/rfc/rfc1945.txt}RFC 1945}} Hypertext Transfer Protocol -- HTTP/1.0
- * {{{http://www.ietf.org/rfc/rfc2616.txt}RFC 2116}} - Hypertext Transfer Protocol -- HTTP/1.1
+ * {{{http://www.ietf.org/rfc/rfc2616.txt}RFC 2616}} Hypertext Transfer Protocol -- HTTP/1.1
- * {{{http://www.ietf.org/rfc/rfc2617.txt}RFC2617}} HTTP Authentication: Basic and Digest Access
+ * {{{http://www.ietf.org/rfc/rfc2617.txt}RFC 2617}} HTTP Authentication: Basic and Digest Access
Authentication
- * {{{http://www.ietf.org/rfc/rfc2109.txt}RFC2109}} HTTP State Management Mechanism (Cookies)
+ * {{{http://www.ietf.org/rfc/rfc2109.txt}RFC 2109}} HTTP State Management Mechanism (Cookies)
- * {{{http://www.ietf.org/rfc/rfc2965.txt}RFC2965}} HTTP State Management Mechanism (Cookies v2)
+ * {{{http://www.ietf.org/rfc/rfc2965.txt}RFC 2965}} HTTP State Management Mechanism (Cookies v2)
Examples