public interface FileDownloadConnection
| Modifier and Type | Field and Description |
|---|---|
static int |
NO_RESPONSE_CODE |
static int |
RESPONSE_CODE_FROM_OFFSET |
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String name,
String value)
Sets the header named
name to value. |
boolean |
dispatchAddResumeOffset(String etag,
long offset)
If we find the file has been downloaded several bytes, we will try to resume from the
breakpoint from
offset length. |
void |
ending()
To Be Reused or Close this connection, since this connection is ending in this session.
|
void |
execute()
Invokes the request immediately, and blocks until the response can be processed or is in
error.
|
InputStream |
getInputStream()
Returns an input stream that reads from this open connection.
|
Map<String,List<String>> |
getRequestHeaderFields()
Returns an unmodifiable Map of general request header fields for this connection.
|
int |
getResponseCode()
Gets the status code from an HTTP response message.
|
String |
getResponseHeaderField(String name)
Returns the value of the named header field, which would be the response-header field.
|
Map<String,List<String>> |
getResponseHeaderFields()
Returns an unmodifiable Map of the header fields.
|
boolean |
setRequestMethod(String method)
Set the method for the request, one of:
GET
POST
HEAD
OPTIONS
PUT
DELETE
TRACE
are legal, subject to protocol restrictions.
|
static final int NO_RESPONSE_CODE
static final int RESPONSE_CODE_FROM_OFFSET
void addHeader(String name, String value)
name to value.
The capacity of this method is similar to the
URLConnection.addRequestProperty(String, String)
boolean dispatchAddResumeOffset(String etag, long offset)
offset length.etag - the etag is stored by the past downloaded.offset - the offset length has already been downloaded.true if adding resume offset was dispatched, so we can't handle that by
internal.InputStream getInputStream() throws IOException
The capacity of this method is similar to the URLConnection.getInputStream()
IOExceptionMap<String,List<String>> getRequestHeaderFields()
The capacity of this method is similar to the URLConnection.getRequestProperties()
Map<String,List<String>> getResponseHeaderFields()
The capacity of this method is similar to the URLConnection.getHeaderFields()
String getResponseHeaderField(String name)
If called on a connection that sets the same header multiple times with possibly different values, only the last value is returned.
name - the name of a header field.null
if there is no such field in the header.boolean setRequestMethod(String method) throws ProtocolException
method - the HTTP methodtrue if set effect, otherwise false.ProtocolException - if the method cannot be reset or if
the requested method isn't valid for HTTP.SecurityException - if a security manager is set and the
method is "TRACE", but the "allowHttpTrace"
NetPermission is not granted.void execute()
throws IOException
IOExceptionint getResponseCode()
throws IOException
If this is not http/https protocol connection:
1. If you make sure this connection is resume from the offset breakpoint(which you can check
out this through dispatchAddResumeOffset(String, long)), please return
RESPONSE_CODE_FROM_OFFSET
2. otherwise, return NO_RESPONSE_CODE.
IOExceptionvoid ending()