public final class NetscapeCookieFile extends Object
It will only load the cookies lazily, i.e. before calling
getCookies(boolean)
the file is not evaluated. This class also
allows persisting cookies in that file format.
In general this class is not thread-safe. So any consumer needs to take care of synchronization!
Constructor and Description |
---|
NetscapeCookieFile(Path path) |
Modifier and Type | Method and Description |
---|---|
Set<HttpCookie> |
getCookies(boolean refresh)
Return all cookies from the underlying cookie file.
|
Path |
getPath()
Path to the underlying cookie file.
|
void |
write(URL url)
Writes all the cookies being maintained in the set being returned by
getCookies(boolean) to the underlying file. |
public NetscapeCookieFile(Path path)
path
- where to find the cookie filepublic Path getPath()
public Set<HttpCookie> getCookies(boolean refresh)
refresh
- if true
updates the list from the underlying cookie
file if it has been modified since the last read otherwise
returns the current transient state. In case the cookie file
has never been read before will always read from the
underlying file disregarding the value of this parameter.write(URL)
. Errors in the underlying file will not lead
to exceptions but rather to an empty set being returned and the
underlying error being logged.public void write(URL url) throws IOException, InterruptedException
getCookies(boolean)
to the underlying file.
Session-cookies will not be persisted.
url
- url for which to write the cookies (important to derive
default values for non-explicitly set attributes)IOException
- if the underlying cookie file could not be read or written or
a problem with the lock fileInterruptedException
- if the thread is interrupted while waiting for the lockCopyright © 2019 Eclipse JGit Project. All rights reserved.