RestEasy Response不包含诸如Content-Length之类的所有标头

时间:2018-08-10 02:18:10

标签: java rest http-headers

我有一个resteasy客户端,它使用InvocationCallback进行异步调用,该调用将响应返回到completed()方法中。

当我在debug或do中查看响应对象时

response.getHeaders() 

我只有两个

Content-Type:application/json
Server:Jetty(6.1.26)

在调试模式下,当我查看日志时会得到

2018-08-10 11:48:46,603 DEBUG (21321) %T  pool-6-thread-1  [apache.http.headers] http-outgoing-0 << HTTP/1.1 200 OK
2018-08-10 11:48:46,603 DEBUG (21321) %T  pool-6-thread-1  [apache.http.headers] http-outgoing-0 << Content-Type: application/json
2018-08-10 11:48:46,603 DEBUG (21321) %T  pool-6-thread-1  [apache.http.headers] http-outgoing-0 << Content-Encoding: gzip
2018-08-10 11:48:46,603 DEBUG (21321) %T  pool-6-thread-1  [apache.http.headers] http-outgoing-0 << Content-Length: 459
2018-08-10 11:48:46,603 DEBUG (21321) %T  pool-6-thread-1  [apache.http.headers] http-outgoing-0 << Server: Jetty(6.1.26)

所以他们在那里。为什么在getHeader()中未返回“ Content-Length:459”和“ Content-Encoding:gzip”。 response.getLength()返回-1;实际上,getLength表示它提供了Content-Length的值。

public void completed(Response response) {
        log.info("Response Completed with response: " + response.getStatus());

        response.getHeaders();// returns only 2 in multiValuemap
response.getLength(); // returns -1
    }

0 个答案:

没有答案