mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-16 23:16:33 +00:00
HTTPCLIENT-773: Improved handling of the 'expires' attribute by the 'Best Match' cookie spec
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@657334 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
14d0e406a3
commit
c9a4970c10
@ -1,6 +1,10 @@
|
|||||||
Changes since 4.0 Alpha 4
|
Changes since 4.0 Alpha 4
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* [HTTPCLIENT-773] Improved handling of the 'expires' attribute by the
|
||||||
|
'Best Match' cookie spec.
|
||||||
|
Contributed by Oleg Kalnichevski <olegk at apache.org>
|
||||||
|
|
||||||
* Partial NTLM support (requires an external NTLM engine). For details see
|
* Partial NTLM support (requires an external NTLM engine). For details see
|
||||||
NTLM_SUPPORT.txt
|
NTLM_SUPPORT.txt
|
||||||
Contributed by Oleg Kalnichevski <olegk at apache.org>
|
Contributed by Oleg Kalnichevski <olegk at apache.org>
|
||||||
|
@ -83,7 +83,11 @@ private BrowserCompatSpec getCompat() {
|
|||||||
|
|
||||||
private NetscapeDraftSpec getNetscape() {
|
private NetscapeDraftSpec getNetscape() {
|
||||||
if (this.netscape == null) {
|
if (this.netscape == null) {
|
||||||
this.netscape = new NetscapeDraftSpec();
|
String[] patterns = this.datepatterns;
|
||||||
|
if (patterns == null) {
|
||||||
|
patterns = BrowserCompatSpec.DATE_PATTERNS;
|
||||||
|
}
|
||||||
|
this.netscape = new NetscapeDraftSpec(patterns);
|
||||||
}
|
}
|
||||||
return netscape;
|
return netscape;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
public class BrowserCompatSpec extends CookieSpecBase {
|
public class BrowserCompatSpec extends CookieSpecBase {
|
||||||
|
|
||||||
/** Valid date patterns used per default */
|
/** Valid date patterns used per default */
|
||||||
private static final String[] DATE_PATTERNS = new String[] {
|
protected static final String[] DATE_PATTERNS = new String[] {
|
||||||
DateUtils.PATTERN_RFC1123,
|
DateUtils.PATTERN_RFC1123,
|
||||||
DateUtils.PATTERN_RFC1036,
|
DateUtils.PATTERN_RFC1036,
|
||||||
DateUtils.PATTERN_ASCTIME,
|
DateUtils.PATTERN_ASCTIME,
|
||||||
|
@ -64,18 +64,32 @@
|
|||||||
*/
|
*/
|
||||||
public class NetscapeDraftSpec extends CookieSpecBase {
|
public class NetscapeDraftSpec extends CookieSpecBase {
|
||||||
|
|
||||||
|
protected static final String EXPIRES_PATTERN = "EEE, dd-MMM-yyyy HH:mm:ss z";
|
||||||
|
|
||||||
|
private final String[] datepatterns;
|
||||||
|
|
||||||
/** Default constructor */
|
/** Default constructor */
|
||||||
public NetscapeDraftSpec() {
|
public NetscapeDraftSpec(final String[] datepatterns) {
|
||||||
super();
|
super();
|
||||||
|
if (datepatterns != null) {
|
||||||
|
this.datepatterns = datepatterns.clone();
|
||||||
|
} else {
|
||||||
|
this.datepatterns = new String[] { EXPIRES_PATTERN };
|
||||||
|
}
|
||||||
registerAttribHandler(ClientCookie.PATH_ATTR, new BasicPathHandler());
|
registerAttribHandler(ClientCookie.PATH_ATTR, new BasicPathHandler());
|
||||||
registerAttribHandler(ClientCookie.DOMAIN_ATTR, new NetscapeDomainHandler());
|
registerAttribHandler(ClientCookie.DOMAIN_ATTR, new NetscapeDomainHandler());
|
||||||
registerAttribHandler(ClientCookie.MAX_AGE_ATTR, new BasicMaxAgeHandler());
|
registerAttribHandler(ClientCookie.MAX_AGE_ATTR, new BasicMaxAgeHandler());
|
||||||
registerAttribHandler(ClientCookie.SECURE_ATTR, new BasicSecureHandler());
|
registerAttribHandler(ClientCookie.SECURE_ATTR, new BasicSecureHandler());
|
||||||
registerAttribHandler(ClientCookie.COMMENT_ATTR, new BasicCommentHandler());
|
registerAttribHandler(ClientCookie.COMMENT_ATTR, new BasicCommentHandler());
|
||||||
registerAttribHandler(ClientCookie.EXPIRES_ATTR, new BasicExpiresHandler(
|
registerAttribHandler(ClientCookie.EXPIRES_ATTR, new BasicExpiresHandler(
|
||||||
new String[] {"EEE, dd-MMM-yyyy HH:mm:ss z"}));
|
this.datepatterns));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Default constructor */
|
||||||
|
public NetscapeDraftSpec() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the Set-Cookie value into an array of <tt>Cookie</tt>s.
|
* Parses the Set-Cookie value into an array of <tt>Cookie</tt>s.
|
||||||
*
|
*
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
import org.apache.http.cookie.CookieSpec;
|
import org.apache.http.cookie.CookieSpec;
|
||||||
import org.apache.http.cookie.CookieSpecFactory;
|
import org.apache.http.cookie.CookieSpecFactory;
|
||||||
|
import org.apache.http.cookie.params.CookieSpecPNames;
|
||||||
import org.apache.http.params.HttpParams;
|
import org.apache.http.params.HttpParams;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +45,12 @@
|
|||||||
public class NetscapeDraftSpecFactory implements CookieSpecFactory {
|
public class NetscapeDraftSpecFactory implements CookieSpecFactory {
|
||||||
|
|
||||||
public CookieSpec newInstance(final HttpParams params) {
|
public CookieSpec newInstance(final HttpParams params) {
|
||||||
return new NetscapeDraftSpec();
|
if (params != null) {
|
||||||
|
return new NetscapeDraftSpec(
|
||||||
|
(String []) params.getParameter(CookieSpecPNames.DATE_PATTERNS));
|
||||||
|
} else {
|
||||||
|
return new NetscapeDraftSpec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user