|
Préférences
Moteurs de recherche
|
|||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.6.0
java.net
|
Constructor Summary | |
---|---|
CookieManager()
Create a new cookie manager. |
|
CookieManager(CookieStore store,
CookiePolicy cookiePolicy)
Create a new cookie manager with specified cookie store and cookie policy. |
Method Summary | |
---|---|
Map<String,List<String>> |
get(URI uri,
Map<String,List<String>> requestHeaders)
Gets all the applicable cookies from a cookie cache for the specified uri in the request header. |
CookieStore |
getCookieStore()
To retrieve current cookie store. |
void |
put(URI uri,
Map<String,List<String>> responseHeaders)
Sets all the applicable cookies, examples are response header fields that are named Set-Cookie2, present in the response headers into a cookie cache. |
void |
setCookiePolicy(CookiePolicy cookiePolicy)
To set the cookie policy of this cookie manager. |
Methods inherited from class java.net.CookieHandler |
---|
getDefault, setDefault |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CookieManager()
This constructor will create new cookie manager with default cookie store and accept policy. The effect is same as CookieManager(null, null).
public CookieManager(CookieStore store, CookiePolicy cookiePolicy)
store
- a CookieStore to be used by cookie manager.
if null, cookie manager will use a default one,
which is an in-memory CookieStore implmentation.cookiePolicy
- a CookiePolicy instance
to be used by cookie manager as policy callback.
if null, ACCEPT_ORIGINAL_SERVER will
be used.Method Detail |
---|
public void setCookiePolicy(CookiePolicy cookiePolicy)
A instance of CookieManager will have cookie policy ACCEPT_ORIGINAL_SERVER by default. Users always can call this method to set another cookie policy.
cookiePolicy
- the cookie policy. Can be null, which
has no effects on current cookie policy.public CookieStore getCookieStore()
public Map<String,List<String>> get(URI uri, Map<String,List<String>> requestHeaders) throws IOException
CookieHandler
get
in class CookieHandler
uri
- a URI
to send cookies to in a requestrequestHeaders
- - a Map from request header
field names to lists of field values representing
the current request headers
IOException
- if an I/O error occursCookieHandler.put(URI, Map)
public void put(URI uri, Map<String,List<String>> responseHeaders) throws IOException
CookieHandler
put
in class CookieHandler
uri
- a URI
where the cookies come fromresponseHeaders
- an immutable map from field names to
lists of field values representing the response
header fields returned
IOException
- if an I/O error occursCookieHandler.get(URI, Map)