use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project netty by netty.
the class HttpPostMultiPartRequestDecoderTest method testDecodeFullHttpRequestWithInvalidCharset.
@Test
public void testDecodeFullHttpRequestWithInvalidCharset() {
FullHttpRequest req = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/");
req.headers().set(HttpHeaderNames.CONTENT_TYPE, "multipart/form-data; boundary=--89421926422648 [; charset=UTF-8]");
try {
new HttpPostMultipartRequestDecoder(req);
fail("Was expecting an ErrorDataDecoderException");
} catch (HttpPostRequestDecoder.ErrorDataDecoderException expected) {
// expected
} finally {
assertTrue(req.release());
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project netty by netty.
the class HttpPostMultiPartRequestDecoderTest method testDecodeFullHttpRequestWithNoContentTypeHeader.
@Test
public void testDecodeFullHttpRequestWithNoContentTypeHeader() {
FullHttpRequest req = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/");
try {
new HttpPostMultipartRequestDecoder(req);
fail("Was expecting an ErrorDataDecoderException");
} catch (HttpPostRequestDecoder.ErrorDataDecoderException expected) {
// expected
} finally {
assertTrue(req.release());
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest 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.FullHttpRequest 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.FullHttpRequest in project netty by netty.
the class CorsHandlerTest method optionsRequest.
private static FullHttpRequest optionsRequest(final String origin, final String requestHeaders, final AsciiString connection) {
final FullHttpRequest httpRequest = createHttpRequest(OPTIONS);
httpRequest.headers().set(ORIGIN, origin);
httpRequest.headers().set(ACCESS_CONTROL_REQUEST_METHOD, httpRequest.method().toString());
httpRequest.headers().set(ACCESS_CONTROL_REQUEST_HEADERS, requestHeaders);
if (connection != null) {
httpRequest.headers().set(CONNECTION, connection);
}
return httpRequest;
}
Aggregations