use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponse in project netty by netty.
the class CorsHandlerTest method preflightRequestWithConnectionKeepAliveShouldStayOpen.
@Test
public void preflightRequestWithConnectionKeepAliveShouldStayOpen() throws Exception {
final CorsConfig config = forOrigin("http://localhost:8888").build();
final EmbeddedChannel channel = new EmbeddedChannel(new CorsHandler(config));
final FullHttpRequest request = optionsRequest("http://localhost:8888", "", KEEP_ALIVE);
assertThat(channel.writeInbound(request), is(false));
final HttpResponse response = channel.readOutbound();
assertThat(HttpUtil.isKeepAlive(response), is(true));
assertThat(channel.isOpen(), is(true));
assertThat(response.status(), is(OK));
assertThat(ReferenceCountUtil.release(response), is(true));
assertThat(channel.finish(), is(false));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponse in project netty by netty.
the class CorsHandlerTest method simpleRequestAllowPrivateNetwork.
@Test
public void simpleRequestAllowPrivateNetwork() {
final CorsConfig config = forOrigin("http://localhost:8888").allowPrivateNetwork().build();
final EmbeddedChannel channel = new EmbeddedChannel(new CorsHandler(config));
final FullHttpRequest request = optionsRequest("http://localhost:8888", "", null);
request.headers().set(ACCESS_CONTROL_REQUEST_PRIVATE_NETWORK, "true");
assertThat(channel.writeInbound(request), is(false));
final HttpResponse response = channel.readOutbound();
assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_PRIVATE_NETWORK), equalTo("true"));
assertThat(ReferenceCountUtil.release(response), is(true));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponse in project netty by netty.
the class CorsHandlerTest method preflightRequestAllowCredentials.
@Test
public void preflightRequestAllowCredentials() {
final String origin = "null";
final CorsConfig config = forOrigin(origin).allowCredentials().build();
final HttpResponse response = preflightRequest(config, origin, "content-type, xheader1");
assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_CREDENTIALS), is(equalTo("true")));
assertThat(ReferenceCountUtil.release(response), is(true));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponse in project netty by netty.
the class CorsHandlerTest method preflightRequestWithoutConnectionShouldStayOpen.
@Test
public void preflightRequestWithoutConnectionShouldStayOpen() throws Exception {
final CorsConfig config = forOrigin("http://localhost:8888").build();
final EmbeddedChannel channel = new EmbeddedChannel(new CorsHandler(config));
final FullHttpRequest request = optionsRequest("http://localhost:8888", "", null);
assertThat(channel.writeInbound(request), is(false));
final HttpResponse response = channel.readOutbound();
assertThat(HttpUtil.isKeepAlive(response), is(true));
assertThat(channel.isOpen(), is(true));
assertThat(response.status(), is(OK));
assertThat(ReferenceCountUtil.release(response), is(true));
assertThat(channel.finish(), is(false));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponse in project netty by netty.
the class CorsHandlerTest method simpleRequestCustomHeaders.
@Test
public void simpleRequestCustomHeaders() {
final CorsConfig config = forAnyOrigin().exposeHeaders("custom1", "custom2").build();
final HttpResponse response = simpleRequest(config, "http://localhost:7777");
assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_ORIGIN), equalTo("*"));
assertThat(response.headers().get(ACCESS_CONTROL_EXPOSE_HEADERS), containsString("custom1"));
assertThat(response.headers().get(ACCESS_CONTROL_EXPOSE_HEADERS), containsString("custom2"));
assertThat(ReferenceCountUtil.release(response), is(true));
}
Aggregations