Skip to content

Commit

Permalink
Fix iOS Image.getSizeWithHeaders (#29338)
Browse files Browse the repository at this point in the history
Summary:
Fixes #28632

Image.getSizeWithHeaders() was not working as intended on iOS.

## Changelog

[iOS] [Fixed] - Fixed headers in `Image.getSizeWithHeaders`.

Pull Request resolved: #29338

Test Plan:
Used RNTester and an Image URL requiring a Bearer token to test.

Code:
<img width="720" alt="Screen Shot 2020-07-10 at 3 00 58 PM" src="https://user-images.githubusercontent.com/4108718/87189376-850cba00-c2be-11ea-851c-d9fa37d88de4.png">

With Bearer Token:
<img width="456" alt="Screen Shot 2020-07-10 at 3 02 48 PM" src="https://user-images.githubusercontent.com/4108718/87189349-7de5ac00-c2be-11ea-8d82-c74cae6d904b.png">

Without Bearer Token:
<img width="559" alt="Screen Shot 2020-07-10 at 3 04 32 PM" src="https://user-images.githubusercontent.com/4108718/87189458-aff70e00-c2be-11ea-82b7-34a14ec465f1.png">

Reviewed By: cpojer

Differential Revision: D22783037

Pulled By: PeteTheHeat

fbshipit-source-id: 3ad5026e71607c61d42316784844c5295bc1dcae
  • Loading branch information
PaitoAnderson authored and facebook-github-bot committed Jul 28, 2020
1 parent 4b935ae commit 0bcc686
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Libraries/Image/RCTImageLoader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,11 @@ - (void)cancelRequest:(id)requestToken
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)
{
NSURLRequest *request = [RCTConvert NSURLRequest:uri];
NSURL *URL = [RCTConvert NSURL:uri];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
[headers enumerateKeysAndObjectsUsingBlock:^(NSString *key, id value, BOOL *stop) {
[request addValue:[RCTConvert NSString:value] forHTTPHeaderField:key];
}];
[self getImageSizeForURLRequest:request
block:^(NSError *error, CGSize size) {
if (error) {
Expand Down

0 comments on commit 0bcc686

Please sign in to comment.