Uh oh!
There was an error while loading. Please reload this page.
iOS: Support HTTP headers for source prop on <Image> components - #7338
iOS: Support HTTP headers for source prop on <Image> components#7338rigdern wants to merge 1 commit into
Conversation
facebook-github-bot
commented
May 2, 2016
By analyzing the blame information on this pull request, we identified @nicklockwood and @ide to be potential reviewers. |
There was a problem hiding this comment.
no-trailing-spaces: Trailing spaces not allowed.
796939f to
426ad27Compareghost
commented
May 2, 2016
@rigdern updated the pull request. |
426ad27 to
fed4637Compareghost
commented
May 2, 2016
@rigdern updated the pull request. |
1 similar comment
ghost
commented
May 4, 2016
@rigdern updated the pull request. |
1eb2054 to
32d7c77Comparefacebook-github-bot
commented
May 18, 2016
@rigdern updated the pull request. |
32d7c77 to
677ee37Compareghost
commented
May 26, 2016
@rigdern updated the pull request. |
ide
commented
May 26, 2016
@rigdern You're awesome for submitting both Android and iOS implementations that both look good at a glance. Would like to get more reviewers on the code, but this PR looks promising. |
nicklockwood
commented
May 26, 2016
@rigdern This is a good idea, but changing these iOS APIs will break quite a lot of our stuff internally. I think the better approach here would be to add a new method to RCTImageLoader that takes an NSURLRequest, which we already have an RCTConvert method for processing in a standard format (it's already used by WebView.source). Validating that the headers are all strings should also be done inside RCTConvert (though it isn't currently). The existing methods of RCTImageLoader can then be refactored to call the new method, so we don't break anything, and we can deprecate the old methods. Also, while I echo @ide's sentiment about building both iOS and Android implementations, it's much easier for us to merge if it's split into separate PRs for each platform. |
Allows developers to specify headers to include in the HTTP request
when fetching a remote image. For example, one might leverage this
when fetching an image from an endpoint that requires authentication:
```
<Image
style={styles.logo}
source={{
uri: 'http://facebook.github.io/react/img/logo_og.png',
headers: {
Authorization: 'someAuthToken'
}
}}
/>
```
Note that the header values must be strings.
When doing image requests, this also gives developers control over the
other properties supported by [RCTConvert NSURLRequest:] like `method`
and `body`.
This change deprecates some APIs on RCTImageLoader in order to replace
them with more flexible APIs which take an NSURLRequest rather than just
an NSURL.677ee37 to
ca1f5a7Compareghost
commented
May 27, 2016
@rigdern updated the pull request. |
rigdern
commented
May 27, 2016
@nicklockwood As you suggested, I created several new RCTImageLoader methods which accept an NSURLRequest and deprecated the old ones which accepted an NSURL. I also removed the Android implementation of the feature and will submit it in a separate PR. |
rigdern
commented
May 27, 2016
Android PR is #7791 |
nicklockwood
commented
Jun 1, 2016
@facebook-github-bot import |
Summary:
Allows developers to specify headers to include in the HTTP request
when fetching a remote image. For example, one might leverage this
when fetching an image from an endpoint that requires authentication:
```
<Image
style={styles.logo}
source={{
uri: 'http://facebook.github.io/react/img/logo_og.png',
headers: {
Authorization: 'someAuthToken'
}
}}
/>
```
Note that the header values must be strings.
Works on iOS and Android.
**Test plan (required)**
- Ran a small example like the one above on iOS and Android and ensured the headers were sent to the server.
- Ran a small example to ensure that \<Image\> components without headers still work.
- Currently using this code in our app.
Adam Comella
Microsoft Corp.
Closesreact/react-native#7338
Reviewed By: javache
Differential Revision: D3371458
Pulled By: nicklockwood
fbshipit-source-id: cdb24fe2572c3ae3ba82c86ad383af6d85157e20@rigdern - Did this PR get accepted and, if so, which version of RN did it first appear in? EDIT -- nevermind... I see it was accepted. |
bitfused
commented
Aug 31, 2016
Are there any working examples? This is not working for me and I am not sure how to debug this.. |
rgoldiez
commented
Aug 31, 2016
@IlyaRepo You want to do something like this, which is working for me |
Summary: Hi there, As ospfranco found there is some documentation for the code coming from #7338 missing, so I added it. It concerns the method, headers and bdoy field on the Image source object. If you would like to have any changes made, please don't hesitate to comment, I will add them. Have a nice day and thank you for maintaining React Native! Closes#9304 Differential Revision: D4913262 Pulled By: javache fbshipit-source-id: 922430ec3388560686e1cf53cb5dff7f30e4e31f
Summary: Hi there, As ospfranco found there is some documentation for the code coming from react#7338 missing, so I added it. It concerns the method, headers and bdoy field on the Image source object. If you would like to have any changes made, please don't hesitate to comment, I will add them. Have a nice day and thank you for maintaining React Native! Closesreact#9304 Differential Revision: D4913262 Pulled By: javache fbshipit-source-id: 922430ec3388560686e1cf53cb5dff7f30e4e31f
xahon
commented
Aug 31, 2017
Headers not working on ios, android works well |
Summary:
Allows developers to specify headers to include in the HTTP request
when fetching a remote image. For example, one might leverage this
when fetching an image from an endpoint that requires authentication:
```
<Image
style={styles.logo}
source={{
uri: 'http://facebook.github.io/react/img/logo_og.png',
headers: {
Authorization: 'someAuthToken'
}
}}
/>
```
Note that the header values must be strings.
Works on iOS and Android.
**Test plan (required)**
- Ran a small example like the one above on iOS and Android and ensured the headers were sent to the server.
- Ran a small example to ensure that \<Image\> components without headers still work.
- Currently using this code in our app.
Adam Comella
Microsoft Corp.
Closesreact/react-native#7338
Reviewed By: javache
Differential Revision: D3371458
Pulled By: nicklockwood
fbshipit-source-id: cdb24fe2572c3ae3ba82c86ad383af6d85157e20Summary:
Allows developers to specify headers to include in the HTTP request
when fetching a remote image. For example, one might leverage this
when fetching an image from an endpoint that requires authentication:
```
<Image
style={styles.logo}
source={{
uri: 'http://facebook.github.io/react/img/logo_og.png',
headers: {
Authorization: 'someAuthToken'
}
}}
/>
```
Note that the header values must be strings.
Works on iOS and Android.
**Test plan (required)**
- Ran a small example like the one above on iOS and Android and ensured the headers were sent to the server.
- Ran a small example to ensure that \<Image\> components without headers still work.
- Currently using this code in our app.
Adam Comella
Microsoft Corp.
Closesreact/react-native#7338
Reviewed By: javache
Differential Revision: D3371458
Pulled By: nicklockwood
fbshipit-source-id: cdb24fe2572c3ae3ba82c86ad383af6d85157e20
Allows developers to specify headers to include in the HTTP request
when fetching a remote image. For example, one might leverage this
when fetching an image from an endpoint that requires authentication:
Note that the header values must be strings.
Works on iOS and Android.
Test plan (required)
Adam Comella
Microsoft Corp.