Andrei Anhurets
Andrei Anhurets

Reputation: 135

OkHttp cut the long response

I need to get the source code of html pages with client OkHttpClient (OkHttp3).
For this purpose the following code:

    @Override
    public String loadInBackground() {
        try {
            HttpLoggingInterceptor mLogging = new HttpLoggingInterceptor();
            mLogging.setLevel(HttpLoggingInterceptor.Level.BODY);
            OkHttpClient mClient = new OkHttpClient.Builder().addInterceptor(mLogging).build();
            Request mRequest = new Request.Builder()
                    .url("some url")
                    .build();
            Response mResponse = mClient.newCall(mRequest).execute();
            Log.i(TAG, "loadInBackground: " + mResponse.body().string());
            return mResponse.body().string();
        } catch (IOException e) {
            return new String();
        }
    }

It works, but only returns a little more than 250 characters, the code is more than 9500 characters. How do I get a full response?

P.S. The log is obtained using HttpLoggingInterceptor displays the full response.

Upvotes: 3

Views: 940

Answers (1)

greenapps
greenapps

Reputation: 11224

The Log statements do not print the whole string.

Determine string length and print to see.

Upvotes: 2

Related Questions