本文整理了Java中jodd.http.HttpResponse.cookies()
方法的一些代码示例,展示了HttpResponse.cookies()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.cookies()
方法的具体详情如下:
包路径:jodd.http.HttpResponse
类名称:HttpResponse
方法名:cookies
[英]Returns list of valid cookies sent from server. If no cookie found, returns an empty array. Invalid cookies are ignored.
[中]返回从服务器发送的有效Cookie列表。如果未找到cookie,则返回空数组。无效的cookies将被忽略。
代码示例来源:origin: oblac/jodd
/**
* Reads cookies from response and adds to cookies list.
*/
protected void readCookies(final HttpResponse httpResponse) {
Cookie[] newCookies = httpResponse.cookies();
for (Cookie cookie : newCookies) {
cookies.add(cookie.getName(), cookie);
}
}
代码示例来源:origin: oblac/jodd
@Test
void testBrowser() {
HttpBrowser httpBrowser = new HttpBrowser();
httpBrowser.sendRequest(
HttpRequest
.get("localhost:8173/echo?id=17")
.cookies(new Cookie("waffle", "jam"))
.bodyText("hello"));
HttpResponse httpResponse = httpBrowser.getHttpResponse();
assertNotNull(httpResponse);
assertEquals("hello", httpResponse.body());
Cookie[] cookies = httpResponse.cookies();
assertEquals(1, cookies.length);
assertEquals("waffle", cookies[0].getName());
assertEquals("jam!", cookies[0].getValue());
}
代码示例来源:origin: org.jodd/jodd-http
/**
* Reads cookies from response and adds to cookies list.
*/
protected void readCookies(final HttpResponse httpResponse) {
Cookie[] newCookies = httpResponse.cookies();
for (Cookie cookie : newCookies) {
cookies.add(cookie.getName(), cookie);
}
}
内容来源于网络,如有侵权,请联系作者删除!