com.seejoke.http.common.HttpCookies Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core-tools Show documentation
Show all versions of core-tools Show documentation
提供java常用的、流行的工具方法,减少项目冗余代码
package com.seejoke.http.common;
import org.apache.http.client.CookieStore;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.BasicCookieStore;
/**
* 封装Cookie
*
* @version 1.0
*/
public class HttpCookies {
/**
* 使用httpcontext,用于设置和携带Cookie
*/
private HttpClientContext context;
/**
* 储存Cookie
*/
private CookieStore cookieStore;
public static HttpCookies custom() {
return new HttpCookies();
}
private HttpCookies() {
this.context = new HttpClientContext();
this.cookieStore = new BasicCookieStore();
this.context.setCookieStore(cookieStore);
}
public HttpClientContext getContext() {
return context;
}
public HttpCookies setContext(HttpClientContext context) {
this.context = context;
return this;
}
public CookieStore getCookieStore() {
return cookieStore;
}
public HttpCookies setCookieStore(CookieStore cookieStore) {
this.cookieStore = cookieStore;
return this;
}
}