public abstract class SonicSessionConnection
extends java.lang.Object
SonicSessionConnection
is the superclass
of all classes that represent a communications link between the
application and a URL. Instances of this class can be used both to
read from and to write to the resource referenced by the URL限定符和类型 | 类和说明 |
---|---|
class |
SonicSessionConnection.ResponseDataTuple
A holder caches information about the input and output stream .
|
static class |
SonicSessionConnection.SessionConnectionDefaultImpl |
限定符和类型 | 字段和说明 |
---|---|
static java.lang.String |
CUSTOM_HEAD_FILED_CACHE_OFFLINE
HTTP header:cache-offline.
|
static java.lang.String |
CUSTOM_HEAD_FILED_DNS_PREFETCH
HTTP Header:dns-prefetch.
|
static java.lang.String |
CUSTOM_HEAD_FILED_ETAG
HTTP header:eTag.
|
static java.lang.String |
CUSTOM_HEAD_FILED_TEMPLATE_CHANGE
HTTP header:template_change.
|
static java.lang.String |
CUSTOM_HEAD_FILED_TEMPLATE_TAG
HTTP header:template_tag.
|
static java.lang.String |
DNS_PREFETCH_ADDRESS
HTTP header:dns-prefetch-address
This header represents the ip address of the server. |
static java.lang.String |
HTTP_HEAD_CSP
HTTP Header:Content-Security-Policy.
|
static java.lang.String |
HTTP_HEAD_CSP_REPORT_ONLY
HTTP Header:Content-Security-Policy-Report-Only.
|
protected android.content.Intent |
intent
This intent saves all of the initialization param.
|
protected java.io.BufferedInputStream |
responseStream
The input stream that reads from this open connection.
|
protected SonicSession |
session
SonicSession Object used by SonicSessionConnection.
|
构造器和说明 |
---|
SonicSessionConnection(SonicSession session,
android.content.Intent intent)
Constructor
|
限定符和类型 | 方法和说明 |
---|---|
int |
connect()
Opens a communications link to the resource referenced by Sonic session
|
abstract void |
disconnect()
Disconnect the communications link to the resource referenced by Sonic session
|
abstract int |
getResponseCode() |
java.io.ByteArrayOutputStream |
getResponseData()
Reads all of data from
getResponseStream() into byte array output stream. |
SonicSessionConnection.ResponseDataTuple |
getResponseData(java.util.concurrent.atomic.AtomicBoolean breakCondition,
java.io.ByteArrayOutputStream outputStream)
Reads all of data from
getResponseStream() into byte array output stream outputStream . |
abstract java.lang.String |
getResponseHeaderField(java.lang.String key) |
abstract java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getResponseHeaderFields() |
java.io.BufferedInputStream |
getResponseStream() |
protected abstract int |
internalConnect() |
protected abstract java.io.BufferedInputStream |
internalGetResponseStream() |
public static final java.lang.String CUSTOM_HEAD_FILED_ETAG
public static final java.lang.String CUSTOM_HEAD_FILED_TEMPLATE_TAG
public static final java.lang.String CUSTOM_HEAD_FILED_TEMPLATE_CHANGE
public static final java.lang.String CUSTOM_HEAD_FILED_CACHE_OFFLINE
public static final java.lang.String DNS_PREFETCH_ADDRESS
public static final java.lang.String CUSTOM_HEAD_FILED_DNS_PREFETCH
DNS_PREFETCH_ADDRESS
public static final java.lang.String HTTP_HEAD_CSP
public static final java.lang.String HTTP_HEAD_CSP_REPORT_ONLY
protected final SonicSession session
protected final android.content.Intent intent
protected java.io.BufferedInputStream responseStream
public SonicSessionConnection(SonicSession session, android.content.Intent intent)
session
- The SonicSession instanceintent
- The intentpublic int connect()
public abstract void disconnect()
public abstract int getResponseCode()
public abstract java.util.Map<java.lang.String,java.util.List<java.lang.String>> getResponseHeaderFields()
public abstract java.lang.String getResponseHeaderField(java.lang.String key)
key
- the name of a header field.public java.io.BufferedInputStream getResponseStream()
public java.io.ByteArrayOutputStream getResponseData()
getResponseStream()
into byte array output stream. Note: This method blocks until the end of the input stream has been reached
getResponseStream()
public SonicSessionConnection.ResponseDataTuple getResponseData(java.util.concurrent.atomic.AtomicBoolean breakCondition, java.io.ByteArrayOutputStream outputStream)
getResponseStream()
into byte array output stream outputStream
.
And then this method returns SonicSessionConnection.ResponseDataTuple
object which holds the input and output stream. Note: This method blocks until the end of the input stream has been reached or breakCondition
has been reset to true.
breakCondition
- This method won't read any data from getResponseStream()
if breakCondition
is false.outputStream
- This method will reuse this byte array output stream instead of creating new output stream.SonicSessionConnection.ResponseDataTuple
caches information about the all of the stream and the state which indicates there is no more data.protected abstract int internalConnect()
protected abstract java.io.BufferedInputStream internalGetResponseStream()