-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add handling for image returned with 404 http response (fixes #399) #396
Merged
garrettmoon
merged 6 commits into
pinterest:master
from
wsdwsd0829:handleImageDataIn404
Aug 24, 2017
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
539137c
add handling for image returned with 404 http response
wsdwsd0829 63843fb
add handling for image returned with 404 http response (refactor)
wsdwsd0829 cb3929a
add test case and refactor (#399)
wsdwsd0829 d3c5691
refactor per review
wsdwsd0829 f3a81e0
add comment per request
wsdwsd0829 e82cecf
add to change log
wsdwsd0829 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
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 |
---|---|---|
|
@@ -188,6 +188,14 @@ - (NSURL *)progressiveURL | |
return bigURLs; | ||
} | ||
|
||
- (NSURL *)imageFrom404URL | ||
{ | ||
NSString *base64EncodedUrl = @"aHR0cHM6Ly9pLnl0aW1nLmNvbS92aS9PRzlRbW9jNGVZcy9tcWRlZmF1bHQuanBn"; | ||
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. cough |
||
NSData *nsdataFromBase64String = [[NSData alloc] initWithBase64EncodedString:base64EncodedUrl options:0]; | ||
NSString *base64Decoded = [[NSString alloc] initWithData:nsdataFromBase64String encoding:NSUTF8StringEncoding]; | ||
return [[NSURL alloc] initWithString:base64Decoded]; | ||
} | ||
|
||
#pragma mark - <PINURLSessionManagerDelegate> | ||
|
||
- (void)didReceiveData:(NSData *)data forTask:(NSURLSessionTask *)task | ||
|
@@ -390,6 +398,20 @@ - (void)testBase64 | |
[self waitForExpectationsWithTimeout:[self timeoutTimeInterval] handler:nil]; | ||
} | ||
|
||
- (void)testHTTPResponse404WithData | ||
{ | ||
XCTestExpectation *expectation = [self expectationWithDescription:@"image from 404 response should set correctly"]; | ||
PINRemoteImageManager *manager = [[PINRemoteImageManager alloc] init]; | ||
NSURL *url = [self imageFrom404URL]; | ||
[manager downloadImageWithURL:url completion:^(PINRemoteImageManagerResult * _Nonnull result) { | ||
XCTAssertNotNil(result.image); | ||
[expectation fulfill]; | ||
}]; | ||
[self waitForExpectationsWithTimeout:[self timeoutTimeInterval] handler:^(NSError * _Nullable error) { | ||
XCTAssertNil(error); | ||
}]; | ||
} | ||
|
||
- (void)testErrorOnNilURLDownload | ||
{ | ||
#pragma clang diagnostic push | ||
|
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.
Do you mind adding a comment that says something along the lines of:
"If a 404 response contains an image, we treat it as a successful request and return the image"
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.
added & thanks for approval.