@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; } }
/** * synchronized to prevent multiple callers from overlapping requests on the same session */ @Override protected synchronized HttpResponse invoke(HttpURLConnection connection) throws IOException, InterruptedException { HttpResponse response = super.invoke(connection); if (response.getStatusCode() == 200) { byte[] data = closeClientButKeepContentStream(response); String message = data != null ? new String(data, "UTF-8") : null; if (message != null && !message.startsWith("{\"status\": \"success\"")) { response = response.toBuilder().statusCode(400).build(); } } return response; } }
/** * synchronized to prevent multiple callers from overlapping requests on the same session */ @Override protected synchronized HttpResponse invoke(HttpURLConnection connection) throws IOException, InterruptedException { HttpResponse response = super.invoke(connection); if (response.getStatusCode() == 200) { byte[] data = closeClientButKeepContentStream(response); String message = data != null ? new String(data, Charsets.UTF_8) : null; if (message != null && !message.startsWith("{\"status\": \"success\"")) { response = response.toBuilder().statusCode(400).build(); } } return response; } }
/** * synchronized to prevent multiple callers from overlapping requests on the same session */ @Override protected synchronized HttpResponse invoke(HttpURLConnection connection) throws IOException, InterruptedException { HttpResponse response = super.invoke(connection); if (response.getStatusCode() == 200) { byte[] data = closeClientButKeepContentStream(response); String message = data != null ? new String(data, Charsets.UTF_8) : null; if (message != null && !message.startsWith("{\"status\": \"success\"")) { response = response.toBuilder().statusCode(400).build(); } } return response; } }
/** * synchronized to prevent multiple callers from overlapping requests on the same session */ @Override protected synchronized HttpResponse invoke(HttpURLConnection connection) throws IOException, InterruptedException { HttpResponse response = super.invoke(connection); if (response.getStatusCode() == 200) { byte[] data = closeClientButKeepContentStream(response); String message = data != null ? new String(data, "UTF-8") : null; if (message != null && !message.startsWith("{\"status\": \"success\"")) { response = response.toBuilder().statusCode(400).build(); } } return response; } }
/** * synchronized to prevent multiple callers from overlapping requests on the same session */ @Override protected synchronized HttpResponse invoke(HttpURLConnection connection) throws IOException, InterruptedException { HttpResponse response = super.invoke(connection); if (response.getStatusCode() == 200) { byte[] data = closeClientButKeepContentStream(response); String message = data != null ? new String(data, Charsets.UTF_8) : null; if (message != null && !message.startsWith("{\"status\": \"success\"")) { response = response.toBuilder().statusCode(400).build(); } } return response; } }
public void handleError(HttpCommand command, HttpResponse response) { Exception exception = null; try { byte[] data = closeClientButKeepContentStream(response); String message = data != null ? new String(data, "UTF-8") : null; if (message != null) { Matcher ms = ERROR_STATUS_PATTERN.matcher(message); Matcher mm = ERROR_MESSAGE_PATTERN.matcher(message); if (ms.find() && mm.find()) { String status = ms.group(1); String errorMessage = mm.group(1); // revert status code to 200 to match actual server's return status response = response.toBuilder().statusCode(200).build(); exception = refineException(new HttpResponseException(command, response, status + ": " + errorMessage)); } } } catch (UnsupportedEncodingException e) { // should never happen as UTF-8 is always supported } finally { if (exception == null) { exception = new HttpResponseException(command, response); } command.setException(exception); releasePayload(response); } }
public void handleError(HttpCommand command, HttpResponse response) { Exception exception = null; try { byte[] data = closeClientButKeepContentStream(response); String message = data != null ? new String(data, "UTF-8") : null; if (message != null) { Matcher ms = ERROR_STATUS_PATTERN.matcher(message); Matcher mm = ERROR_MESSAGE_PATTERN.matcher(message); if (ms.find() && mm.find()) { String status = ms.group(1); String errorMessage = mm.group(1); // revert status code to 200 to match actual server's return status response = response.toBuilder().statusCode(200).build(); exception = refineException(new HttpResponseException(command, response, status + ": " + errorMessage)); } } } catch (UnsupportedEncodingException e) { // should never happen as UTF-8 is always supported } finally { if (exception == null) { exception = new HttpResponseException(command, response); } command.setException(exception); releasePayload(response); } }
@Override protected HttpResponse invoke(HttpURLConnection connection) throws IOException, InterruptedException { HttpResponse originalResponse = super.invoke(connection); HttpResponse.Builder<?> responseBuilder = originalResponse.toBuilder();
@Override protected HttpResponse invoke(HttpURLConnection connection) throws IOException, InterruptedException { HttpResponse originalResponse = super.invoke(connection); HttpResponse.Builder<?> responseBuilder = originalResponse.toBuilder();