Получить ответ заголовка URL-адреса после запроса на обновление OkHttp - PullRequest
0 голосов
/ 06 декабря 2018

Я читал много ресурсов, но я не могу получить ответ на этот вопрос.То, что я пытаюсь сделать, это получить ответ заголовка от запроса POST, и этот ответ является URL, используя Retrofit и OK.Мне удалось успешно получить другие ответы, кроме 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) {

            }
        });

    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...