MCPcopy Index your code
hub / github.com/HtmlUnit/htmlunit / getCookies

Method getCookies

src/main/java/org/htmlunit/WebClient.java:2894–2917  ·  view source on GitHub ↗

Returns the currently configured cookies applicable to the specified URL, in an unmodifiable set. If disabled, this returns an empty set. @param url the URL on which to filter the returned cookies @return the currently configured cookies applicable to the specified URL, in an unmodifiable set

(final URL url)

Source from the content-addressed store, hash-verified

2892 * @return the currently configured cookies applicable to the specified URL, in an unmodifiable set
2893 */
2894 public synchronized Set<Cookie> getCookies(final URL url) {
2895 final CookieManager cookieManager = getCookieManager();
2896
2897 if (!cookieManager.isCookiesEnabled()) {
2898 return Collections.emptySet();
2899 }
2900
2901 final URL normalizedUrl = HttpClientConverter.replaceForCookieIfNecessary(url);
2902
2903 final String host = normalizedUrl.getHost();
2904 // URLs like "about:blank" don't have cookies and we need to catch these
2905 // cases here before HttpClient complains
2906 if (host.isEmpty()) {
2907 return Collections.emptySet();
2908 }
2909
2910 // discard expired cookies
2911 cookieManager.clearExpired(new Date());
2912
2913 final Set<Cookie> matchingCookies = new LinkedHashSet<>();
2914 HttpClientConverter.addMatching(cookieManager.getCookies(), normalizedUrl,
2915 getBrowserVersion(), matchingCookies);
2916 return Collections.unmodifiableSet(matchingCookies);
2917 }
2918
2919 /**
2920 * Parses the given cookie and adds this to our cookie store.

Callers 1

cookiesForAboutBlankMethod · 0.95

Calls 9

getCookieManagerMethod · 0.95
isCookiesEnabledMethod · 0.95
getHostMethod · 0.95
clearExpiredMethod · 0.95
addMatchingMethod · 0.95
getCookiesMethod · 0.95
getBrowserVersionMethod · 0.95
isEmptyMethod · 0.65

Tested by 1

cookiesForAboutBlankMethod · 0.76