StringCronetCallback

abstract class StringCronetCallback : InMemoryTransformCronetCallback


A specialization of InMemoryTransformCronetCallback that interprets the response body as a string.

The charset used to decode the string is derived from the Content-Type header.

Summary

Public functions

StringCronetCallback!

Adds a completion listener.

Protected functions

String!

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

Inherited functions

From org.chromium.net.apihelpers.ImplicitFlowControlCallback
Unit
onCanceled(request: UrlRequest!, info: UrlResponseInfo!)

Invoked if request was canceled via cancel.

Unit
onFailed(
    request: UrlRequest!,
    info: UrlResponseInfo!,
    error: CronetException!
)

Invoked if request failed for any reason after start.

Unit
onReadCompleted(
    request: UrlRequest!,
    info: UrlResponseInfo!,
    byteBuffer: ByteBuffer!
)

Invoked whenever part of the response body has been read.

Unit
onRedirectReceived(
    request: UrlRequest!,
    info: UrlResponseInfo!,
    newLocationUrl: String!
)

Invoked whenever a redirect is encountered.

Unit

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

Unit
onSucceeded(request: UrlRequest!, info: UrlResponseInfo!)

Invoked when request is completed successfully.

abstract Boolean
shouldFollowRedirect(info: UrlResponseInfo!, newLocationUrl: String!)

Invoked whenever a redirect is encountered.

From org.chromium.net.apihelpers.InMemoryTransformCronetCallback
Unit

Invoked whenever part of the response body has been read.

Unit

Invoked if request was canceled via cancel.

Unit
onFailed(info: UrlResponseInfo?, exception: CronetException!)

Invoked if request failed for any reason after start.

Unit

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

Unit

Invoked when request is completed successfully.

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

Invoked if request failed for any reason after start.

abstract Unit
onReadCompleted(
    request: UrlRequest!,
    info: UrlResponseInfo!,
    byteBuffer: ByteBuffer!
)

Invoked whenever part of the response body has been read.

abstract Unit
onRedirectReceived(
    request: UrlRequest!,
    info: UrlResponseInfo!,
    newLocationUrl: String!
)

Invoked whenever a redirect is encountered.

Public functions

addCompletionListener

fun addCompletionListener(
    listener: CronetRequestCompletionListener<String!>!
): StringCronetCallback!

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 functions

transformBodyBytes

protected fun transformBodyBytes(info: UrlResponseInfo!, bodyBytes: ByteArray!): String!

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.