本文整理汇总了Java中org.apache.http.cookie.CookieSpecFactory类的典型用法代码示例。如果您正苦于以下问题:Java CookieSpecFactory类的具体用法?Java CookieSpecFactory怎么用?Java CookieSpecFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CookieSpecFactory类属于org.apache.http.cookie包,在下文中一共展示了CookieSpecFactory类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareForBrowser
import org.apache.http.cookie.CookieSpecFactory; //导入依赖的package包/类
public void prepareForBrowser() {
// Clear cookies, let the browser handle them
httpClient.setCookieStore(new BlankCookieStore());
httpClient.getCookieSpecs().register("easy", new CookieSpecFactory() {
@Override
public CookieSpec newInstance(final HttpParams params) {
return new BrowserCompatSpec() {
@Override
public void validate(final Cookie cookie, final CookieOrigin origin) throws MalformedCookieException {
// easy!
}
};
}
});
httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, "easy");
decompress = false;
setFollowRedirects(false);
}
示例2: prepairCookieStore
import org.apache.http.cookie.CookieSpecFactory; //导入依赖的package包/类
private void prepairCookieStore(DefaultHttpClient client) {
client.setCookieStore(cookieStore);
CookieSpecFactory csf = new CookieSpecFactory() {
public CookieSpec newInstance(HttpParams params) {
return new BrowserCompatSpec() {
@Override
public void validate(Cookie cookie, CookieOrigin origin)
throws MalformedCookieException {
// not filtering; accept all cookies
Log.d(this.toString(),"cookies");
}
};
}
};
client.getCookieSpecs().register("all", csf);
client.getParams().setParameter(
ClientPNames.COOKIE_POLICY, "all");
}