private T convertStreamToStringAndParse(HttpResponse response) { String from = null; try { from = new String(closeClientButKeepContentStream(response)); validateXml(from); return doParse(new InputSource(new StringReader(from))); } catch (Exception e) { return addDetailsAndPropagate(response, e, from); } }
private T convertStreamToStringAndParse(HttpResponse response) { String from = null; try { from = new String(closeClientButKeepContentStream(response)); validateXml(from); return doParse(new InputSource(new StringReader(from))); } catch (Exception e) { return addDetailsAndPropagate(response, e, from); } }
private T convertStreamToStringAndParse(HttpResponse response) { String from = null; try { byte[] fromBytes = closeClientButKeepContentStream(response); from = new String(fromBytes); validateXml(from); // Use InputStream to skip over byte order mark. return doParse(new InputSource(new ByteArrayInputStream(fromBytes))); } catch (Exception e) { return addDetailsAndPropagate(response, e, from); } }
private T convertStreamToStringAndParse(HttpResponse response) { String from = null; try { from = new String(closeClientButKeepContentStream(response)); validateXml(from); return doParse(new InputSource(new StringReader(from))); } catch (Exception e) { return addDetailsAndPropagate(response, e, from); } }
private T convertStreamToStringAndParse(HttpResponse response) { String from = null; try { byte[] fromBytes = closeClientButKeepContentStream(response); from = new String(fromBytes); validateXml(from); // Use InputStream to skip over byte order mark. return doParse(new InputSource(new ByteArrayInputStream(fromBytes))); } catch (Exception e) { return addDetailsAndPropagate(response, e, from); } }
private T convertStreamToStringAndParse(HttpResponse response) { String from = null; try { byte[] fromBytes = closeClientButKeepContentStream(response); from = new String(fromBytes); validateXml(from); // Use InputStream to skip over byte order mark. return doParse(new InputSource(new ByteArrayInputStream(fromBytes))); } catch (Exception e) { return addDetailsAndPropagate(response, e, from); } }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() == 400 || response.getStatusCode() == 403 || response.getStatusCode() == 409) { // Content can be null in the case of HEAD requests if (response.getPayload() != null) { closeClientButKeepContentStream(response); AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response); if (error != null) { return shouldRetryRequestOnError(command, response, error); } } } return false; }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() == 400 || response.getStatusCode() == 403 || response.getStatusCode() == 409) { // Content can be null in the case of HEAD requests if (response.getPayload() != null) { closeClientButKeepContentStream(response); AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response); if (error != null) { return shouldRetryRequestOnError(command, response, error); } } } return false; }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() == 400 || response.getStatusCode() == 403 || response.getStatusCode() == 409) { // Content can be null in the case of HEAD requests if (response.getPayload() != null) { closeClientButKeepContentStream(response); AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response); if (error != null) { return shouldRetryRequestOnError(command, response, error); } } } return false; }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() == 400 || response.getStatusCode() == 403 || response.getStatusCode() == 409) { // Content can be null in the case of HEAD requests if (response.getPayload() != null) { closeClientButKeepContentStream(response); AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response); if (error != null) { return shouldRetryRequestOnError(command, response, error); } } } return false; }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() == 400 || response.getStatusCode() == 403 || response.getStatusCode() == 409) { // Content can be null in the case of HEAD requests if (response.getPayload() != null) { closeClientButKeepContentStream(response); AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response); if (error != null) { return shouldRetryRequestOnError(command, response, error); } } } return false; }
@Override public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (response.getStatusCode() == 400 || response.getStatusCode() == 403 || response.getStatusCode() == 409) { // Content can be null in the case of HEAD requests if (response.getPayload() != null) { closeClientButKeepContentStream(response); AWSError error = utils.parseAWSErrorFromContent(command.getCurrentRequest(), response); if (error != null) { return shouldRetryRequestOnError(command, response, error); } } } return false; }
@Override protected HttpResponse invoke(HttpURLConnection connection) throws IOException, InterruptedException { HttpResponse response = super.invoke(connection); byte[] data = closeClientButKeepContentStream(response); if (data != null && !new String(data).contains("<responseStatus>SUCCESS</responseStatus>")) { response = response.toBuilder().statusCode(500).build(); } return response; } }
@Override protected HttpResponse invoke(HttpURLConnection connection) throws IOException, InterruptedException { HttpResponse response = super.invoke(connection); byte[] data = closeClientButKeepContentStream(response); if (data != null && !new String(data).contains("<responseStatus>SUCCESS</responseStatus>")) { response = response.toBuilder().statusCode(500).build(); } return response; } }
public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (command.getFailureCount() > retryCountLimit) return false; if (response.getStatusCode() == 400 && command.getCurrentRequest().getMethod().equals("PUT") && command.getCurrentRequest().getEndpoint().getPath().indexOf("sandboxes") != -1) { if (response.getPayload() != null) { String error = new String(closeClientButKeepContentStream(response)); if (error != null && error.indexOf("was not uploaded") != -1) { return backoffLimitedRetryHandler.shouldRetryRequest(command, response); } } } return false; }
public boolean shouldRetryRequest(HttpCommand command, HttpResponse response) { if (command.getFailureCount() > retryCountLimit) return false; if (response.getStatusCode() == 400 && command.getCurrentRequest().getMethod().equals("PUT") && command.getCurrentRequest().getEndpoint().getPath().indexOf("sandboxes") != -1) { if (response.getPayload() != null) { String error = new String(closeClientButKeepContentStream(response)); if (error != null && error.indexOf("was not uploaded") != -1) { return backoffLimitedRetryHandler.shouldRetryRequest(command, response); } } } return false; }
@Override public Void answer() throws Throwable { // This error handler will close the original stream and buffer it into memory HttpResponse response = (HttpResponse) getCurrentArguments()[1]; closeClientButKeepContentStream(response); return null; } });
@Override public void handleError(HttpCommand command, HttpResponse response) { Exception exception = new HttpResponseException(command, response); try { if (response.getPayload() != null) { AWSError error = factory.create(handlers.get()) .parse(new String(closeClientButKeepContentStream(response))); exception = refineException(new AWSResponseException(command, response, error)); } } finally { releasePayload(response); command.setException(exception); } }
@Override public void handleError(HttpCommand command, HttpResponse response) { Exception exception = new HttpResponseException(command, response); try { if (response.getPayload() != null) { AWSError error = factory.create(handlers.get()) .parse(new String(closeClientButKeepContentStream(response))); exception = refineException(new AWSResponseException(command, response, error)); } } finally { releasePayload(response); command.setException(exception); } }
@Override public void handleError(HttpCommand command, HttpResponse response) { Exception exception = new HttpResponseException(command, response); try { if (response.getPayload() != null) { AWSError error = factory.create(handlers.get()) .parse(new String(closeClientButKeepContentStream(response))); exception = refineException(new AWSResponseException(command, response, error)); } } finally { releasePayload(response); command.setException(exception); } }