|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sonalb.net.http.cookie.Client
public class Client
This class is used to invoke the cookie-handling logic of the jCookie Library.
It is the developer's view of the library. All cookie-handling methods are invoked on this
object. The following snippet shows common-case usage. The highlighted portion is the only
cookie-handling code, as far as the developer is concerned.
import com.sonalb.net.http.cookie.*; import java.net.*; import java.io.*; ... public class Example { ... public void someMethod() { ... URL url = new URL("http://www.site.com/"); HttpURLConnection huc = (HttpURLConnection) url.openConnection(); // Setup the HttpURLConnection here ... huc.connect(); InputStream is = huc.getInputStream(); Client client = new Client(); CookieJar cj = client.getCookies(huc); // Do some processing ... huc.disconnect(); // Make another request url = new URL("http://www.site.com/"); huc = (HttpURLConnection) url.openConnection(); client.setCookies(huc, cj); huc.connect(); ... } }
Constructor Summary | |
---|---|
Client()
Constructs an instance using the default CookieParser |
Method Summary | |
---|---|
CookieParser |
getCookieParser()
Gets the CookieParser implementation being used in this instance. |
CookieJar |
getCookies(java.net.URLConnection urlConn)
Processes cookie headers from the given URLConnection. |
static CookieParser |
getDefaultCookieParser()
Returns the built-in CookieParser implementation. |
void |
resetToDefaultCookieParser()
Resets the CookieParser implementation to be used for this instance, to the default
(built-in) implementation. |
void |
setCookieParser(CookieParser cp)
Sets the CookieParser implementation to be used in this instance. |
CookieJar |
setCookies(java.net.URLConnection urlConn,
CookieJar cj)
Sets cookie headers on the given URLConnection, using Cookies in the CookieJar. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Client()
CookieParser
,
getDefaultCookieParser()
Method Detail |
---|
public static CookieParser getDefaultCookieParser()
CookieParser
implementation. Current implementation
conforms to RFC-2965.
CookieParser
implementationRFC2965CookieParser
public void resetToDefaultCookieParser()
CookieParser
implementation to be used for this instance, to the default
(built-in) implementation.
setCookieParser(CookieParser)
public void setCookieParser(CookieParser cp)
CookieParser
implementation to be used in this instance.
cp
- the CookieParser to be usedpublic CookieParser getCookieParser()
CookieParser
implementation being used in this instance.
public CookieJar getCookies(java.net.URLConnection urlConn) throws MalformedCookieException
urlConn
- the URLConnection to be processed
MalformedCookieException
- if there was some error during cookie processingpublic CookieJar setCookies(java.net.URLConnection urlConn, CookieJar cj)
urlConn
- the URLConnection to be processedcj
- the CookieJar containing the Cookies to be set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |