改进POST java.io.EOFException

时间:2015-06-10 21:46:17

标签: java android retrofit eofexception

我正在尝试使用json正文对我的服务器发出POST请求。如果我的POST请求没有正文,则可以。如果我有任何正文内容,我会收到此EOFException。如果我错过任何细节,请告诉我。

public static class MyMessage{
    String local;
}

消息模型:

@POST("/user/{user_id}/message")
void createMessage(
        @Path("user_id") long user_id,
        @Body MyMessage json,
        MyCallback cb);

改造后的帖子:

06-10 18:25:18.575: D/Retrofit(28598): ---> HTTP POST XXX/user/1111158/message
06-10 18:25:18.575: D/Retrofit(28598): Content-Type: application/json; charset=UTF-8
06-10 18:25:18.575: D/Retrofit(28598): Content-Length: 16
06-10 18:25:18.576: D/Retrofit(28598): {"local":"xyzw"}
06-10 18:25:18.576: D/Retrofit(28598): ---> END HTTP (16-byte body)
06-10 18:25:18.579: D/Retrofit(28598): ---- ERROR XXX/user/1111158/message
06-10 18:25:18.581: D/Retrofit(28598): java.io.EOFException
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.okio.RealBufferedSource.readUtf8Line(RealBufferedSource.java:90)
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:145)
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:99)
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:568)
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:372)
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:319)
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:484)
06-10 18:25:18.581: D/Retrofit(28598):  at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:71)
06-10 18:25:18.581: D/Retrofit(28598):  at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
06-10 18:25:18.581: D/Retrofit(28598):  at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:358)
06-10 18:25:18.581: D/Retrofit(28598):  at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:264)
06-10 18:25:18.581: D/Retrofit(28598):  at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:315)
06-10 18:25:18.581: D/Retrofit(28598):  at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
06-10 18:25:18.581: D/Retrofit(28598):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
06-10 18:25:18.581: D/Retrofit(28598):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
06-10 18:25:18.581: D/Retrofit(28598):  at java.lang.Thread.run(Thread.java:841)
06-10 18:25:18.581: D/Retrofit(28598): ---- END ERROR

记录错误:

testUtilities.js

0 个答案:

没有答案