我正在使用多部分API,除了401之外,它在所有2XX和4XX情况下工作正常,它无法映射到ClientResponse类并抛出ClientHandlerException,这就是我打电话的方式:
ClientResponse response = client.resource(uri)
.accept("application/json")
.header("X-FORWARDED-FOR", "X.X.X.X")
.header("Authorization", authorization)
.type(MediaType.MULTIPART_FORM_DATA_TYPE)
.post(ClientResponse.class, part);
athorization: Basic authorization header
part: FormDataMultiPart object
这是错误日志:
ERROR [2017-06-02 21:46:01,362] [ ] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: 91277b4e45d2df98
! com.sun.jersey.api.client.ClientHandlerException: java.io.IOException: Error writing to server
! at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:155)
! at com.sun.jersey.api.client.Client.handle(Client.java:652)
! at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)
! at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
! at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570)
......更多应用程序日志然后..
! Caused by: java.io.IOException: Error writing to server
! at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:666)
! at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:666)
! at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1534)
Jersey-client版本:1.18.1