我一直在阅读很多资源,但似乎无法获得答案。我想做的是从POST请求获取标头响应,而该响应是使用Retrofit和OK的URL。我能够成功获得URL以外的其他响应。请帮忙。谢谢。
public void getAllProfileRequest() {
final RetrofitClient retrofit = new RetrofitClient();
APIGetAllProfile apiGetAllProfile = retrofit.getClient().create(APIGetAllProfile.class);
Call<List<JSONGetAllProfile>> callProfile = apiGetAllProfile.getResponse();
callProfile.enqueue(new Callback<List<JSONGetAllProfile>>() {
@Override
public void onResponse(Call<List<JSONGetAllProfile>> call, Response<List<JSONGetAllProfile>> response) {
if(response.body() != null) {
List<JSONGetAllProfile> getAllProfile = response.body();
String[] getAllProfileArr = new String[getAllProfile.size()];
for (int i = 0; i < getAllProfile.size(); i++) {
getAllProfileArr[i] = getAllProfile.get(i).getIdentificationProfileId();
String url = getAllProfileArr[i];
String FILE_NAME = recordWavMaster.audioFilePath + ".wav";
//Identify
File file = new File(Environment.getExternalStorageDirectory() + File.separator
+ "AudioRecord" + FILE_NAME);
IdentifyBody identifyBody = new IdentifyBody(file);
APIPostIdentify apiPostIdentify = retrofit.getClient().create(APIPostIdentify.class);
Call<IdentifyBody> callIdentify = apiPostIdentify.identifyUser(url, "true", identifyBody);
callIdentify.enqueue(new Callback<IdentifyBody>() {
@Override
public void onResponse(Call<IdentifyBody> call, Response<IdentifyBody> response) {
Log.e("URL RESPONSE: ", response.raw().request().url() + " ?");
Headers headers = response.headers();
String url = response.headers().get("Expires");
}
@Override
public void onFailure(Call<IdentifyBody> call, Throwable t) {
}
});
}
}
}
@Override
public void onFailure(Call<List<JSONGetAllProfile>> call, Throwable t) {
}
});
}