问题:
请求方式 ----> POST
Http 版本:http/1.1
请求头 ----> Content-Type: application/x-www-form-urlencoded
请求参数 ----> token: ZEdsaGJtaHZibWRtWVc0PSRkR2xoYm1odmJtZG1ZVzQ9JE1UWXlOVFExTmpFM05TNDNNVEE0JDRjNDRjZDkwZjViYzBkYzIwMDU3NWM1ZjU3NTYwZDYwu;
请求体 ----> page_id=1&user_id=9124&conds={"type":1,"city_id":"12"}
请求结束 --> END POST (76-byte body)
请求出错 ----> java.io.IOException: unexpected end of stream on http://mob.test.com/...
at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:205)
at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:105)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:82)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at com.ganji.android.core.network.LogInterceptor.intercept(LogInterceptor.java:106)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:37)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:71)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at com.ganji.android.core.network.RedirectInterceptor.intercept(RedirectInterceptor.java:38)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184)
at okhttp3.RealCall$AsyncCall.run(RealCall.kt:136)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.io.EOFException: \n not found: limit=0 content=…
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:231)
at okhttp3.internal.http1.Http1ExchangeCodec.readHead
2021-07-05 14:46:32.920 24045-27647/? D/okhttp-LogInterceptor: erLine(Http1ExchangeCodec.kt:210)
at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:181)
... 25 more
解决方案:(添加上这句话,日志可以正常输出打印)
okhttp3.Request.Builder builder = new okhttp3.Request.Builder()
builder.addHeader("Accept-Encoding", "identity"); //最关键的一句话
但是不知道怎么回事?请教大神解释,,,