/** * Sends a request and optionally reads a response. Returns true if the request was successfully * executed, and false if the request can be retried. Throws an exception if the request failed * permanently. */ private boolean execute(boolean readResponse) throws IOException { try { httpEngine.sendRequest(); if (readResponse) { httpEngine.readResponse(); } return true; } catch (IOException e) { if (handleFailure(e)) { return false; } else { throw e; } } }