HttpStatus httpStatus = HttpStatus.resolve(response.getRawStatusCode()); if (httpStatus == null) { throw new UnknownHttpStatusCodeException( response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), null, null);
/** * Determine the HTTP status of the given response. * @param response the response to inspect * @return the associated HTTP status * @throws IOException in case of I/O errors * @throws UnknownHttpStatusCodeException in case of an unknown status code * that cannot be represented with the {@link HttpStatus} enum * @since 4.3.8 * @deprecated as of 5.0, in favor of {@link #handleError(ClientHttpResponse, HttpStatus)} */ @Deprecated protected HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException { HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); if (statusCode == null) { throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } return statusCode; }
/** * Handle the error in the given response with the given resolved status code. * <p>The default implementation throws an {@link HttpClientErrorException} * if the status code is {@link HttpStatus.Series#CLIENT_ERROR}, an * {@link HttpServerErrorException} if it is {@link HttpStatus.Series#SERVER_ERROR}, * and an {@link UnknownHttpStatusCodeException} in other cases. * @since 5.0 * @see HttpClientErrorException#create * @see HttpServerErrorException#create */ protected void handleError(ClientHttpResponse response, HttpStatus statusCode) throws IOException { String statusText = response.getStatusText(); HttpHeaders headers = response.getHeaders(); byte[] body = getResponseBody(response); Charset charset = getCharset(response); switch (statusCode.series()) { case CLIENT_ERROR: throw HttpClientErrorException.create(statusCode, statusText, headers, body, charset); case SERVER_ERROR: throw HttpServerErrorException.create(statusCode, statusText, headers, body, charset); default: throw new UnknownHttpStatusCodeException(statusCode.value(), statusText, headers, body, charset); } }
/** * Delegates to {@link #handleError(ClientHttpResponse, HttpStatus)} with the * response status code. * @throws UnknownHttpStatusCodeException in case of an unresolvable status code * @see #handleError(ClientHttpResponse, HttpStatus) */ @Override public void handleError(ClientHttpResponse response) throws IOException { HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); if (statusCode == null) { throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } handleError(response, statusCode); }
/** * Determine the HTTP status of the given response. * @param response the response to inspect * @return the associated HTTP status * @throws IOException in case of I/O errors * @throws UnknownHttpStatusCodeException in case of an unknown status code * that cannot be represented with the {@link HttpStatus} enum * @since 4.3.8 * @deprecated as of 5.0, in favor of {@link #handleError(ClientHttpResponse, HttpStatus)} */ @Deprecated protected HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException { HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); if (statusCode == null) { throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } return statusCode; }
/** * Handle the error in the given response with the given resolved status code. * <p>The default implementation throws an {@link HttpClientErrorException} * if the status code is {@link HttpStatus.Series#CLIENT_ERROR}, an * {@link HttpServerErrorException} if it is {@link HttpStatus.Series#SERVER_ERROR}, * and an {@link UnknownHttpStatusCodeException} in other cases. * @since 5.0 * @see HttpClientErrorException#create * @see HttpServerErrorException#create */ protected void handleError(ClientHttpResponse response, HttpStatus statusCode) throws IOException { String statusText = response.getStatusText(); HttpHeaders headers = response.getHeaders(); byte[] body = getResponseBody(response); Charset charset = getCharset(response); switch (statusCode.series()) { case CLIENT_ERROR: throw HttpClientErrorException.create(statusCode, statusText, headers, body, charset); case SERVER_ERROR: throw HttpServerErrorException.create(statusCode, statusText, headers, body, charset); default: throw new UnknownHttpStatusCodeException(statusCode.value(), statusText, headers, body, charset); } }
/** * Delegates to {@link #handleError(ClientHttpResponse, HttpStatus)} with the * response status code. * @throws UnknownHttpStatusCodeException in case of an unresolvable status code * @see #handleError(ClientHttpResponse, HttpStatus) */ @Override public void handleError(ClientHttpResponse response) throws IOException { HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); if (statusCode == null) { throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } handleError(response, statusCode); }
private HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException { final HttpStatus statusCode; try { statusCode = response.getStatusCode(); } catch (IllegalArgumentException ex) { throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } return statusCode; }
HttpStatus httpStatus = HttpStatus.resolve(response.getRawStatusCode()); if (httpStatus == null) { throw new UnknownHttpStatusCodeException( response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), null, null);
HttpStatus httpStatus = HttpStatus.resolve(response.getRawStatusCode()); if (httpStatus == null) { throw new UnknownHttpStatusCodeException( response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), null, null);
protected HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException { try { return response.getStatusCode(); } catch (IllegalArgumentException ex) { throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } }
protected HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException { HttpStatus statusCode; try { statusCode = response.getStatusCode(); } catch (IllegalArgumentException ex) { throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } return statusCode; }
@Override public void handleError(ClientHttpResponse response) throws IOException { try { response.getStatusCode(); } catch (IllegalArgumentException ex) { throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } }
/** * Determine the HTTP status of the given response. * @param response the response to inspect * @return the associated HTTP status * @throws IOException in case of I/O errors * @throws UnknownHttpStatusCodeException in case of an unknown status code * that cannot be represented with the {@link HttpStatus} enum * @since 4.3.8 * @deprecated as of 5.0, in favor of {@link #handleError(ClientHttpResponse, HttpStatus)} */ @Deprecated protected HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException { HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); if (statusCode == null) { throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } return statusCode; }
/** * Determine the HTTP status of the given response. * @param response the response to inspect * @return the associated HTTP status * @throws IOException in case of I/O errors * @throws UnknownHttpStatusCodeException in case of an unknown status code * that cannot be represented with the {@link HttpStatus} enum * @since 4.3.8 * @deprecated as of 5.0, in favor of {@link #handleError(ClientHttpResponse, HttpStatus)} */ @Deprecated protected HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException { HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); if (statusCode == null) { throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } return statusCode; }
/** * Handle the error in the given response with the given resolved status code. * <p>The default implementation throws an {@link HttpClientErrorException} * if the status code is {@link HttpStatus.Series#CLIENT_ERROR}, an * {@link HttpServerErrorException} if it is {@link HttpStatus.Series#SERVER_ERROR}, * and an {@link UnknownHttpStatusCodeException} in other cases. * @since 5.0 * @see HttpClientErrorException#create * @see HttpServerErrorException#create */ protected void handleError(ClientHttpResponse response, HttpStatus statusCode) throws IOException { String statusText = response.getStatusText(); HttpHeaders headers = response.getHeaders(); byte[] body = getResponseBody(response); Charset charset = getCharset(response); switch (statusCode.series()) { case CLIENT_ERROR: throw HttpClientErrorException.create(statusCode, statusText, headers, body, charset); case SERVER_ERROR: throw HttpServerErrorException.create(statusCode, statusText, headers, body, charset); default: throw new UnknownHttpStatusCodeException(statusCode.value(), statusText, headers, body, charset); } }
/** * Determine the HTTP status of the given response. * <p>Note: Only called from {@link #handleError}, not from {@link #hasError}. * @param response the response to inspect * @return the associated HTTP status * @throws IOException in case of I/O errors * @throws UnknownHttpStatusCodeException in case of an unknown status code * that cannot be represented with the {@link HttpStatus} enum * @since 4.3.8 */ protected HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException { try { return response.getStatusCode(); } catch (IllegalArgumentException ex) { throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } }
/** * Delegates to {@link #handleError(ClientHttpResponse, HttpStatus)} with the * response status code. * @throws UnknownHttpStatusCodeException in case of an unresolvable status code * @see #handleError(ClientHttpResponse, HttpStatus) */ @Override public void handleError(ClientHttpResponse response) throws IOException { HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); if (statusCode == null) { throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } handleError(response, statusCode); }
/** * Delegates to {@link #handleError(ClientHttpResponse, HttpStatus)} with the * response status code. * @throws UnknownHttpStatusCodeException in case of an unresolvable status code * @see #handleError(ClientHttpResponse, HttpStatus) */ @Override public void handleError(ClientHttpResponse response) throws IOException { HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode()); if (statusCode == null) { throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } handleError(response, statusCode); }
/** * Handle the error in the given response with the given resolved status code. * <p>The default implementation throws an {@link HttpClientErrorException} * if the status code is {@link HttpStatus.Series#CLIENT_ERROR}, an * {@link HttpServerErrorException} if it is {@link HttpStatus.Series#SERVER_ERROR}, * and an {@link UnknownHttpStatusCodeException} in other cases. * @since 5.0 */ protected void handleError(ClientHttpResponse response, HttpStatus statusCode) throws IOException { switch (statusCode.series()) { case CLIENT_ERROR: throw new HttpClientErrorException(statusCode, response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); case SERVER_ERROR: throw new HttpServerErrorException(statusCode, response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); default: throw new UnknownHttpStatusCodeException(statusCode.value(), response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response)); } }