Or thinking the interceptor for this scenario applicable ?

Our app using OkHttp for downloading files (new version of app, daily databases etc.) 

Sometimes server fails just while the app streaming bytes (btw the problem is, recvfrom failed: ECONNRESET)

So to fix this case i just wanted to write OkHttp retry interceptor. But seems this is appropriate for operations which aren't streaming.

Is there a solution(like interceptor) to handle this case ?

---

To make more clear exposition

0%==============================100% (*Just started streaming)*

0%**===**===========================100% (*10% completed*)

0%**======**========================100% (*20% completed*)

0%**======**========================100% (*ECONNRESET - Connection reset by peer*)

At just this point, streaming gets stopped. The thing i'm wishing from OkHttp is **recognizing this situation then starting the stream from scratch (not from 20%)**

---

Related code here, pay attention to comments

```
 Call call = client.newCall(new Request.Builder().url(url).get().build());
 Response response = call.execute();
 // PROBLEM DOES NOT OCCUR THERE
 // PROBLEM DOES NOT OCCUR THERE
 // PROBLEM DOES NOT OCCUR THERE
 if (response.code() == 200 || response.code() == 201) {
     InputStream inputStream = null;
     try {
         long downloaded = 0;
         byte[] buff = new byte[1024 * 4];
         inputStream = response.body().byteStream();
         long target = response.body().contentLength();
         while (true) {
             // EXCEPTION OCCURS THERE
             // EXCEPTION OCCURS THERE
             // EXCEPTION OCCURS THERE
             int read = inputStream.read(buff);
             if (read == -1) {
                 break;
             }
             downloaded += read;
         }
         ...
     } catch (IOException e) {
         // EXCEPTION SAYS 
         // ECONNRESET - Connection reset by peer
         ...
     }
}

```