Skip to content

Commit

Permalink
fixes #64
Browse files Browse the repository at this point in the history
  • Loading branch information
Ron Radtke authored and Ron Radtke committed Sep 29, 2021
1 parent ece3401 commit 6806822
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,9 @@ public Response intercept(Chain chain) throws IOException {
clientBuilder.addInterceptor(new Interceptor() {
@Override
public Response intercept(@NonNull Chain chain) throws IOException {
Response originalResponse = null;
try {
Response originalResponse = chain.proceed(req);
originalResponse = chain.proceed(req);
ResponseBody extended;
switch (responseType) {
case KeepInMemory:
Expand Down Expand Up @@ -428,12 +429,21 @@ public Response intercept(@NonNull Chain chain) throws IOException {
return originalResponse.newBuilder().body(extended).build();
} catch (SocketException e) {
timeout = true;
if (originalResponse != null) {
originalResponse.close();
}
} catch (SocketTimeoutException e) {
timeout = true;
if (originalResponse != null) {
originalResponse.close();
}
//ReactNativeBlobUtilUtils.emitWarningEvent("ReactNativeBlobUtil error when sending request : " + e.getLocalizedMessage());
} catch (Exception ex) {

if (originalResponse != null) {
originalResponse.close();
}
}

return chain.proceed(chain.request());
}
});
Expand Down

0 comments on commit 6806822

Please sign in to comment.