本文整理了Java中com.gargoylesoftware.htmlunit.WebClient.getCookieManager()
方法的一些代码示例,展示了WebClient.getCookieManager()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.getCookieManager()
方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.WebClient
类名称:WebClient
方法名:getCookieManager
[英]Returns the cookie manager used by this web client.
[中]返回此web客户端使用的cookie管理器。
代码示例来源:origin: spring-projects/spring-framework
private CookieManager getCookieManager() {
return this.webClient.getCookieManager();
}
代码示例来源:origin: spring-projects/spring-framework
private void storeCookies(WebRequest webRequest, javax.servlet.http.Cookie[] cookies) {
Date now = new Date();
CookieManager cookieManager = this.webClient.getCookieManager();
for (javax.servlet.http.Cookie cookie : cookies) {
if (cookie.getDomain() == null) {
cookie.setDomain(webRequest.getUrl().getHost());
}
Cookie toManage = createCookie(cookie);
Date expires = toManage.getExpires();
if (expires == null || expires.after(now)) {
cookieManager.addCookie(toManage);
}
else {
cookieManager.removeCookie(toManage);
}
}
}
代码示例来源:origin: javaee-samples/javaee7-samples
@After
public void tearDown() {
webClient.getCookieManager().clearCookies();
webClient.close();
}
代码示例来源:origin: spring-projects/spring-framework
private void assertSingleSessionCookie(String expected) {
com.gargoylesoftware.htmlunit.util.Cookie jsessionidCookie = webClient.getCookieManager().getCookie("JSESSIONID");
if (expected == null || expected.contains("Expires=Thu, 01-Jan-1970 00:00:01 GMT")) {
assertThat(jsessionidCookie, nullValue());
return;
}
String actual = jsessionidCookie.getValue();
assertThat("JSESSIONID=" + actual + "; Path=/test; Domain=example.com", equalTo(expected));
}
代码示例来源:origin: spring-projects/spring-framework
@Test // SPR-14066
public void cookieManagerShared() throws Exception {
this.mockMvc = MockMvcBuilders.standaloneSetup(new CookieController()).build();
WebClient client = MockMvcWebClientBuilder.mockMvcSetup(this.mockMvc).build();
assertThat(getResponse(client, "http://localhost/").getContentAsString(), equalTo("NA"));
client.getCookieManager().addCookie(new Cookie("localhost", "cookie", "cookieManagerShared"));
assertThat(getResponse(client, "http://localhost/").getContentAsString(), equalTo("cookieManagerShared"));
}
代码示例来源:origin: spring-projects/spring-framework
@Test // SPR-14066
public void cookieManagerShared() throws Exception {
WebConnectionHtmlUnitDriver otherDriver = new WebConnectionHtmlUnitDriver();
this.mockMvc = MockMvcBuilders.standaloneSetup(new CookieController()).build();
this.driver = MockMvcHtmlUnitDriverBuilder.mockMvcSetup(this.mockMvc)
.withDelegate(otherDriver).build();
assertThat(get("http://localhost/"), equalTo(""));
Cookie cookie = new Cookie("localhost", "cookie", "cookieManagerShared");
otherDriver.getWebClient().getCookieManager().addCookie(cookie);
assertThat(get("http://localhost/"), equalTo("cookieManagerShared"));
}
代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-htmlunit
public void deleteCookieNamed(String name) {
CookieManager cookieManager = webClient.getCookieManager();
Set<org.apache.commons.httpclient.Cookie> rawCookies = webClient.getCookieManager().getCookies(getHostName());
for (org.apache.commons.httpclient.Cookie cookie : rawCookies) {
if (name.equals(cookie.getName())) {
cookieManager.removeCookie(cookie);
}
}
}
代码示例来源:origin: javaserverfaces/mojarra
public void print(HtmlPage page) {
System.out.println("\n\n\n RAW REQUEST BODY \n" + getRawRequestBody());
System.out.println("\n\n\n RAW RESPONSE \n" + getRawResponse());
System.out.println("Response Headers: " + page.getWebResponse().getResponseHeaders());
System.out.println("\n\n\n ********************************* \n" + page.asXml());
System.out.println("\n\n\n **************************** \n" + webClient.getCookieManager().getCookies());
System.out.println("\n\n\n *********************************");
}
代码示例来源:origin: javaee/security-soteria
@After
public void tearDown() {
webClient.getCookieManager().clearCookies();
webClient.close();
}
代码示例来源:origin: stackoverflow.com
WebClient webClient = new WebClient(BrowserVersion.CHROME);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setUseInsecureSSL(true);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
webClient.getCookieManager().setCookiesEnabled(true);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getCookieManager().setCookiesEnabled(true);
代码示例来源:origin: org.seleniumhq.selenium/selenium-htmlunit-driver
@Override
public void deleteCookieNamed(String name) {
CookieManager cookieManager = getWebClient().getCookieManager();
URL url = getRawUrl();
Set<com.gargoylesoftware.htmlunit.util.Cookie> rawCookies = getWebClient().getCookies(url);
for (com.gargoylesoftware.htmlunit.util.Cookie cookie : rawCookies) {
if (name.equals(cookie.getName())) {
cookieManager.removeCookie(cookie);
}
}
}
代码示例来源:origin: org.seleniumhq.selenium/selenium-htmlunit-driver
@Override
public void deleteAllCookies() {
CookieManager cookieManager = getWebClient().getCookieManager();
URL url = getRawUrl();
Set<com.gargoylesoftware.htmlunit.util.Cookie> rawCookies = getWebClient().getCookies(url);
for (com.gargoylesoftware.htmlunit.util.Cookie cookie : rawCookies) {
cookieManager.removeCookie(cookie);
}
}
代码示例来源:origin: org.jenkins-ci/htmlunit
/**
* Returns the property "cookieEnabled".
* @return the property "cookieEnabled"
*/
public boolean jsxGet_cookieEnabled() {
return getWindow().getWebWindow().getWebClient().getCookieManager().isCookiesEnabled();
}
代码示例来源:origin: org.jvnet.hudson/htmlunit
/**
* Returns the property "cookieEnabled".
* @return the property "cookieEnabled"
*/
public boolean jsxGet_cookieEnabled() {
return getWindow().getWebWindow().getWebClient().getCookieManager().isCookiesEnabled();
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Returns the property "cookieEnabled".
* @return the property "cookieEnabled"
*/
public boolean jsxGet_cookieEnabled() {
return getWindow().getWebWindow().getWebClient().getCookieManager().isCookiesEnabled();
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Returns the {@code cookieEnabled} property.
* @return the {@code cookieEnabled} property
*/
@JsxGetter
public boolean isCookieEnabled() {
return getWindow().getWebWindow().getWebClient().getCookieManager().isCookiesEnabled();
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Returns the {@code cookieEnabled} property.
* @return the {@code cookieEnabled} property
*/
@JsxGetter
public boolean isCookieEnabled() {
return getWindow().getWebWindow().getWebClient().getCookieManager().isCookiesEnabled();
}
代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-htmlunit
public Set<Cookie> getCookies() {
Set<org.apache.commons.httpclient.Cookie> rawCookies = webClient.getCookieManager().getCookies(getHostName());
Set<Cookie> retCookies = new HashSet<Cookie>();
for(org.apache.commons.httpclient.Cookie c : rawCookies) {
if (c.getPath() != null && getPath().startsWith(c.getPath())) {
retCookies.add(new ReturnedCookie(c.getName(), c.getValue(), c.getDomain(), c.getPath(),
c.getExpiryDate(), c.getSecure()));
}
}
return retCookies;
}
代码示例来源:origin: org.jboss.cdi.tck/cdi-tck-impl
@Override
public String call() throws Exception {
WebClient client = new WebClient();
client.setThrowExceptionOnFailingStatusCode(false);
client.getCookieManager().addCookie(new Cookie(contextPath.getHost(), JSESSIONID, jsessionid));
Page page = client.getPage(contextPath + "introspect?mode=" + mode + "&cid=" + cid);
if (!(page instanceof TextPage)) {
return "" + page.getWebResponse().getStatusCode();
}
TextPage textPage = (TextPage) page;
return textPage.getContent();
}
代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-htmlunit
public void addCookie(Cookie cookie) {
Page page = lastPage();
if (!(page instanceof HtmlPage)) {
throw new WebDriverException("You may not set cookies on a page that is not HTML");
}
// Cookies only make sense if the page is
String domain = getDomainForCookie(cookie);
verifyDomain(cookie, domain);
webClient.getCookieManager().addCookie(new org.apache.commons.httpclient.Cookie(domain,
cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getExpiry(),
cookie.isSecure()));
}
内容来源于网络,如有侵权,请联系作者删除!