2015-09-16 38 views
1

我已閱讀本:compress-responses-in-jersey和有澤西2配置:澤西2 gzip壓縮沒有Content-Encoding頭響應

@ApplicationPath("/jaxrs/") 
public class AppConfig extends ResourceConfig { 

    public AppConfig() { 
     super(AdvertisementResource.class, MultiPartFeature.class); 
     packages("jaxrs"); 
     EncodingFilter.enableFor(this, GZipEncoder.class, DeflateEncoder.class); 
    } 
} 

我已經頭請求:

GET http://localhost:8081/jaxrs/admin-adblock 
Accept:application/json 
Cache-Control:no-cache 
Content-Type:application/json 
Authorization:Basic c21h... 
Accept-Encoding:gzip,deflate 

但標頭響應是:響應Content-Encoding:gzip

HTTP/1.1 200 OK 
Content-Type: application/json 
Vary: Accept-Encoding 
Server: Jetty(9.2.2.v20140723) 

頭僅丟失的出現,如果我有:

EncodingFilter.enableFor(this, GZipEncoder.class, DeflateEncoder.class); 

如果我刪除壓縮和評論EncodingFilter行響應頭有:

HTTP/1.1 200 OK 
Content-Type: application/json 
Transfer-Encoding: chunked 
Server: Jetty(9.2.2.v20140723) 

或本:

HTTP/1.1 200 OK 
Content-Type: application/json 
Content-Length: 369 
Server: Jetty(9.2.2.v20140723) 

我真的測試與Intellij Rest Client Tool和我不確定我是否收到來自服務器的壓縮響應?

我下載的球衣來源,並與設定的IntelliJ斷點here和調試REST服務的Web應用程序看起來CONTENT_ENCODING的gzip在這裏補充說:

response.getHeaders().putSingle(HttpHeaders.CONTENT_ENCODING, contentEncoding); 

但其在響應頭的IntelliJ從REST客戶端工具失蹤..

回答

0

我已經下載了SoapUI和測試相同的REST請求的響應頭:

HTTP/1.1 200 OK 
Content-Type: application/json 
Vary: Accept-Encoding 
Content-Encoding: gzip 
Content-Length: 204 
Server: Jetty(9.2.2.v20140723) 

的我ntellij Rest客戶端工具隱藏響應標題內容編碼和內容長度.. 我已打開新的issue