Skip to content
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

Report error code contained in PlayReady licenser server response body #2180

Conversation

jeffcunat
Copy link
Contributor

@jeffcunat jeffcunat commented Sep 21, 2017

When we get an error response from the PlayReady licenser server, it is a SOAP response.
So we parse the response to look for a Fault tag in the SOAP response and extract a status code, a fault string and a possible message to build the string response of the getErrorResponse function

Moreover the response can also be sent with an HTTP 200 Response code.
So the getLicenseMessage function returns null if a Fault tag is found in the SOAP response and in this case, we call the getErrorResponse function to get the error message

I have added some unit tests for this PR

PlayReady licenser error response returns a string
@@ -497,18 +497,25 @@ function ProtectionController(config) {
return;
}

const reportError = function (xhr, eventData, keySystemString, messageType) {
sendLicenseRequestCompleteEvent(eventData, 'DRM: ' + keySystemString + ' update, XHR complete. status is "' + xhr.statusText + '" (' + xhr.status +
'), readyState is ' + xhr.readyState +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation looks weird

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to write this long line of code into two parts instead

let stringResponse = uintToString(serverResponse);
let parser = new window.DOMParser();
let xmlDoc = parser.parseFromString(stringResponse, 'text/xml');
let enveloppe = xmlDoc ? xmlDoc.getElementsByTagNameNS(soap, 'Envelope')[0] : null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't we too optimistic assuming XML is going to be well-formed and with the right structure? Makes sense checking if the elements we are looking for really exist?

Note: minor thing, there is a typo in name variable (it should be envelope).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thinks it is OK, because if there is no soap:Envelope or anything else, we return the server response not modified.
There is no exception when we parseFromString something that is not xml, we get a xml document with a parserror tag.
The only thing we have to return is null when there is a soap:Fault tag in the server response.
There is a unit test that mocks a playready invalid license (test/unit/streaming.protection.servers.PlayReady.js with /unit/data/licence/playredayInvalidLicence.txt mock response) and it passes...
Have I missed something wrong ?

I have fixed the typo in the variable name 'envelope'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, you are right. It is well managed. Thanks!

@epiclabsDASH epiclabsDASH merged commit 838e606 into Dash-Industry-Forum:development Sep 26, 2017
@nicosang nicosang deleted the reportLicenseServerErrorCode branch September 27, 2017 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants