Modernization: how to get the size of the request and response?

I am developing an Android application and use the modification to send requests and receive responses. Like this:

public interface Service {
    @POST("/GetInfo")
    InfoResponse getInfo(@Body InfoRequest request);
}

I want to know how much data it will use when performing these queries.

I find that if I install LogLevel for modification, it can print the size in the log.

For request:

---> HTTP POST http://....
Content-Type: application/json; charset=UTF-8
Content-Length: 516
---> END HTTP (522-byte body)

For the answer:

<--- HTTP 200  http://....
:HTTP/1.1 200 OK 
Content-Type: application/json 
<--- END HTTP (420394-byte body)

This 522-byte and 420394-byte information is what I want. Is there a way to get it directly without getting a log and not parsing it?

If I need to use this log to calculate the size, is there any good way to get the size from the log and then show on android?

Thank!

+4
source share

All Articles