目录

Callback

Class Info

public abstract class Callback<T>

Callback for an asynchronous request.

Public Constructor Summary

Constructor Name

public Callback()

Default constructor.

Public Method Summary

Qualifier and Type

Method Name and Description

public abstract void

onFailure(Submit<T> submit, Throwable t)

Called when a request failed to be executed due to an exception.

public abstract void

onResponse(Submit<T> submit, Response<T> response)

Called when the requested remote server successfully responds.

Public Constructors

[h2]Callback

Constructor

public Callback()

Default constructor.

Public Methods

[h2]onFailure

Method

public abstract void onFailure(Submit<T> submit, Throwable t)

Called when a request failed to be executed due to an exception, such as request cancellation, connection failure, or timeout during access to the remote server.

Parameters

Name

Description

submit

Submit object.

t

Request exception.

[h2]onResponse

Method

public abstract void onResponse(Submit<T> submit, Response<T> response) throws IOException

Called when the requested remote server successfully responds. This method is used to read the input stream of ResponseBody to obtain the response. Before the input stream is closed, this method can obtain the response by reading the input stream.

Parameters

Name

Description

submit

Submit object.

response

Response result.

Throws

Name

Description

IOException

If an I/O exception occurs in an asynchronous request.