This repository has been archived by the owner on Jan 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 201
optimization: when responseSerializer is set a AFHTTPResponseSerializer instance #51
Open
leleliu008
wants to merge
10
commits into
AFNetworking:master
Choose a base branch
from
leleliu008:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ddb7550
optimization: when responseSerializer is set a AFHTTPResponseSerializ…
502c0c7
optimization:when log level is AFLoggerLevelDebug apply the optimizat…
8cd2614
modify testcase: choose a HTTP POST request has HTTP Body cover the c…
1e55cf0
重新实现
ad064d2
修改名称
d0f6999
修改文档
478234f
修改文档
d87a32a
optimization
36788cf
修改文档
1120a96
修改文档
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
GET:@"ip" | ||
parameters:nil | ||
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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