sendRequest

abstract fun sendRequest(request: HttpRequest, completion: Callback<NetworkResult>): Disposable

Sends an HTTP request asynchronously and returns the result to the provided completion block. The request is retried if necessary based on the provided request and the response NetworkResult.

Return

A Disposable that can be used to cancel the request.

Parameters

request

The HttpRequest object representing the request to be sent.

completion

The block to receive the result of the network request. This will be called on Tealium's background thread.


abstract fun sendRequest(request: HttpRequest.Builder, completion: Callback<NetworkResult>): Disposable

Builds the request and sends it asynchronously, returning the result to the provided completion block.

Unlike sendRequest, this overload takes an unbuilt HttpRequest.Builder and so absorbs the MalformedURLException that HttpRequest.Builder.build may throw for an invalid url. In that case no request is made, completion is called with a NetworkResult.Failure wrapping a NetworkException.UnexpectedException, and a disposed Disposable is returned.

Return

A Disposable that can be used to cancel the request.

Parameters

request

The HttpRequest.Builder representing the request to be built and sent.

completion

The block to receive the result of the network request. This will be called on Tealium's background thread.