Cookie spec provides to re-use the same thread-safe CookieSpec instance by default
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1620787 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
70d3412315
commit
92700fd23b
|
@ -38,8 +38,9 @@ import org.apache.http.params.HttpParams;
|
|||
import org.apache.http.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* {@link CookieSpecProvider} implementation that creates and initializes
|
||||
* {@link BestMatchSpec} instances.
|
||||
* {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
|
||||
* {@link org.apache.http.impl.cookie.BestMatchSpec}. The instance returned by this factory can
|
||||
* be shared by multiple threads.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
|
@ -47,13 +48,11 @@ import org.apache.http.protocol.HttpContext;
|
|||
@SuppressWarnings("deprecation")
|
||||
public class BestMatchSpecFactory implements CookieSpecFactory, CookieSpecProvider {
|
||||
|
||||
private final String[] datepatterns;
|
||||
private final boolean oneHeader;
|
||||
private final CookieSpec cookieSpec;
|
||||
|
||||
public BestMatchSpecFactory(final String[] datepatterns, final boolean oneHeader) {
|
||||
super();
|
||||
this.datepatterns = datepatterns;
|
||||
this.oneHeader = oneHeader;
|
||||
this.cookieSpec = new BestMatchSpec(datepatterns, oneHeader);;
|
||||
}
|
||||
|
||||
public BestMatchSpecFactory() {
|
||||
|
@ -82,7 +81,7 @@ public class BestMatchSpecFactory implements CookieSpecFactory, CookieSpecProvid
|
|||
|
||||
@Override
|
||||
public CookieSpec create(final HttpContext context) {
|
||||
return new BestMatchSpec(this.datepatterns, this.oneHeader);
|
||||
return this.cookieSpec;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,8 +38,9 @@ import org.apache.http.params.HttpParams;
|
|||
import org.apache.http.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* {@link CookieSpecProvider} implementation that creates and initializes
|
||||
* {@link BrowserCompatSpec} instances.
|
||||
* {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
|
||||
* {@link org.apache.http.impl.cookie.BrowserCompatSpec}. The instance returned by this factory
|
||||
* can be shared by multiple threads.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
|
@ -52,13 +53,13 @@ public class BrowserCompatSpecFactory implements CookieSpecFactory, CookieSpecPr
|
|||
SECURITYLEVEL_IE_MEDIUM
|
||||
}
|
||||
|
||||
private final String[] datepatterns;
|
||||
private final SecurityLevel securityLevel;
|
||||
private final CookieSpec cookieSpec;
|
||||
|
||||
public BrowserCompatSpecFactory(final String[] datepatterns, final SecurityLevel securityLevel) {
|
||||
super();
|
||||
this.datepatterns = datepatterns;
|
||||
this.securityLevel = securityLevel;
|
||||
this.cookieSpec = new BrowserCompatSpec(datepatterns, securityLevel);
|
||||
}
|
||||
|
||||
public BrowserCompatSpecFactory(final String[] datepatterns) {
|
||||
|
@ -88,7 +89,7 @@ public class BrowserCompatSpecFactory implements CookieSpecFactory, CookieSpecPr
|
|||
|
||||
@Override
|
||||
public CookieSpec create(final HttpContext context) {
|
||||
return new BrowserCompatSpec(this.datepatterns);
|
||||
return this.cookieSpec;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,8 +38,9 @@ import org.apache.http.params.HttpParams;
|
|||
import org.apache.http.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* {@link CookieSpecProvider} implementation that creates and initializes
|
||||
* {@link NetscapeDraftSpec} instances.
|
||||
* {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
|
||||
* {@link org.apache.http.impl.cookie.NetscapeDraftSpec}. The instance returned by this factory
|
||||
* can be shared by multiple threads.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
|
@ -47,11 +48,11 @@ import org.apache.http.protocol.HttpContext;
|
|||
@SuppressWarnings("deprecation")
|
||||
public class NetscapeDraftSpecFactory implements CookieSpecFactory, CookieSpecProvider {
|
||||
|
||||
private final String[] datepatterns;
|
||||
private final CookieSpec cookieSpec;
|
||||
|
||||
public NetscapeDraftSpecFactory(final String[] datepatterns) {
|
||||
super();
|
||||
this.datepatterns = datepatterns;
|
||||
this.cookieSpec = new NetscapeDraftSpec(datepatterns);
|
||||
}
|
||||
|
||||
public NetscapeDraftSpecFactory() {
|
||||
|
@ -77,11 +78,7 @@ public class NetscapeDraftSpecFactory implements CookieSpecFactory, CookieSpecPr
|
|||
|
||||
@Override
|
||||
public CookieSpec create(final HttpContext context) {
|
||||
|
||||
|
||||
|
||||
|
||||
return new NetscapeDraftSpec(this.datepatterns);
|
||||
return this.cookieSpec;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,8 +38,9 @@ import org.apache.http.params.HttpParams;
|
|||
import org.apache.http.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* {@link CookieSpecProvider} implementation that creates and initializes
|
||||
* {@link RFC2109Spec} instances.
|
||||
* {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
|
||||
* {@link org.apache.http.impl.cookie.RFC2109Spec}. The instance returned by this factory
|
||||
* can be shared by multiple threads.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
|
@ -47,13 +48,11 @@ import org.apache.http.protocol.HttpContext;
|
|||
@SuppressWarnings("deprecation")
|
||||
public class RFC2109SpecFactory implements CookieSpecFactory, CookieSpecProvider {
|
||||
|
||||
private final String[] datepatterns;
|
||||
private final boolean oneHeader;
|
||||
private final CookieSpec cookieSpec;
|
||||
|
||||
public RFC2109SpecFactory(final String[] datepatterns, final boolean oneHeader) {
|
||||
super();
|
||||
this.datepatterns = datepatterns;
|
||||
this.oneHeader = oneHeader;
|
||||
this.cookieSpec = new RFC2109Spec(datepatterns, oneHeader);
|
||||
}
|
||||
|
||||
public RFC2109SpecFactory() {
|
||||
|
@ -82,7 +81,7 @@ public class RFC2109SpecFactory implements CookieSpecFactory, CookieSpecProvider
|
|||
|
||||
@Override
|
||||
public CookieSpec create(final HttpContext context) {
|
||||
return new RFC2109Spec(this.datepatterns, this.oneHeader);
|
||||
return this.cookieSpec;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,8 +38,9 @@ import org.apache.http.params.HttpParams;
|
|||
import org.apache.http.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* {@link CookieSpecProvider} implementation that creates and initializes
|
||||
* {@link RFC2965Spec} instances.
|
||||
* {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
|
||||
* {@link org.apache.http.impl.cookie.RFC2965Spec}. The instance returned by this factory can
|
||||
* be shared by multiple threads.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
|
@ -47,13 +48,11 @@ import org.apache.http.protocol.HttpContext;
|
|||
@SuppressWarnings("deprecation")
|
||||
public class RFC2965SpecFactory implements CookieSpecFactory, CookieSpecProvider {
|
||||
|
||||
private final String[] datepatterns;
|
||||
private final boolean oneHeader;
|
||||
private final CookieSpec cookieSpec;
|
||||
|
||||
public RFC2965SpecFactory(final String[] datepatterns, final boolean oneHeader) {
|
||||
super();
|
||||
this.datepatterns = datepatterns;
|
||||
this.oneHeader = oneHeader;
|
||||
this.cookieSpec = new RFC2965Spec(datepatterns, oneHeader);
|
||||
}
|
||||
|
||||
public RFC2965SpecFactory() {
|
||||
|
@ -82,7 +81,7 @@ public class RFC2965SpecFactory implements CookieSpecFactory, CookieSpecProvider
|
|||
|
||||
@Override
|
||||
public CookieSpec create(final HttpContext context) {
|
||||
return new RFC2965Spec(this.datepatterns, this.oneHeader);
|
||||
return this.cookieSpec;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue