ByteArrayCronetCallback

public abstract class ByteArrayCronetCallback extends InMemoryTransformCronetCallback


A specialization of InMemoryTransformCronetCallback which returns the body bytes verbatim without any interpretation.

Summary

Public constructors

Public methods

ByteArrayCronetCallback

Adds a completion listener.

Protected methods

final byte[]
transformBodyBytes(UrlResponseInfo info, byte[] bodyBytes)

Transforms (deserializes) the plain full body into a user-defined object.

Inherited methods

From org.chromium.net.apihelpers.ImplicitFlowControlCallback
final void

Invoked if request was canceled via cancel.

final void
onFailed(
    UrlRequest request,
    UrlResponseInfo info,
    CronetException error
)

Invoked if request failed for any reason after start.

final void
onReadCompleted(
    UrlRequest request,
    UrlResponseInfo info,
    ByteBuffer byteBuffer
)

Invoked whenever part of the response body has been read.

final void
onRedirectReceived(
    UrlRequest request,
    UrlResponseInfo info,
    String newLocationUrl
)

Invoked whenever a redirect is encountered.

final void

Invoked when the final set of headers, after all redirects, is received.

final void

Invoked when request is completed successfully.

abstract boolean

Invoked whenever a redirect is encountered.

From org.chromium.net.apihelpers.InMemoryTransformCronetCallback
final void

Invoked whenever part of the response body has been read.

final void

Invoked if request was canceled via cancel.

final void

Invoked if request failed for any reason after start.

final void

Invoked when the final set of headers, after all redirects, is received.

final void

Invoked when request is completed successfully.

From org.chromium.net.UrlRequest.Callback
abstract void
onFailed(
    UrlRequest request,
    UrlResponseInfo info,
    CronetException error
)

Invoked if request failed for any reason after start.

abstract void
onReadCompleted(
    UrlRequest request,
    UrlResponseInfo info,
    ByteBuffer byteBuffer
)

Invoked whenever part of the response body has been read.

abstract void
onRedirectReceived(
    UrlRequest request,
    UrlResponseInfo info,
    String newLocationUrl
)

Invoked whenever a redirect is encountered.

Public constructors

ByteArrayCronetCallback

public ByteArrayCronetCallback()

Public methods

addCompletionListener

public ByteArrayCronetCallback addCompletionListener(
    CronetRequestCompletionListener<byte[]> listener
)

Adds a completion listener. All listeners are informed when the request reaches a terminal state, in order of addition. If a listener is added multiple times, it will only be called once according to the first time it was added.

Protected methods

transformBodyBytes

protected final byte[] transformBodyBytes(UrlResponseInfo info, byte[] bodyBytes)

Transforms (deserializes) the plain full body into a user-defined object.

It is assumed that the implementing classes handle edge cases (such as empty and malformed bodies) appropriately. Cronet doesn't inspects the objects and passes them (or any exceptions) along to the issuer of the request.