How to override response header in jersey client

后端 未结 3 1809
盖世英雄少女心
盖世英雄少女心 2020-12-12 02:52

I have a jersey client that I am trying to unmarshall a response entity with. The problem is the remote web service sends back application/octet-stream as the content type s

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-12 03:10

    As laz pointed out, ClientFilter is the way to go:

    client.addFilter(new ClientFilter() {
        @Override
        public ClientResponse handle(ClientRequest request) throws ClientHandlerException {
            request.getHeaders().putSingle(HttpHeaders.CONTENT_TYPE, "application/json");
            return getNext().handle(request);
        }
    });
    

提交回复
热议问题