|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sonalb.net.http.HTTPRedirectHandler
public class HTTPRedirectHandler
Convenience class that combines cookie-handling and redirect-handling logic. When the connect() method is invoked, the handler cyclically processes HTTP Redirects (if any), and also takes care of cookie-handling while doing so. The maximum number of redirects defaults to 10. The handler determines a successful run, when the HTTP response code is equal to a specified success code. This code defaults to 200 (OK).
Constructor Summary | |
---|---|
HTTPRedirectHandler(java.net.HttpURLConnection huc)
Creates a handler for the input HttpURLConnection. |
Method Summary | |
---|---|
void |
addCookies(CookieJar cj)
Adds some Cookies to the existing Cookies in an HTTPRedirectHandler. |
void |
connect()
Connects to initial HttpURLConnection (specified during construction), and initiates cookie-handling and redirect-handling. |
java.net.HttpURLConnection |
getConnection()
Gets the HttpURLConnection for the final successful response. |
CookieJar |
getCookieJar()
Gets the CookieJar containing any pre-existing Cookies, as well as new ones extracted during processing. |
java.io.InputStream |
getInputStream()
Gets the InputStream for the final successful response. |
void |
handleCookies(boolean b)
Enables/Disables automated cookie-handling. |
boolean |
isConnected()
Checks whether this handler has successfully connected. |
void |
setClient(Client cl)
Sets the Client to be used for this handler. |
void |
setCookieJar(CookieJar cj)
Sets the CookieJar containing Cookies to be used during cookie-handling. |
void |
setMaxRedirects(int i)
Sets the maximum number of redirects that will be followed. |
void |
setSuccessCode(int i)
Sets the HTTP response code designating a successful run. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HTTPRedirectHandler(java.net.HttpURLConnection huc)
Method Detail |
---|
public void setClient(Client cl)
public void handleCookies(boolean b)
public void setSuccessCode(int i)
i
- the code; non-positive values ignoredpublic void setCookieJar(CookieJar cj)
public void addCookies(CookieJar cj)
cj
- the Cookies to be addedpublic CookieJar getCookieJar()
public java.io.InputStream getInputStream()
java.lang.IllegalStateException
- when called before successful connection.public java.net.HttpURLConnection getConnection()
public void setMaxRedirects(int i)
i
- the max number; non-positive values are ignoredpublic void connect() throws java.io.IOException, MalformedCookieException
java.io.IOException
- if there is an I/O problem
MalformedCookieException
- if there was a problem with cookie-handling
java.lang.IllegalStateException
- if this method has already been calledpublic boolean isConnected()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |