mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-18 10:32:43 +00:00
Avoid crashing if we get an invalid status code back from GFE
This commit is contained in:
parent
e7aeeb8bd5
commit
2be2c95212
@ -186,11 +186,22 @@ public class NvHTTP {
|
||||
}
|
||||
|
||||
private static void verifyResponseStatus(XmlPullParser xpp) throws GfeHttpResponseException {
|
||||
int statusCode = Integer.parseInt(xpp.getAttributeValue(XmlPullParser.NO_NAMESPACE, "status_code"));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public String getServerInfo() throws IOException, XmlPullParserException {
|
||||
String resp;
|
||||
|
Loading…
x
Reference in New Issue
Block a user