With Retrofit 1.9.0, if you use the Callback asynchronous version of the interface,
@GET("/user")
void getUser(Callback<User> callback)
Then your callback will receive a Response
object
Callback<User> user = new Callback<User>() {
@Override
public void success(User user, Response response) {
}
@Override
public void failure(RetrofitError error) {
}
}
Which has a method called getHeaders()
Callback<User> user = new Callback<User>() {
@Override
public void success(User user, Response response) {
List<Header> headerList = response.getHeaders();
for(Header header : headerList) {
Log.d(TAG, header.getName() + " " + header.getValue());
}
}
For Retrofit 2.0's interface, you can do this with Call<T>
.
For Retrofit 2.0's Rx support, you can do this with Observable<Result<T>>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…