android - 获取 Post Request Retrofit OkHttp 的 URL Header 响应
问题描述
我一直在阅读很多资源,但我似乎无法得到答案。我要做的是从 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) {
}
});
}
解决方案
推荐阅读
- javascript - VueJS多个嵌套路由不由路由器视图呈现
- docker - 使用 supervisord 在 docker 中生成 JSON 格式的 celery 日志
- docker - Docker compose 生成匿名卷而不是现有的命名卷
- dialogflow-es - 在 Dialogflow 中是否可以进行手动聊天?
- amazon-web-services - 如何从 S3 存储桶中的文件夹中删除带有后缀的图像
- javascript - 如何获取自定义属性(CSS 变量)列表?- 类似`getPropertyEntries()`
- tensorflow - 训练期间如何在 Keras 中使用 get_updates() of optimizers.SGD?
- android - Failed to notify project evaluation listener: ReactNative
- django - Django 使用 Postgres 在 JSONField 中注释计数
- git - error: failed to push some refs to 'https://git.heroku.com/nameless-cliffs-57613.git'