gpt4 book ai didi

java - com.sun.jersey.api.client.ClientHandlerException : java. io.IOException:过早的 EOF

转载 作者:行者123 更新时间:2023-11-30 10:46:20 32 4
gpt4 key购买 nike

我正在使用 jersey api 客户端调用基于 REST 的网络服务(该服务托管在我的本地主机中)。当我打电话时

String entity = (client response object here).getEntity(String.class);

我遇到以下异常:

Caused by: java.io.IOException: Premature EOF
at sun.net.www.http.ChunkedInputStream.readAheadBlocking(ChunkedInputStream.java:565) ~[?:1.7.0_71]
at sun.net.www.http.ChunkedInputStream.readAhead(ChunkedInputStream.java:609) ~[?:1.7.0_71]
at sun.net.www.http.ChunkedInputStream.read(ChunkedInputStream.java:696) ~[?:1.7.0_71]
at java.io.FilterInputStream.read(FilterInputStream.java:133) ~[?:1.7.0_71]
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3053) ~[?:1.7.0_71]
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283) ~[?:1.7.0_71]
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325) ~[?:1.7.0_71]
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177) ~[?:1.7.0_71]
at java.io.InputStreamReader.read(InputStreamReader.java:184) ~[?:1.7.0_71]
at java.io.Reader.read(Reader.java:140) ~[?:1.7.0_71]
at com.sun.jersey.core.util.ReaderWriter.readFromAsString(ReaderWriter.java:171) ~[jersey-core-1.17.jar:1.17]
at com.sun.jersey.core.util.ReaderWriter.readFromAsString(ReaderWriter.java:157) ~[jersey-core-1.17.jar:1.17]
at com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.readFromAsString(AbstractMessageReaderWriterProvider.java:114) ~[jersey-core-1.17.jar:1.17]
at com.sun.jersey.core.impl.provider.entity.StringProvider.readFrom(StringProvider.java:73) ~[jersey-core-1.17.jar:1.17]
at com.sun.jersey.core.impl.provider.entity.StringProvider.readFrom(StringProvider.java:58) ~[jersey-core-1.17.jar:1.17]
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:565) ~[jersey-client-1.17.jar:1.17]
... 59 more

我知道我的网络服务器正在给我 200 OK 响应。查看从基于 REST 的 webserive 获得的 json 响应:

  {"user_likes":[],"status_code":200,"status_msg":"OK"}

Here is the response of my webservie:-

* Adding handle: conn: 0x7fee13808c00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fee13808c00) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 8080 (#0)
* Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /social/69124/likes/?comic_uuids=ccd48dca-955f-4ad4-838e-aa558b86679d,ff201290-1f92-4b13-bf11-20b61500a9aa,f1e77de0-0c75-4f0c-8515-7fa90e9a6baa,11e19c81-9e74-4a96-a34f-9696c3ab4a4e,152a624e-e06b-47ed-83bc-75ce26ce4a13,e9f0e9d6-5e35-4012-a7a9-6c37d5781205,7c718479-d8ed-4b67-9584-1647c34c08f2,4febbdde-8ab7-4127-b178-6c91f58deab5,ad583bc5-17d6-4982-9412-26fadfb8e261,1a53e323-5577-49a3-8151-a39a75084636 HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost:8080
> Accept: */*
>
HTTP/1.1 200 OK
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< Access-Control-Allow-Origin: *
< Content-Type: application/json;charset=utf-8
< Transfer-Encoding: chunked
< Date: Wed, 13 Apr 2016 10:28:51 GMT
<
* transfer closed with outstanding read data remaining
* Closing connection 0
curl: (18) transfer closed with outstanding read data remaining
{"user_likes":[],"status_code":200,"status_msg":"OK"}

请在这方面帮助我。

最佳答案

从您的服务器中可以清楚地看出,响应中的 Content-Length header 存在问题。它不包含 Content-Length header 。您应该将其添加到具有正确值的响应中。

关于java - com.sun.jersey.api.client.ClientHandlerException : java. io.IOException:过早的 EOF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36593686/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com