-
Notifications
You must be signed in to change notification settings - Fork 203
optimization: when responseSerializer is set a AFHTTPResponseSerializer instance #51
base: master
Are you sure you want to change the base?
Changes from 3 commits
ddb7550
502c0c7
8cd2614
1e55cf0
ad064d2
d0f6999
478234f
d87a32a
36788cf
1120a96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -265,5 +265,52 @@ - (void)testThatIndividualLoggerIsNotCalledWhenLoggerIsNilledOut { | |
| [manager invalidateSessionCancelingTasks:YES]; | ||
| } | ||
|
|
||
| - (void)testThatResponseSerializerIsAFHTTPResponseSerializerAndResponseBodyIsText { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| NSURL *baseURL = [NSURL URLWithString:@"https://httpbin.org"]; | ||
| AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:baseURL]; | ||
| manager.responseSerializer = [AFHTTPResponseSerializer serializer]; | ||
| AFNetworkActivityTestLogger *testLogger = [AFNetworkActivityTestLogger new]; | ||
|
|
||
| XCTestExpectation *expectation = [self expectationWithDescription:@"Finish Block Should Be Called"]; | ||
| [testLogger setFinishBlock:^(NSURLSessionTask *task, id responseObject, NSTimeInterval elpasedTime, NSError *error) { | ||
| [expectation fulfill]; | ||
| }]; | ||
| [self.logger addLogger:testLogger]; | ||
| [self.logger setLogLevel:AFLoggerLevelDebug]; | ||
| [self.logger startLogging]; | ||
|
|
||
| [manager | ||
| POST:@"post" | ||
|
||
| parameters:@"x=y" | ||
| progress:nil | ||
| success:nil | ||
| failure:nil]; | ||
| [self waitForExpectationsWithTimeout:10.0 handler:nil]; | ||
| [manager invalidateSessionCancelingTasks:YES]; | ||
| } | ||
|
|
||
| - (void)testThatResponseSerializerIsAFHTTPResponseSerializerAndResponseBodyIsNotText { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| NSURL *baseURL = [NSURL URLWithString:@"https://httpbin.org"]; | ||
| AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:baseURL]; | ||
| manager.responseSerializer = [AFJSONResponseSerializer serializer]; | ||
| AFNetworkActivityTestLogger *testLogger = [AFNetworkActivityTestLogger new]; | ||
|
|
||
| XCTestExpectation *expectation = [self expectationWithDescription:@"Finish Block Should Be Called"]; | ||
| [testLogger setFinishBlock:^(NSURLSessionTask *task, id responseObject, NSTimeInterval elpasedTime, NSError *error) { | ||
| [expectation fulfill]; | ||
| }]; | ||
| [self.logger addLogger:testLogger]; | ||
| [self.logger setLogLevel:AFLoggerLevelDebug]; | ||
| [self.logger startLogging]; | ||
|
|
||
| [manager | ||
| GET:@"image/jpeg" | ||
| parameters:nil | ||
| progress:nil | ||
| success:nil | ||
| failure:nil]; | ||
| [self waitForExpectationsWithTimeout:10.0 handler:nil]; | ||
| [manager invalidateSessionCancelingTasks:YES]; | ||
| } | ||
|
|
||
| @end | ||
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