本文整理了Java中jodd.http.HttpRequest.cookies()
方法的一些代码示例,展示了HttpRequest.cookies()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.cookies()
方法的具体详情如下:
包路径:jodd.http.HttpRequest
类名称:HttpRequest
方法名:cookies
[英]Sets cookies to the request.
[中]将cookies设置为请求。
代码示例来源:origin: oblac/jodd
/**
* Add cookies to the request.
*/
protected void addCookies(final HttpRequest httpRequest) {
// prepare all cookies
List<Cookie> cookiesList = new ArrayList<>();
if (!cookies.isEmpty()) {
for (Map.Entry<String, Cookie> cookieEntry : cookies) {
cookiesList.add(cookieEntry.getValue());
}
httpRequest.cookies(cookiesList.toArray(new Cookie[0]));
}
}
}
代码示例来源: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
/**
* Add cookies to the request.
*/
protected void addCookies(final HttpRequest httpRequest) {
// prepare all cookies
List<Cookie> cookiesList = new ArrayList<>();
if (!cookies.isEmpty()) {
for (Map.Entry<String, Cookie> cookieEntry : cookies) {
cookiesList.add(cookieEntry.getValue());
}
httpRequest.cookies(cookiesList.toArray(new Cookie[0]));
}
}
}
代码示例来源:origin: com.liferay.launchpad/api-client
.collect(Collectors.toList());
httpRequest.cookies(
cookies.toArray(new jodd.http.Cookie[cookies.size()]));
内容来源于网络,如有侵权,请联系作者删除!