use of cn.taketoday.http.HttpStatus in project today-infrastructure by TAKETODAY.
the class ErrorHandlerIntegrationTests method emptyPathSegments.
@ParameterizedHttpServerTest
// SPR-15560
void emptyPathSegments(HttpServer httpServer) throws Exception {
startServer(httpServer);
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
URI url = new URI("http://localhost:" + port + "//");
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
// Jetty 10+ rejects empty path segments, see https://github.com/eclipse/jetty.project/issues/6302,
// but an application can apply CompactPathRule via RewriteHandler:
// https://www.eclipse.org/jetty/documentation/jetty-11/programming_guide.php
HttpStatus expectedStatus = (httpServer instanceof JettyHttpServer ? HttpStatus.BAD_REQUEST : HttpStatus.OK);
assertThat(response.getStatusCode()).isEqualTo(expectedStatus);
}
use of cn.taketoday.http.HttpStatus in project today-framework by TAKETODAY.
the class ErrorResponseException method getMessage.
@Override
public String getMessage() {
HttpStatus httpStatus = HttpStatus.resolve(this.status);
String message = (httpStatus != null ? httpStatus : String.valueOf(this.status)) + (!this.headers.isEmpty() ? ", headers=" + this.headers : "") + ", " + this.body;
return ExceptionUtils.buildMessage(message, getCause());
}
use of cn.taketoday.http.HttpStatus in project today-framework by TAKETODAY.
the class DefaultClientResponseTests method statusCode.
@Test
public void statusCode() {
HttpStatus status = HttpStatus.CONTINUE;
given(mockResponse.getStatusCode()).willReturn(status);
assertThat(defaultClientResponse.statusCode()).isEqualTo(status);
}
use of cn.taketoday.http.HttpStatus in project today-framework by TAKETODAY.
the class ClientResponseWrapperTests method statusCode.
@Test
public void statusCode() {
HttpStatus status = HttpStatus.BAD_REQUEST;
given(mockResponse.statusCode()).willReturn(status);
assertThat(wrapper.statusCode()).isSameAs(status);
}
use of cn.taketoday.http.HttpStatus in project today-framework by TAKETODAY.
the class ErrorHandlerIntegrationTests method emptyPathSegments.
@ParameterizedHttpServerTest
// SPR-15560
void emptyPathSegments(HttpServer httpServer) throws Exception {
startServer(httpServer);
RestTemplate restTemplate = new RestTemplate();
restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER);
URI url = new URI("http://localhost:" + port + "//");
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
// Jetty 10+ rejects empty path segments, see https://github.com/eclipse/jetty.project/issues/6302,
// but an application can apply CompactPathRule via RewriteHandler:
// https://www.eclipse.org/jetty/documentation/jetty-11/programming_guide.php
HttpStatus expectedStatus = (httpServer instanceof JettyHttpServer ? HttpStatus.BAD_REQUEST : HttpStatus.OK);
assertThat(response.getStatusCode()).isEqualTo(expectedStatus);
}
Aggregations