0

I am using Picasso to download images and show them from the server. I need to set basic Aucathention to my requests. And because of that i used this:

'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'

and my code is:

   String url = "images/download/" + images.getiId();

                OkHttpClient client = new OkHttpClient.Builder()
                  .addInterceptor(new Interceptor() {
                    @Override
                    public Response intercept(Chain chain) throws IOException {

                      Request newRequest = chain.request().newBuilder()
                        .addHeader("user_auth", user_auth)
                        .addHeader("user_password", user_pass)
                        .build();
                      return chain.proceed(newRequest);
                    }

                  })
                  .build();

                Picasso picasso = new Picasso.Builder(context)
                  .downloader(new OkHttp3Downloader(client))
                  .build();

                picasso.load(url)
                  .error(R.drawable.error_icon_128)
                  .into(view);
              }

but every time it can't download images And I can't see response code from the server. How can I see response code?

Thank you.

Ehsan
  • 2,676
  • 6
  • 29
  • 56
  • Have you tried this https://github.com/square/okhttp/blob/master/okhttp-logging-interceptor/src/main/java/okhttp3/logging/HttpLoggingInterceptor.java – migos Aug 18 '17 at 15:16
  • Or maybe use ...into(view, callback) – migos Aug 18 '17 at 15:18
  • Possible duplicate of [Picasso Library, Android: Using Error Listener](https://stackoverflow.com/questions/17052538/picasso-library-android-using-error-listener) – an_droid_dev Aug 18 '17 at 15:58

0 Answers0