mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-22 12:33:02 +00:00
Fix parsing rare GFE status code of 0xFFFFFFFF
This commit is contained in:
parent
c30c54d562
commit
20dc351f4c
@ -186,20 +186,13 @@ public class NvHTTP {
|
||||
}
|
||||
|
||||
private static void verifyResponseStatus(XmlPullParser xpp) throws GfeHttpResponseException {
|
||||
String statusCodeText = xpp.getAttributeValue(XmlPullParser.NO_NAMESPACE, "status_code");
|
||||
if (statusCodeText == null) {
|
||||
throw new GfeHttpResponseException(418, "Status code is missing");
|
||||
}
|
||||
try {
|
||||
int statusCode = Integer.parseInt(statusCodeText);
|
||||
if (statusCode != 200) {
|
||||
throw new GfeHttpResponseException(statusCode, xpp.getAttributeValue(XmlPullParser.NO_NAMESPACE, "status_message"));
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// It seems like GFE 3.20.3.63 is returning garbage for status_code in rare cases.
|
||||
// Surface this in a more friendly way rather than crashing.
|
||||
throw new GfeHttpResponseException(418, "Status code is not a number: "+statusCodeText);
|
||||
// We use Long.parseLong() because in rare cases GFE can send back a status code of
|
||||
// 0xFFFFFFFF, which will cause Integer.parseInt() to throw a NumberFormatException due
|
||||
// to exceeding Integer.MAX_VALUE. We'll get the desired error code of -1 by just casting
|
||||
// the resulting long into an int.
|
||||
int statusCode = (int)Long.parseLong(xpp.getAttributeValue(XmlPullParser.NO_NAMESPACE, "status_code"));
|
||||
if (statusCode != 200) {
|
||||
throw new GfeHttpResponseException(statusCode, xpp.getAttributeValue(XmlPullParser.NO_NAMESPACE, "status_message"));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user