Package org.faceless.publisher.type
Class CookieStoreURLConnectionProcessor
java.lang.Object
org.faceless.publisher.type.AbstractURLConnectionProcessor
org.faceless.publisher.type.CookieStoreURLConnectionProcessor
- All Implemented Interfaces:
URLConnectionProcessor
A subclass of
URLConnectionProcessor
which can be used to serve, store and
persist HTTP Cookies for any HTTP connections made to request resources.-
Constructor Summary
ConstructorDescriptionCreate a newCookieStoreURLConnectionProcessor
with the systemCookieManager
.Create a newCookieStoreURLConnectionProcessor
with the specifiedCookieManager
Create a newCookieStoreURLConnectionProcessor
with the systemCookieManager
. -
Method Summary
Modifier and TypeMethodDescriptionafter
(URL2Connection con) If this processermatches
, this method is called after the supplied URL connection is made.void
before
(URL2Connection con) If this processermatches
, this method is called before the supplied URL connection is made.Return theCookieManager
used by this classgetPath()
Return the path most recently passed intoload(java.nio.file.Path)
orsave(java.nio.file.Path)
void
Load the cookies from the netscape/curl format \"cookiejar\" file at the specified path, if it existsvoid
Save the cookies from the netscape/curl format \"cookiejar\" file to the specified path, or if path is null, to the path last passed intoload(java.nio.file.Path)
orsave(java.nio.file.Path)
.Methods inherited from class org.faceless.publisher.type.AbstractURLConnectionProcessor
getMatches, matches
-
Constructor Details
-
CookieStoreURLConnectionProcessor
public CookieStoreURLConnectionProcessor()Create a newCookieStoreURLConnectionProcessor
with the systemCookieManager
. If no system CookieManager exists, create one. -
CookieStoreURLConnectionProcessor
Create a newCookieStoreURLConnectionProcessor
with the systemCookieManager
. If no system CookieManager exists, create one. and load the cookies from the specified path if it exists- Parameters:
path
- the path to a netscape/curl style cookie-store, which will be loaded if it exists.- Throws:
IOException
-
CookieStoreURLConnectionProcessor
Create a newCookieStoreURLConnectionProcessor
with the specifiedCookieManager
- Parameters:
handler
- the handler
-
-
Method Details
-
load
Load the cookies from the netscape/curl format \"cookiejar\" file at the specified path, if it exists- Parameters:
path
- the file path to load.- Throws:
IOException
-
save
Save the cookies from the netscape/curl format \"cookiejar\" file to the specified path, or if path is null, to the path last passed intoload(java.nio.file.Path)
orsave(java.nio.file.Path)
. If no path can be resolved, does nothing.- Parameters:
path
- the file path to load- Throws:
IOException
-
getPath
Return the path most recently passed intoload(java.nio.file.Path)
orsave(java.nio.file.Path)
-
getCookieHandler
Return theCookieManager
used by this class- Returns:
- the handler
-
before
Description copied from interface:URLConnectionProcessor
If this processermatches
, this method is called before the supplied URL connection is made. It can alter any request headers.- Specified by:
before
in interfaceURLConnectionProcessor
- Overrides:
before
in classAbstractURLConnectionProcessor
- Parameters:
con
- the connection- Throws:
IOException
-
after
Description copied from interface:URLConnectionProcessor
If this processermatches
, this method is called after the supplied URL connection is made. It can act on the response headers, modify them for the next processor, and if it returns non-null, the request headers and URI of the returned value will be used for another request. For example to implement a redirect on a return code of 301if (con.getCode() == 301) { con.setURI(parse(con.getResponseHeader("location"))); return con; } else { return null; }
- Specified by:
after
in interfaceURLConnectionProcessor
- Overrides:
after
in classAbstractURLConnectionProcessor
- Parameters:
con
- the connection- Returns:
- the next connection to make, or
null
to accept this response - Throws:
IOException
-