/** * Get the response status as {@link HttpStatus} * @return the response HttpStatus * @throws InvalidHttpMessageException If the status code of the message does not corresponds to any of the * {@link HttpStatus} values */ default HttpStatus getStatus() { return HttpStatus.of(getStatusCode()) .orElseThrow(() -> new InvalidHttpMessageException("Unknown status code: " + getStatusCode())); }
public void httpResponse() { // tag::httpresponse[] HttpResponse<String> message = getResponseMessage(); int statusCode = message.getStatusCode(); // <1> HttpStatus status = message.getStatus(); // <2> // end::httpresponse[] }