)
);
}
else if (401 == statusCode || 0 == statusCode)
{
resultCallback.onFailure(new DispatchError("Authentication required.", statusCode));
}
else if (403 == statusCode)
{
resultCallback.onFailure(new DispatchError("Authentication required.", statusCode));
}
else if (307 == statusCode)
{
String location = response.getHeader("Location");
Log.error("Redirect '" + location + "'. Could not execute " + operation.toString());
redirect(location);
}
else if (503 == statusCode)
{
resultCallback.onFailure(
new DispatchError("Service temporarily unavailable. Is the server is still booting?", statusCode));
}
else
{
StringBuilder sb = new StringBuilder();
sb.append("Unexpected HTTP response").append(": ").append(statusCode);
sb.append("\n\n");
sb.append("Request\n");
sb.append(operation.toString());
sb.append("\n\nResponse\n\n");
sb.append(response.getStatusText()).append("\n");
String payload = response.getText().equals("") ? "No details" :
ModelNode.fromBase64(response.getText()).toString();
sb.append(payload);
resultCallback.onFailure(new DispatchError(sb.toString(), statusCode));
}
trace(Type.END, id, operation);
}
@Override