Square Modification of Parsing Logic: Streaming?

Could you explain the logic for parsing Square Retrofit's answer. I am interested in the case when we need to get and analyze large json (> 100Kb) - will Retrofit wait until all the content is received from the server and only after analyzing it, or will it start to parse it immediately when receiving the stream data? My goal is to speed up response processing.

Does he have any options for customization?

+5
source share
1 answer

Once the HTTP client parses the headers, the InputStream will be returned to "Retrofit", which will then pass it directly to Converter . This means that since the main conversion mechanism (say Gson) pulls bytes, they are read (and potentially blocked) directly from the network.

Note: this is only true if logging is disabled (as it should be in production / release assemblies). When logging is enabled outside of the HEADERS level, the response body must be fully read in byte[] in order to both log and transmit data to the converter.

+12
source

Source: https://habr.com/ru/post/1213602/


All Articles