如何在解析为 dto 之前获取 http 球衣响应状态?

how to get http jersey response status before parsing to dto?

我的代码曾经是:

ClientResponse clientResponse = webResource.path("routingRequest")
                    .queryParam("at", rr.at)
                    .get(ClientResponse.class);

我补充道:

RoutingResponse routingResponse = webResource.path("routingRequest")
                    .queryParam("at", rr.at)
                    .get(ClientResponse.class)
                    .getEntity(RoutingResponse.class);

如何获取 http 结果代码,现在连 ClientResponse.class

都没有

您将如何获得此身份?

没有理由不能同时读取客户端响应和实体主体。

    ClientConfig cc = new DefaultClientConfig();
    cc.getProperties().put(
            ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true);
    Client c = Client.create(cc);
    WebResource r = c.resource("https://my_url");
    ClientResponse response = r.get(ClientResponse.class);
    EntityTag e = response.getEntityTag();
    String entity = response.getEntity(String.class);
    System.out.println("The response status is " + response.getStatus());
    System.out.println("The enttiy body is " + entity);