public class ThreadCookieHandler extends Object
Note that the interface of this cookie handler does not comply with java.net.ThreadCookieHandler.
Modifier and Type | Method and Description |
---|---|
void |
addRequestCookies(HttpURLConnection c)
Adds the applicable cookies from the cookie handler to the request
header of the connection.
|
Map<String,List<String>> |
get(URI request,
Map<String,List<String>> requestHeaders)
Selects the cookies applicable to the request URI from the cookie
store and puts them into the request header.
|
String[] |
getCookieValuesByName(String name)
Obtains the value of all cookies in the cookie store by the name of the
cookie.
|
static ThreadCookieHandler |
getInstance()
Obtains the thread cookie handler for this thread.
|
static void |
main(String[] args)
Main method to test cookie handler.
|
static ThreadCookieHandler |
newInstance()
Creates a new instance of the thread cookie handler for this thread.
|
void |
put(URI request,
Map<String,List<String>> responseHeaders)
Puts the cookies from the response headers into the cookie store.
|
public static ThreadCookieHandler newInstance()
public static ThreadCookieHandler getInstance()
public void put(URI request, Map<String,List<String>> responseHeaders)
request
- The URI of the requestresponseHeaders
- The response headers.public Map<String,List<String>> get(URI request, Map<String,List<String>> requestHeaders)
request
- The request URIrequestHeaders
- The request header mappublic void addRequestCookies(HttpURLConnection c) throws URISyntaxException
c
- The connectionURISyntaxException
public String[] getCookieValuesByName(String name)
name
- The cookie namepublic static void main(String[] args) throws IOException, URISyntaxException
args
- Name of each file representing each request headerIOException
- Cannot find or read fileURISyntaxException