-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Get response url from XMLHttpRequest #4981
Conversation
By analyzing the blame information on this pull request, we identified @nicklockwood, @philikon and @lexs to be potential reviewers. |
if (requestId === this._requestId) { | ||
this.status = status; | ||
this.setResponseHeaders(responseHeaders); | ||
this.setReadyState(this.HEADERS_RECEIVED); | ||
if (responseURL) { |
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.
property responseURL
Property not found in XMLHttpRequestBase
@realaboo updated the pull request. |
1 similar comment
@realaboo updated the pull request. |
cc @mkonicek |
8e5568c
to
bf10b5c
Compare
StyleSheet, | ||
Text, | ||
TextInput, | ||
TouchableHighlight, |
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.
no-unused-vars: "TouchableHighlight" is defined but never used
bf10b5c
to
03688b3
Compare
@realaboo updated the pull request. |
1 similar comment
@realaboo updated the pull request. |
@lexs Does this look OK to you? |
@@ -352,7 +352,7 @@ var self = {}; | |||
var xhr = new XMLHttpRequest() | |||
|
|||
function responseURL() { | |||
if ('responseURL' in xhr) { | |||
if ('responseURL' in xhr && xhr.responseURL) { |
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.
Instead of changing this in fetch.js (which is upstream) could we delete responseURL
if it is null? I'm not 100% sure what this means in this context as I'm guessing it will never be null in our case?
The spec says this:
The responseURL attribute must return the empty string if response's url is null and its serialization with the exclude fragment flag set otherwise.
I'd be ok with just deleting the property if it's null. Seems reasonable?
@realaboo updated the pull request. |
@lexs I've updated the commit. Sorry but I'm new to ES6. I'm not sure if it's OK to declare a class member first and then delete it later somewhere else. Thanks for the review. |
@realaboo That's an interesting question, it's definitely ok JS-wise but Flow might be less happy. Nothing blocking this tho. |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1532998640345120/int_phab to review. |
b659d7f
Summary: An HTTP request may be redirected to another URL, sometimes we need to know the URL where the response comes from. If the server is in control, we can add an HTTP header X-Request-URL for the redirect URL. However there will be cases that 3rd party services are used. This PR retrieves the response URL from native networking module and passes to it XMLHttpRequest. The fetch API built on XMLHttpRequest also benefits from this feature. Closes facebook#4981 Reviewed By: svcscm Differential Revision: D2811392 Pulled By: lexs fb-gh-sync-id: 3ec356fb92f8011b6a243d6879172877a3dc498a
An HTTP request may be redirected to another URL, sometimes we need to know the URL where the response comes from.
If the server is in control, we can add an HTTP header X-Request-URL for the redirect URL. However there will be cases that 3rd party services are used.
This PR retrieves the response URL from native networking module and passes to it XMLHttpRequest. The fetch API built on XMLHttpRequest also benefits from this feature.