Fast-Android-Networking上传图片java.net.ProtocolException: unexpected end of stream

1缘由:

最近做一个上传图片的需求,发现用Fast-Android-Networking上传图片的时候一直报一个异常 java.net.ProtocolException: unexpected end of stream。

2.原因:

原因是设置打印log的拦截器的等级设置成body导致的就是

  HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
        loggingInterceptor.setLevel(  HttpLoggingInterceptor.Level.BODY);
        OkHttpClient okHttpClient = builder
                .addInterceptor(loggingInterceptor)
                .proxy( Proxy.NO_PROXY)
                .build();

3.解决办法

  HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
        loggingInterceptor.setLevel(  HttpLoggingInterceptor.Level.HEADERS);
        OkHttpClient okHttpClient = builder
                .addInterceptor(loggingInterceptor)
                .proxy( Proxy.NO_PROXY)
                .build();

然后我尝试把HttpLoggingInterceptor.Level.BODY 修改成HttpLoggingInterceptor.Level.HEADERS之后可以了。只是找到解决办法了没有找到为什么 是这样。如果有大佬看源码找到原因可以 告知一下小弟

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容