-
Notifications
You must be signed in to change notification settings - Fork 1.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
Add support for 302 redirect #266
Conversation
@@ -168,6 +168,9 @@ shaka.util.FailoverUri.prototype.createRequest_ = | |||
// effectively cache every response. | |||
this.requestPromise_ = null; | |||
this.request_ = null; | |||
if (xhr.responseURL) { | |||
this.urls.unshift(new goog.Uri(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.
What would be better (IMO) than prepending the URL would be to replace the specific URL this request used. (this.urls[i])
Agree - replacing (this.urls[i]) is better - will do that. |
@joeyparrish - Lint/Build passed and I've implemented the replace rather than the unshift. Will read the contrib before committing next time ;) Thanks! |
GitHub is saying you have merge conflicts. Please rebase to the tip of master and manually resolve the merge conflicts. Thanks! |
Conflicts have been resolved -- Thanks |
Testing in progress... |
We are experiencing some flakiness on our buildbot. Please forgive the noise. |
I think it is failing b/c the URLs are formatted in the tests as: So the test is failing as it notices they don't match... I'll look into it. |
Yes, that seems to be the case. Not flake at all. Here's the log snippet:
|
I'm pondering the best way to fix. It looks like we have an expectation that the final MPD location should match the target location: spyOn(window.shaka.dash, 'MpdRequest').and.callFake(function(mpdUrl) {
expect(mpdUrl.toString()).toEqual(targetMpdUrl); I could strip the proto and params and get it to pass the specific test case, but that's not right. Ultimately, this expectation isn't going to pass ever in cases where the player was redirected, so I'll need to come up with a better test to fit. |
Options:
My preference is for 2. |
I was testing my solution last night and noticed that by replacing urls[i], we doom future manifest requests. The proper functionality would be for the relative chunks detailed in the manifest to use the 302 location for the relative baseUrl, however future manifest requests should not. Below is an updated version of flow which encompasses this detail. Example - Proposed Flow I've committed a few more changes that fix the flow. I have not altered the failing test, as I believe these new changes may not trigger it. |
|
||
/** @public {goog.Uri} */ | ||
this.currentUrl = null; | ||
|
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.
Drop this extra line
One last request: can you squash these commits together? It's kind of hard to parse the log with 10 commits, 7 of which have the same message. |
…URL that is seperate from original URL
@joeyparrish - squashed. Thanks much! |
Testing in progress... |
Failure:
|
@rgc Still getting failures. I've edited the buildbot message in this thread to just the failures. (In the mean time, I'm working on getting our buildbot to send the failures only and to format the message correctly. Should be easier to read if we see failures next time.) |
@joeyparrish - I was able to run the tests locally, find the issue and fix it. |
I fixed the spec tests to pass the proper number of arguments to shaka.dash.mpd.parseMpd as well |
@@ -50,8 +51,12 @@ shaka.dash.mpd.parseMpd = function(source, url) { | |||
return null; | |||
} | |||
|
|||
if (!baseUrl) { |
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.
You should drop this condition, since it should not be possible after successful compilation. Otherwise, the PR looks good to me.
@joeyparrish - agreed, done and squashed. |
Looks good! I'll give the buildbot one more crack at it to verify. Thanks for taking the time to do revisions and get everything done cleanly. |
Testing in progress... |
All tests passed! |
Add support for 302 redirect
Thanks very much for the contribution. We will implement something equivalent in Shaka 2 soon to make sure this feature isn't lost in the rewrite. |
Thanks for walking me through the process -- Cheers! |
Add support for responseURL where supported.
XMLHttpRequest spec 4.6.1 adds the responseUrl attribute:
https://xhr.spec.whatwg.org/#the-responseurl-attribute
Browser Support
Chromium: https://code.google.com/p/chromium/issues/detail?id=377583
Webkit: https://bugs.webkit.org/show_bug.cgi?id=136938
Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=998076
A current use case is when the DASH manifest is located at a URL that is redirected via 302 to another location. Currently, the mpdParser will then pull the chunks from the original URI rather than the URl from which the manifest was ultimately downloaded.
Example - Current Flow
http://some.host.org/path/manifest.mpd returns 302 to http://other.host.org/path/manifest.mpd.
Subsequent requests for mp4 chunks will be:
http://some.host.org/path/chunk1.mp4
http://some.host.org/path/chunk2.mp4
If the server has been configured to 302 redirect for everything, this will result in each of the above chunks also having a 302 redirect. If the server hasn't been configured, then they will fail.
Example - Proposed Flow
http://some.host.org/path/manifest.mpd returns 302 to http://other.host.org/path/manifest.mpd.
Subsequent requests for mp4 chunks will be:
http://other.host.org/path/chunk1.mp4
http://other.host.org/path/chunk2.mp4
As the base_url should be the URI from which the manifest was downloaded.
In browsers without responseUrl support, flow will fallback to current.