-
Notifications
You must be signed in to change notification settings - Fork 202
optimization: when responseSerializer is set a AFHTTPResponseSerializer instance #51
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #51 +/- ##
=========================================
+ Coverage 94.86% 95.1% +0.24%
=========================================
Files 4 3 -1
Lines 292 388 +96
Branches 12 0 -12
=========================================
+ Hits 277 369 +92
- Misses 15 19 +4
Continue to review full report at Codecov.
|
…ion, add some test cases
NSLog(@"%ld '%@' [%.04f s]: %@ %@", (long)responseStatusCode, [[task.response URL] absoluteString], elapsedTime, responseHeaderFields, responseObject); | ||
break; | ||
case AFLoggerLevelDebug: { | ||
id responseBody = responseObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when log level is AFLoggerLevelDebug apply the optimization
@@ -265,5 +265,52 @@ - (void)testThatIndividualLoggerIsNotCalledWhenLoggerIsNilledOut { | |||
[manager invalidateSessionCancelingTasks:YES]; | |||
} | |||
|
|||
- (void)testThatResponseSerializerIsAFHTTPResponseSerializerAndResponseBodyIsText { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the test case: when manager.responseSerializer = [AFHTTPResponseSerializer serializer]; and the http response body is text.
[manager invalidateSessionCancelingTasks:YES]; | ||
} | ||
|
||
- (void)testThatResponseSerializerIsAFHTTPResponseSerializerAndResponseBodyIsNotText { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the test case: when manager.responseSerializer = [AFHTTPResponseSerializer serializer]; and the http response body is not text, for example, the response body is a image
…ode if ([request HTTPBody]) in AFNetworkActivityConsoleLogger.m
Tests/AFNetworkActivityLoggerTests.m
Outdated
[self.logger startLogging]; | ||
|
||
[manager | ||
POST:@"post" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the code _if ([request HTTPBody]) {
body = [[NSString alloc] initWithData:[request HTTPBody] encoding:NSUTF8StringEncoding];
}_in AFNetworkActivityConsoleLogger.m is not test. so I find a POST request and has request body to cover it
when responseSerializer is set a AFHTTPResponseSerializer instance, the responseObject is NSData Type, in fact, the response body may be xml、html、x-www-form-urlencoded or other text format, in this case , we can according to Content-Type response header determine whether the response body is text, if the response body is text, we convert it to NSString to print it, beasuse it looks better.