本文整理汇总了Java中org.apache.http.impl.cookie.DefaultCookieSpec类的典型用法代码示例。如果您正苦于以下问题:Java DefaultCookieSpec类的具体用法?Java DefaultCookieSpec怎么用?Java DefaultCookieSpec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultCookieSpec类属于org.apache.http.impl.cookie包,在下文中一共展示了DefaultCookieSpec类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterPropertiesSet
import org.apache.http.impl.cookie.DefaultCookieSpec; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
cookieSpecRegistry = RegistryBuilder.<CookieSpecProvider> create().register("easy", new CookieSpecProvider() {
public CookieSpec create(HttpContext context) {
return new DefaultCookieSpec() {
@Override
public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException {
}
};
}
}).build();
requestConfig = RequestConfig.custom().setCookieSpec("easy")
.setConnectionRequestTimeout(propertyConfigurer.getIntValue("connection.request.timeout"))
.setSocketTimeout(propertyConfigurer.getIntValue("socket_timeout"))
.setConnectTimeout(propertyConfigurer.getIntValue("connection_timeout")).build();
}
示例2: create
import org.apache.http.impl.cookie.DefaultCookieSpec; //导入依赖的package包/类
@Override
public CookieSpec create(HttpContext context) {
String[] datePatterns = new String[] {
DateUtils.PATTERN_RFC1123,
DATE_PATTERN_NETSCAPE1,//default Netscape date pattern
};
return new DefaultCookieSpec(datePatterns, false) {
@Override
public void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException {
//do nothing
}
};
}
示例3: getCookie
import org.apache.http.impl.cookie.DefaultCookieSpec; //导入依赖的package包/类
/**
* 获取当前Http客户端状态中的Cookie
*
* @param domain
* 作用域
* @param port
* 端口 传null 默认80
* @param path
* Cookie路径 传null 默认"/"
* @param useSecure
* Cookie是否采用安全机制 传null 默认false
* @return
*/
public Map<String, Cookie> getCookie(String domain, Integer port, String path, Boolean useSecure) {
if (domain == null) {
return null;
}
if (port == null) {
port = 80;
}
if (path == null) {
path = "/";
}
if (useSecure == null) {
useSecure = false;
}
List<Cookie> cookies = cookieStore.getCookies();
if (cookies == null || cookies.isEmpty()) {
return null;
}
CookieOrigin origin = new CookieOrigin(domain, port, path, useSecure);
DefaultCookieSpec cookieSpec = new DefaultCookieSpec();
Map<String, Cookie> retVal = new HashMap<String, Cookie>();
for (Cookie cookie : cookies) {
if (cookieSpec.match(cookie, origin)) {
retVal.put(cookie.getName(), cookie);
}
}
return retVal;
}
示例4: build
import org.apache.http.impl.cookie.DefaultCookieSpec; //导入依赖的package包/类
public RestResponseEntity build() {
if (resultString == null && result == null) {
throw new IllegalArgumentException("Either resultString or result must be set");
}
if (!cookies.isEmpty()) {
DefaultCookieSpec defaultCookieSpec = new DefaultCookieSpec();
defaultCookieSpec.formatCookies(cookies)
.forEach(header -> headers.put(header.getName(), header.getValue()));
}
return new RestResponseEntity(statusCode, result, resultString, headers);
}
示例5: setUp
import org.apache.http.impl.cookie.DefaultCookieSpec; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
this.cookieOrigin = new CookieOrigin("localhost", 80, "/", false);
this.cookieSpec = new DefaultCookieSpec();
this.cookieStore = new BasicCookieStore();
}