RequestFinishedInfo

abstract class RequestFinishedInfo


Information about a finished request. Passed to RequestFinishedInfo.Listener.

To associate the data with the original request, use addRequestAnnotation to add a unique identifier when creating the request, and call getAnnotations when the RequestFinishedInfo is received to retrieve the identifier.

Summary

Nested types

Listens for finished requests for the purpose of collecting metrics.

Metrics collected for a single request.

Constants

const Int

Reason value indicating that the request was canceled.

const Int
FAILED = 1

Reason value indicating that the request failed or returned an error.

const Int

Reason value indicating that the request succeeded.

Public constructors

Public functions

abstract (Mutable)Collection<Any!>!

Returns the objects that the caller has supplied when initiating the request, using addRequestAnnotation.

abstract CronetException?

If the request failed, returns the same CronetException provided to onFailed.

abstract Int

Returns the reason why the request finished.

abstract RequestFinishedInfo.Metrics!

Returns metrics collected for this request.

abstract UrlResponseInfo?

Returns a UrlResponseInfo for the request, if its response had started.

abstract String!

Returns the request's original URL.

Constants

CANCELED

const val CANCELED = 2: Int

Reason value indicating that the request was canceled. Returned from getFinishedReason.

FAILED

const val FAILED = 1: Int

Reason value indicating that the request failed or returned an error. Returned from getFinishedReason.

SUCCEEDED

const val SUCCEEDED = 0: Int

Reason value indicating that the request succeeded. Returned from getFinishedReason.

Public constructors

RequestFinishedInfo

RequestFinishedInfo()

Public functions

getAnnotations

abstract fun getAnnotations(): (Mutable)Collection<Any!>!

Returns the objects that the caller has supplied when initiating the request, using addRequestAnnotation. Annotations can be used to associate a RequestFinishedInfo with the original request or type of request.

Returns
(Mutable)Collection<Any!>!

annotations supplied when creating the request

getException

abstract fun getException(): CronetException?

If the request failed, returns the same CronetException provided to onFailed.

Returns
CronetException?

the request's CronetException, if the request failed

getFinishedReason

abstract fun getFinishedReason(): Int

Returns the reason why the request finished.

Returns
Int

one of SUCCEEDED, FAILED, or CANCELED

getMetrics

abstract fun getMetrics(): RequestFinishedInfo.Metrics!

Returns metrics collected for this request.

The reported times and bytes account for all redirects, i.e. the TTFB is from the start of the original request to the ultimate response headers, the TTLB is from the start of the original request to the end of the ultimate response, the received byte count is for all redirects and the ultimate response combined. These cumulative metric definitions are debatable, but are chosen to make sense for user-facing latency analysis.

Returns
RequestFinishedInfo.Metrics!

metrics collected for this request.

getResponseInfo

abstract fun getResponseInfo(): UrlResponseInfo?

Returns a UrlResponseInfo for the request, if its response had started.

Returns
UrlResponseInfo?

UrlResponseInfo for the request, if its response had started.

getUrl

abstract fun getUrl(): String!

Returns the request's original URL.

Returns
String!

the request's original URL