Skip to content

Commit

Permalink
fix(AWSCore): call response interceptors in HTTP response handlers (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisabhash authored Jan 21, 2025
1 parent d9823c6 commit 2d6ac35
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions AWSCore/Networking/AWSURLSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)sessionTask
if (!delegate.error
&& [sessionTask.response isKindOfClass:[NSHTTPURLResponse class]]) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)sessionTask.response;

for(id<AWSNetworkingHTTPResponseInterceptor>interceptor in delegate.request.responseInterceptors) {
[interceptor interceptResponse:httpResponse
data:nil
originalRequest:sessionTask.originalRequest
currentRequest:sessionTask.currentRequest];
}

if (delegate.shouldWriteToFile) {
NSError *error = nil;
Expand Down Expand Up @@ -351,6 +358,14 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)sessionTask
if (delegate.error
&& ([sessionTask.response isKindOfClass:[NSHTTPURLResponse class]] || sessionTask.response == nil)
&& delegate.request.retryHandler) {

for(id<AWSNetworkingHTTPResponseInterceptor>interceptor in delegate.request.responseInterceptors) {
[interceptor interceptResponse:(NSHTTPURLResponse *)sessionTask.response
data:nil
originalRequest:sessionTask.originalRequest
currentRequest:sessionTask.currentRequest];
}

AWSNetworkingRetryType retryType = [delegate.request.retryHandler shouldRetry:delegate.currentRetryCount
originalRequest:delegate.request
response:(NSHTTPURLResponse *)sessionTask.response
Expand Down

0 comments on commit 2d6ac35

Please sign in to comment.