Skip to content
Anirudh Ramanan edited this page Jul 15, 2016 · 2 revisions

NetworkInterpreter is an interface whose implementations are supposed to interpret the input stream and call either the success or failure methods.

It has two methods

  • Response interpretResponseStream(int requestId, NetworkInterceptor.TimeInfo timeInfo, Request request, Response response) throws IOException : This is used to interpret the input stream received from the responsebody, and give back an response object.

  • void interpretError(int requestId, NetworkInterceptor.TimeInfo timeInfo, Request request, IOException e) : This is used to interpret the error received.


The library provides a default implementation of NetworkInterpreter interface, DefaultInterpreter. This is where the important param such as the request size, request url, response size, response time, status code are noted and bubbled to the NetworkEventReporter which is used to report these events further.

There are two type of response, one with Content-Length, and other which does not have the Content-Length in their header.

  1. If the response header contains the Content-Length, we directly notify the event reporter that response has been received.

  2. In case if the response header does not contain the Content-Length, the CountingInputStream is used to read its bytes, and then the reporting is done.

Clone this wiki locally