Skip to content

Commit 5ecf7c5

Browse files
committed
[Issue AFNetworking#6] Fallback on serialized response object if responseString is not available
1 parent 5142562 commit 5ecf7c5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

AFNetworkActivityLogger/AFNetworkActivityLogger.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,11 @@ - (void)networkRequestDidFinish:(NSNotification *)notification {
135135
responseHeaderFields = [(NSHTTPURLResponse *)response allHeaderFields];
136136
}
137137

138-
NSString *responseString = nil;
138+
id responseObject = nil;
139139
if ([[notification object] respondsToSelector:@selector(responseString)]) {
140-
responseString = [[notification object] responseString];
140+
responseObject = [[notification object] responseString];
141+
} else if (notification.userInfo) {
142+
responseObject = notification.userInfo[AFNetworkingTaskDidCompleteSerializedResponseKey];
141143
}
142144

143145
NSTimeInterval elapsedTime = [[NSDate date] timeIntervalSinceDate:objc_getAssociatedObject(notification.object, AFNetworkRequestStartDate)];
@@ -155,7 +157,7 @@ - (void)networkRequestDidFinish:(NSNotification *)notification {
155157
} else {
156158
switch (self.level) {
157159
case AFLoggerLevelDebug:
158-
NSLog(@"%ld '%@' [%.04f s]: %@ %@", (long)responseStatusCode, [[response URL] absoluteString], elapsedTime, responseHeaderFields, responseString);
160+
NSLog(@"%ld '%@' [%.04f s]: %@ %@", (long)responseStatusCode, [[response URL] absoluteString], elapsedTime, responseHeaderFields, responseObject);
159161
break;
160162
case AFLoggerLevelInfo:
161163
NSLog(@"%ld '%@' [%.04f s]", (long)responseStatusCode, [[response URL] absoluteString], elapsedTime);

0 commit comments

Comments
 (0)