-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Report error code contained in PlayReady licenser server response body #2180
Conversation
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 + |
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.
Indentation looks weird
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.
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; |
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.
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).
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.
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'
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.
yep, you are right. It is well managed. Thanks!
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