1

I am writing one client to measure Jersey, REST based web service performance. I have written some code to measure response time and to measure number of bytes sent from the server but response.getLength() method always returning -1.

In many QA forum I read that setting client.setChunkedEncodingSize(null) will work but even after setting this, I am getting -1.

From server side, I am sending response of type XML or JSON or protobuf depending upon parameters sent by client. For all of these response types, I am getting response length as -1.

My actual request looks like below:

WebResource webResourceQuery = client.resource(requestUrl);
ClientResponse response = webResourceQuery.header("Authorization", header)
                                          .accept(MediaType.APPLICATION_JSON)
                                          .get(ClientResponse.class);

From server side, I am not setting content-length explicitly. Can anyone please help me in getting content-length on client side?

Whole purpose of this experiment is to measure which response type is more efficient in terms of response time and amount of data sent/received.

4

1 回答 1

0

我遇到了同样的问题:client.setChunkedEncodingSize(null);不起作用。

这对我来说实际上禁用了分块编码:

client.getProperties().put(ApacheHttpClient4Config.PROPERTY_ENABLE_BUFFERING, true);
于 2015-03-09T22:51:30.543 回答