/** * Template method called from {@link #hasError(ClientHttpResponse)}. * <p>The default implementation checks {@link HttpStatus#isError()}. * Can be overridden in subclasses. * @param statusCode the HTTP status code as enum value * @return {@code true} if the response indicates an error; {@code false} otherwise * @see HttpStatus#isError() */ protected boolean hasError(HttpStatus statusCode) { return statusCode.isError(); }
/** * Template method called from {@link #hasError(ClientHttpResponse)}. * <p>The default implementation checks {@link HttpStatus#isError()}. * Can be overridden in subclasses. * @param statusCode the HTTP status code as enum value * @return {@code true} if the response indicates an error; {@code false} otherwise * @see HttpStatus#isError() */ protected boolean hasError(HttpStatus statusCode) { return statusCode.isError(); }
private String buildResultString(HttpStatus status) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(status.value()); if (status.isError() && isNotBlank(status.getReasonPhrase())) { stringBuilder.append(": "); stringBuilder.append(status.getReasonPhrase()); } return stringBuilder.toString(); }
private ElasticsearchHost updateNodeState(Tuple2<InetSocketAddress, ClientResponse> tuple2) { State state = tuple2.getT2().statusCode().isError() ? State.OFFLINE : State.ONLINE; ElasticsearchHost elasticsearchHost = new ElasticsearchHost(tuple2.getT1(), state); hosts.put(tuple2.getT1(), elasticsearchHost); return elasticsearchHost; }
@Override public Mono<ClusterInformation> clusterInfo() { return createWebClient(endpoint) // .head().uri("/").exchange() // .flatMap(it -> { if (it.statusCode().isError()) { state = ElasticsearchHost.offline(endpoint); } else { state = ElasticsearchHost.online(endpoint); } return Mono.just(state); }).onErrorResume(throwable -> { state = ElasticsearchHost.offline(endpoint); clientProvider.getErrorListener().accept(throwable); return Mono.just(state); }) // .flatMap(it -> Mono.just(new ClusterInformation(Collections.singleton(it)))); }
private void mockResponseStatus(HttpStatus responseStatus) throws Exception { given(request.execute()).willReturn(response); given(errorHandler.hasError(response)).willReturn(responseStatus.isError()); given(response.getStatusCode()).willReturn(responseStatus); given(response.getRawStatusCode()).willReturn(responseStatus.value()); given(response.getStatusText()).willReturn(responseStatus.getReasonPhrase()); }
/** * Template method called from {@link #hasError(ClientHttpResponse)}. * <p>The default implementation checks {@link HttpStatus#isError()}. * Can be overridden in subclasses. * @param statusCode the HTTP status code as enum value * @return {@code true} if the response indicates an error; {@code false} otherwise * @see HttpStatus#isError() */ protected boolean hasError(HttpStatus statusCode) { return statusCode.isError(); }
/** * Template method called from {@link #hasError(ClientHttpResponse)}. * <p>The default implementation checks {@link HttpStatus#isError()}. * Can be overridden in subclasses. * @param statusCode the HTTP status code as enum value * @return {@code true} if the response indicates an error; {@code false} otherwise * @see HttpStatus#isError() */ protected boolean hasError(HttpStatus statusCode) { return statusCode.isError(); }
@Override public boolean shouldHandle(HttpStatus status) { return status.isError(); }
.flatMap(response -> { HttpStatus httpStatus = response.statusCode(); if (httpStatus.isError()) { return response.body(BodyExtractors.toDataBuffers()) .reduce(DataBuffer::write)
public static Mono<ClientResponse> checkStatus(ClientResponse response) { return checkStatus(response, httpStatus -> !httpStatus.isError()); }
@Override public boolean isAvailable(final SamlRegisteredService service) { if (supports(service)) { val status = HttpRequestUtils.pingUrl(service.getMetadataLocation()); return !status.isError(); } return false; } }
@Override public boolean isAvailable(final SamlRegisteredService service) { if (supports(service)) { val status = HttpRequestUtils.pingUrl(service.getMetadataLocation()); return !status.isError(); } return false; } }