Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android OkHttp切断了长响应_Android_Http_Get_Okhttp_Okhttp3 - Fatal编程技术网

Android OkHttp切断了长响应

Android OkHttp切断了长响应,android,http,get,okhttp,okhttp3,Android,Http,Get,Okhttp,Okhttp3,我需要使用clientOkHttpClient(OkHttp3)获取html页面的源代码。 为此,应使用以下代码: @Override public String loadInBackground() { try { HttpLoggingInterceptor mLogging = new HttpLoggingInterceptor(); mLogging.setLevel(HttpLoggingIntercep

我需要使用client
OkHttpClient
(OkHttp3)获取html页面的源代码。
为此,应使用以下代码:

    @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();
        }
    }
它可以工作,但只返回250个字符多一点,代码超过9500个字符。如何获得完整的回复?


另外,日志是使用HttpLoggingInterceptor获取的,它显示完整的响应。

日志语句不会打印整个字符串


确定字符串长度并打印以查看。

您的意思是什么?我定义了字符串的长度
response.body().string().length()
,但如何在日志中显示整个字符串?
我定义了字符串响应的长度.body().string().length()
。你的意思是:
我用response.body().string().length()确定了字符串的长度。
?那么它的长度是多少?