Handle when server doesn't send the expected response
This commit is contained in:
@@ -75,6 +75,7 @@ import org.xml.sax.SAXException;
|
||||
import com.sheepit.client.Configuration.ComputeType;
|
||||
import com.sheepit.client.Error.ServerCode;
|
||||
import com.sheepit.client.exception.FermeException;
|
||||
import com.sheepit.client.exception.FermeExceptionBadResponseFromServer;
|
||||
import com.sheepit.client.exception.FermeExceptionNoRightToRender;
|
||||
import com.sheepit.client.exception.FermeExceptionNoSession;
|
||||
import com.sheepit.client.exception.FermeExceptionNoSpaceLeftOnDevice;
|
||||
@@ -254,6 +255,9 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (r == HttpURLConnection.HTTP_OK && contentType.startsWith("text/html")) {
|
||||
return Error.Type.ERROR_BAD_RESPONSE;
|
||||
}
|
||||
else {
|
||||
this.log.error("Server::getConfiguration: Invalid response " + contentType + " " + r);
|
||||
return Error.Type.WRONG_CONFIGURATION;
|
||||
@@ -443,6 +447,9 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
|
||||
// most likely varnish is up but apache down
|
||||
throw new FermeServerDown();
|
||||
}
|
||||
else if (r == HttpURLConnection.HTTP_OK && contentType.startsWith("text/html")) {
|
||||
throw new FermeExceptionBadResponseFromServer();
|
||||
}
|
||||
InputStream in = connection.getInputStream();
|
||||
String line;
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
|
||||
@@ -732,6 +739,9 @@ public class Server extends Thread implements HostnameVerifier, X509TrustManager
|
||||
}
|
||||
return ServerCode.OK;
|
||||
}
|
||||
else if (r == HttpURLConnection.HTTP_OK && contentType.startsWith("text/html")) {
|
||||
return ServerCode.ERROR_BAD_RESPONSE;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
inStream = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
|
||||
Reference in New Issue
Block a user