use of cn.taketoday.http.client.ClientHttpResponse in project today-framework by TAKETODAY.
the class AbstractServletWebServerFactoryTests method customServerHeader.
@Test
void customServerHeader() throws Exception {
AbstractServletWebServerFactory factory = getFactory();
factory.setServerHeader("MyServer");
this.webServer = factory.getWebServer(exampleServletRegistration());
this.webServer.start();
ClientHttpResponse response = getClientResponse(getLocalUrl("/hello"));
assertThat(response.getHeaders().getFirst("server")).isEqualTo("MyServer");
}
use of cn.taketoday.http.client.ClientHttpResponse in project today-framework by TAKETODAY.
the class AbstractServletWebServerFactoryTests method cannotReadClassPathFiles.
@Test
void cannotReadClassPathFiles() throws Exception {
AbstractServletWebServerFactory factory = getFactory();
this.webServer = factory.getWebServer(exampleServletRegistration());
this.webServer.start();
ClientHttpResponse response = getClientResponse(getLocalUrl("/cn/taketoday/framework/Application.class"));
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
use of cn.taketoday.http.client.ClientHttpResponse in project today-framework by TAKETODAY.
the class ServletWebServerMvcIntegrationTests method doTest.
private void doTest(AnnotationConfigServletWebServerApplicationContext context, String resourcePath) throws Exception {
SimpleClientHttpRequestFactory clientHttpRequestFactory = new SimpleClientHttpRequestFactory();
ClientHttpRequest request = clientHttpRequestFactory.createRequest(new URI("http://localhost:" + context.getWebServer().getPort() + resourcePath), HttpMethod.GET);
try (ClientHttpResponse response = request.execute()) {
assertThat(response.getBody()).hasContent("Hello World");
}
}
use of cn.taketoday.http.client.ClientHttpResponse in project today-infrastructure by TAKETODAY.
the class AbstractServletWebServerFactoryTests method serverHeaderIsDisabledByDefaultWhenUsingSsl.
@Test
void serverHeaderIsDisabledByDefaultWhenUsingSsl() throws Exception {
AbstractServletWebServerFactory factory = getFactory();
factory.setSsl(getSsl(null, "password", "src/test/resources/test.jks"));
this.webServer = factory.getWebServer(new ServletRegistrationBean<>(new ExampleServlet(true, false), "/hello"));
this.webServer.start();
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
HttpClient httpClient = this.httpClientBuilder.get().setSSLSocketFactory(socketFactory).build();
ClientHttpResponse response = getClientResponse(getLocalUrl("https", "/hello"), HttpMethod.GET, new HttpComponentsClientHttpRequestFactory(httpClient));
assertThat(response.getHeaders().get("Server")).isNullOrEmpty();
}
use of cn.taketoday.http.client.ClientHttpResponse in project today-infrastructure by TAKETODAY.
the class AbstractServletWebServerFactoryTests method cannotReadClassPathFiles.
@Test
void cannotReadClassPathFiles() throws Exception {
AbstractServletWebServerFactory factory = getFactory();
this.webServer = factory.getWebServer(exampleServletRegistration());
this.webServer.start();
ClientHttpResponse response = getClientResponse(getLocalUrl("/cn/taketoday/framework/Application.class"));
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
Aggregations