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;
|
import org.apache.http.protocol.HttpContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link CookieSpecProvider} implementation that creates and initializes
|
* {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
|
||||||
* {@link BestMatchSpec} instances.
|
* {@link org.apache.http.impl.cookie.BestMatchSpec}. The instance returned by this factory can
|
||||||
|
* be shared by multiple threads.
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
|
@ -47,13 +48,11 @@ import org.apache.http.protocol.HttpContext;
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class BestMatchSpecFactory implements CookieSpecFactory, CookieSpecProvider {
|
public class BestMatchSpecFactory implements CookieSpecFactory, CookieSpecProvider {
|
||||||
|
|
||||||
private final String[] datepatterns;
|
private final CookieSpec cookieSpec;
|
||||||
private final boolean oneHeader;
|
|
||||||
|
|
||||||
public BestMatchSpecFactory(final String[] datepatterns, final boolean oneHeader) {
|
public BestMatchSpecFactory(final String[] datepatterns, final boolean oneHeader) {
|
||||||
super();
|
super();
|
||||||
this.datepatterns = datepatterns;
|
this.cookieSpec = new BestMatchSpec(datepatterns, oneHeader);;
|
||||||
this.oneHeader = oneHeader;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BestMatchSpecFactory() {
|
public BestMatchSpecFactory() {
|
||||||
|
@ -82,7 +81,7 @@ public class BestMatchSpecFactory implements CookieSpecFactory, CookieSpecProvid
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CookieSpec create(final HttpContext context) {
|
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;
|
import org.apache.http.protocol.HttpContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link CookieSpecProvider} implementation that creates and initializes
|
* {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
|
||||||
* {@link BrowserCompatSpec} instances.
|
* {@link org.apache.http.impl.cookie.BrowserCompatSpec}. The instance returned by this factory
|
||||||
|
* can be shared by multiple threads.
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
|
@ -52,13 +53,13 @@ public class BrowserCompatSpecFactory implements CookieSpecFactory, CookieSpecPr
|
||||||
SECURITYLEVEL_IE_MEDIUM
|
SECURITYLEVEL_IE_MEDIUM
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String[] datepatterns;
|
|
||||||
private final SecurityLevel securityLevel;
|
private final SecurityLevel securityLevel;
|
||||||
|
private final CookieSpec cookieSpec;
|
||||||
|
|
||||||
public BrowserCompatSpecFactory(final String[] datepatterns, final SecurityLevel securityLevel) {
|
public BrowserCompatSpecFactory(final String[] datepatterns, final SecurityLevel securityLevel) {
|
||||||
super();
|
super();
|
||||||
this.datepatterns = datepatterns;
|
|
||||||
this.securityLevel = securityLevel;
|
this.securityLevel = securityLevel;
|
||||||
|
this.cookieSpec = new BrowserCompatSpec(datepatterns, securityLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BrowserCompatSpecFactory(final String[] datepatterns) {
|
public BrowserCompatSpecFactory(final String[] datepatterns) {
|
||||||
|
@ -88,7 +89,7 @@ public class BrowserCompatSpecFactory implements CookieSpecFactory, CookieSpecPr
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CookieSpec create(final HttpContext context) {
|
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;
|
import org.apache.http.protocol.HttpContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link CookieSpecProvider} implementation that creates and initializes
|
* {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
|
||||||
* {@link NetscapeDraftSpec} instances.
|
* {@link org.apache.http.impl.cookie.NetscapeDraftSpec}. The instance returned by this factory
|
||||||
|
* can be shared by multiple threads.
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
|
@ -47,11 +48,11 @@ import org.apache.http.protocol.HttpContext;
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class NetscapeDraftSpecFactory implements CookieSpecFactory, CookieSpecProvider {
|
public class NetscapeDraftSpecFactory implements CookieSpecFactory, CookieSpecProvider {
|
||||||
|
|
||||||
private final String[] datepatterns;
|
private final CookieSpec cookieSpec;
|
||||||
|
|
||||||
public NetscapeDraftSpecFactory(final String[] datepatterns) {
|
public NetscapeDraftSpecFactory(final String[] datepatterns) {
|
||||||
super();
|
super();
|
||||||
this.datepatterns = datepatterns;
|
this.cookieSpec = new NetscapeDraftSpec(datepatterns);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetscapeDraftSpecFactory() {
|
public NetscapeDraftSpecFactory() {
|
||||||
|
@ -77,11 +78,7 @@ public class NetscapeDraftSpecFactory implements CookieSpecFactory, CookieSpecPr
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CookieSpec create(final HttpContext context) {
|
public CookieSpec create(final HttpContext context) {
|
||||||
|
return this.cookieSpec;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return new NetscapeDraftSpec(this.datepatterns);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,9 @@ import org.apache.http.params.HttpParams;
|
||||||
import org.apache.http.protocol.HttpContext;
|
import org.apache.http.protocol.HttpContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link CookieSpecProvider} implementation that creates and initializes
|
* {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
|
||||||
* {@link RFC2109Spec} instances.
|
* {@link org.apache.http.impl.cookie.RFC2109Spec}. The instance returned by this factory
|
||||||
|
* can be shared by multiple threads.
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
|
@ -47,13 +48,11 @@ import org.apache.http.protocol.HttpContext;
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class RFC2109SpecFactory implements CookieSpecFactory, CookieSpecProvider {
|
public class RFC2109SpecFactory implements CookieSpecFactory, CookieSpecProvider {
|
||||||
|
|
||||||
private final String[] datepatterns;
|
private final CookieSpec cookieSpec;
|
||||||
private final boolean oneHeader;
|
|
||||||
|
|
||||||
public RFC2109SpecFactory(final String[] datepatterns, final boolean oneHeader) {
|
public RFC2109SpecFactory(final String[] datepatterns, final boolean oneHeader) {
|
||||||
super();
|
super();
|
||||||
this.datepatterns = datepatterns;
|
this.cookieSpec = new RFC2109Spec(datepatterns, oneHeader);
|
||||||
this.oneHeader = oneHeader;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RFC2109SpecFactory() {
|
public RFC2109SpecFactory() {
|
||||||
|
@ -82,7 +81,7 @@ public class RFC2109SpecFactory implements CookieSpecFactory, CookieSpecProvider
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CookieSpec create(final HttpContext context) {
|
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;
|
import org.apache.http.protocol.HttpContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link CookieSpecProvider} implementation that creates and initializes
|
* {@link org.apache.http.cookie.CookieSpecProvider} implementation that provides an instance of
|
||||||
* {@link RFC2965Spec} instances.
|
* {@link org.apache.http.impl.cookie.RFC2965Spec}. The instance returned by this factory can
|
||||||
|
* be shared by multiple threads.
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
|
@ -47,13 +48,11 @@ import org.apache.http.protocol.HttpContext;
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class RFC2965SpecFactory implements CookieSpecFactory, CookieSpecProvider {
|
public class RFC2965SpecFactory implements CookieSpecFactory, CookieSpecProvider {
|
||||||
|
|
||||||
private final String[] datepatterns;
|
private final CookieSpec cookieSpec;
|
||||||
private final boolean oneHeader;
|
|
||||||
|
|
||||||
public RFC2965SpecFactory(final String[] datepatterns, final boolean oneHeader) {
|
public RFC2965SpecFactory(final String[] datepatterns, final boolean oneHeader) {
|
||||||
super();
|
super();
|
||||||
this.datepatterns = datepatterns;
|
this.cookieSpec = new RFC2965Spec(datepatterns, oneHeader);
|
||||||
this.oneHeader = oneHeader;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RFC2965SpecFactory() {
|
public RFC2965SpecFactory() {
|
||||||
|
@ -82,7 +81,7 @@ public class RFC2965SpecFactory implements CookieSpecFactory, CookieSpecProvider
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CookieSpec create(final HttpContext context) {
|
public CookieSpec create(final HttpContext context) {
|
||||||
return new RFC2965Spec(this.datepatterns, this.oneHeader);
|
return this.cookieSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue