de.enough.polish.io
Class RedirectHttpConnection
java.lang.Object
de.enough.polish.io.RedirectHttpConnection
- All Implemented Interfaces:
- Connection, ContentConnection, HttpConnection, InputConnection, OutputConnection, StreamConnection
public class RedirectHttpConnection
- extends Object
- implements HttpConnection
Provides a HttpConnection that supports HTTP redirects. This
class is compatible to javax.microedition.io.HttpConnection.
When connecting to an URL and a HTTP redirect is return this class follows
the redirect and uses the following HTTP connection. This works over multiple
levels. By default five redirects are supported. The number of supported
redirects can be tuned by setting the preprocessing variable
polish.Browser.MaxRedirects to some integer value.
- See Also:
HttpConnection
| Fields inherited from interface javax.microedition.io.HttpConnection |
GET, HEAD, HTTP_ACCEPTED, HTTP_BAD_GATEWAY, HTTP_BAD_METHOD, HTTP_BAD_REQUEST, HTTP_CLIENT_TIMEOUT, HTTP_CONFLICT, HTTP_CREATED, HTTP_ENTITY_TOO_LARGE, HTTP_EXPECT_FAILED, HTTP_FORBIDDEN, HTTP_GATEWAY_TIMEOUT, HTTP_GONE, HTTP_INTERNAL_ERROR, HTTP_LENGTH_REQUIRED, HTTP_MOVED_PERM, HTTP_MOVED_TEMP, HTTP_MULT_CHOICE, HTTP_NO_CONTENT, HTTP_NOT_ACCEPTABLE, HTTP_NOT_AUTHORITATIVE, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_NOT_MODIFIED, HTTP_OK, HTTP_PARTIAL, HTTP_PAYMENT_REQUIRED, HTTP_PRECON_FAILED, HTTP_PROXY_AUTH, HTTP_REQ_TOO_LONG, HTTP_RESET, HTTP_SEE_OTHER, HTTP_TEMP_REDIRECT, HTTP_UNAUTHORIZED, HTTP_UNAVAILABLE, HTTP_UNSUPPORTED_RANGE, HTTP_UNSUPPORTED_TYPE, HTTP_USE_PROXY, HTTP_VERSION, POST |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RedirectHttpConnection
public RedirectHttpConnection(String url)
throws IOException
- Creates a new http connection that understands redirects.
- Parameters:
url - the url to connect to
- Throws:
IOException - when Connector.open() fails
RedirectHttpConnection
public RedirectHttpConnection(String url,
HashMap requestProperties)
throws IOException
- Creates a new http connection that understands redirects.
- Parameters:
url - the url to connect torequestProperties - the request properties to be set for each http request
- Throws:
IOException - when Connector.open() fails
getDate
public long getDate()
throws IOException
- Specified by:
getDate in interface HttpConnection
- Throws:
IOException
getExpiration
public long getExpiration()
throws IOException
- Specified by:
getExpiration in interface HttpConnection
- Throws:
IOException
getFile
public String getFile()
- Specified by:
getFile in interface HttpConnection
getHeaderField
public String getHeaderField(String name)
throws IOException
- Specified by:
getHeaderField in interface HttpConnection
- Throws:
IOException
getHeaderField
public String getHeaderField(int n)
throws IOException
- Specified by:
getHeaderField in interface HttpConnection
- Throws:
IOException
getHeaderFieldDate
public long getHeaderFieldDate(String name,
long def)
throws IOException
- Specified by:
getHeaderFieldDate in interface HttpConnection
- Throws:
IOException
getHeaderFieldInt
public int getHeaderFieldInt(String name,
int def)
throws IOException
- Specified by:
getHeaderFieldInt in interface HttpConnection
- Throws:
IOException
getHeaderFieldKey
public String getHeaderFieldKey(int n)
throws IOException
- Specified by:
getHeaderFieldKey in interface HttpConnection
- Throws:
IOException
getHost
public String getHost()
- Specified by:
getHost in interface HttpConnection
getLastModified
public long getLastModified()
throws IOException
- Specified by:
getLastModified in interface HttpConnection
- Throws:
IOException
getPort
public int getPort()
- Specified by:
getPort in interface HttpConnection
getProtocol
public String getProtocol()
- Specified by:
getProtocol in interface HttpConnection
getQuery
public String getQuery()
- Specified by:
getQuery in interface HttpConnection
getRef
public String getRef()
- Specified by:
getRef in interface HttpConnection
getRequestMethod
public String getRequestMethod()
- Specified by:
getRequestMethod in interface HttpConnection
getRequestProperty
public String getRequestProperty(String key)
- Specified by:
getRequestProperty in interface HttpConnection
getResponseCode
public int getResponseCode()
throws IOException
- Specified by:
getResponseCode in interface HttpConnection
- Throws:
IOException
getResponseMessage
public String getResponseMessage()
throws IOException
- Specified by:
getResponseMessage in interface HttpConnection
- Throws:
IOException
getURL
public String getURL()
- Specified by:
getURL in interface HttpConnection
setRequestMethod
public void setRequestMethod(String requestMethod)
throws IOException
- Specified by:
setRequestMethod in interface HttpConnection
- Throws:
IOException
setRequestProperty
public void setRequestProperty(String key,
String value)
throws IOException
- Specified by:
setRequestProperty in interface HttpConnection
- Throws:
IOException
getEncoding
public String getEncoding()
- Specified by:
getEncoding in interface ContentConnection
getLength
public long getLength()
- Specified by:
getLength in interface ContentConnection
getType
public String getType()
- Specified by:
getType in interface ContentConnection
openDataInputStream
public DataInputStream openDataInputStream()
throws IOException
- Specified by:
openDataInputStream in interface InputConnection
- Throws:
IOException
openInputStream
public InputStream openInputStream()
throws IOException
- Specified by:
openInputStream in interface InputConnection
- Throws:
IOException
close
public void close()
throws IOException
- Specified by:
close in interface Connection
- Throws:
IOException
openDataOutputStream
public DataOutputStream openDataOutputStream()
throws IOException
- Specified by:
openDataOutputStream in interface OutputConnection
- Throws:
IOException
openOutputStream
public OutputStream openOutputStream()
throws IOException
- Specified by:
openOutputStream in interface OutputConnection
- Throws:
IOException