java.lang.Object
org.htmlunit.httpclient.HttpClientConverter
Helper methods to convert from/to HttpClient.
- Author:
- Ronald Brill
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddMatching(Set<Cookie> cookies, URL normalizedUrl, BrowserVersion browserVersion, Set<Cookie> matches) Adds all matching cookies to the provided set.static org.apache.http.cookie.CookieOriginbuildCookieOrigin(URL url) Helper that builds a CookieOrigin.parseCookie(String cookieString, URL pageUrl, BrowserVersion browserVersion) static URLCookieOrigindoesn't like empty hosts and negative ports, but these things happen if we're dealing with a local file.static List<org.apache.http.cookie.Cookie>toHttpClient(Collection<Cookie> cookies) Converts the specified collection of cookies into a collection of HttpClient cookies.
-
Method Details
-
buildCookieOrigin
Helper that builds a CookieOrigin.- Parameters:
url- the url to be used- Returns:
- the new CookieOrigin
-
replaceForCookieIfNecessary
CookieOrigindoesn't like empty hosts and negative ports, but these things happen if we're dealing with a local file. This method allows us to work around this limitation in HttpClient by feeding it a bogus host and port.- Parameters:
url- the URL to replace if necessary- Returns:
- the replacement URL, or the original URL if no replacement was necessary
-
parseCookie
public static List<Cookie> parseCookie(String cookieString, URL pageUrl, BrowserVersion browserVersion) throws org.apache.http.cookie.MalformedCookieException - Parameters:
cookieString- the string to parsepageUrl- the page url as rootbrowserVersion- theBrowserVersion- Returns:
- a list of
Cookie's - Throws:
org.apache.http.cookie.MalformedCookieException- in case the cookie does not conform to the spec
-
toHttpClient
Converts the specified collection of cookies into a collection of HttpClient cookies.- Parameters:
cookies- the cookies to be converted- Returns:
- the specified cookies, as HttpClient cookies
-
addMatching
public static void addMatching(Set<Cookie> cookies, URL normalizedUrl, BrowserVersion browserVersion, Set<Cookie> matches) Adds all matching cookies to the provided set.- Parameters:
cookies- the cookies to select fromnormalizedUrl- the url to match againstbrowserVersion- theBrowserVersionmatches- the set to add
-