use of org.xnio.OptionMap in project undertow by undertow-io.
the class LotsOfHeadersRequestTestCase method testLotsOfHeadersInRequest_MaxHeaders_Ok.
@Test
@AjpIgnore
public void testLotsOfHeadersInRequest_MaxHeaders_Ok() throws IOException {
OptionMap existing = DefaultServer.getUndertowOptions();
TestHttpClient client = new TestHttpClient();
try {
HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/path");
for (int i = 0; i < getTestMaxHeaders(); ++i) {
get.addHeader(HEADER + i, MESSAGE + i);
}
DefaultServer.setUndertowOptions(OptionMap.create(UndertowOptions.MAX_HEADERS, TEST_MAX_HEADERS));
HttpResponse result = client.execute(get);
Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
for (int i = 0; i < getTestMaxHeaders(); ++i) {
Header[] header = result.getHeaders(HEADER + i);
Assert.assertEquals(MESSAGE + i, header[0].getValue());
}
} finally {
DefaultServer.setUndertowOptions(existing);
client.getConnectionManager().shutdown();
}
}
use of org.xnio.OptionMap in project undertow by undertow-io.
the class LotsOfHeadersRequestTestCase method testLotsOfHeadersInRequest_MaxHeaders_BadRequest.
@Test
public void testLotsOfHeadersInRequest_MaxHeaders_BadRequest() throws IOException {
OptionMap existing = DefaultServer.getUndertowOptions();
TestHttpClient client = new TestHttpClient();
try {
HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/path");
// add request headers more than MAX_HEADERS
for (int i = 0; i < (getTestMaxHeaders() + 1); ++i) {
get.addHeader(HEADER + i, MESSAGE + i);
}
DefaultServer.setUndertowOptions(OptionMap.create(UndertowOptions.MAX_HEADERS, TEST_MAX_HEADERS));
HttpResponse result = client.execute(get);
Assert.assertEquals(DefaultServer.isH2() ? StatusCodes.SERVICE_UNAVAILABLE : StatusCodes.BAD_REQUEST, result.getStatusLine().getStatusCode());
} finally {
DefaultServer.setUndertowOptions(existing);
client.getConnectionManager().shutdown();
}
}
use of org.xnio.OptionMap in project undertow by undertow-io.
the class QueryParameterUtils method getQueryParamEncoding.
public static String getQueryParamEncoding(HttpServerExchange exchange) {
String encoding = null;
OptionMap undertowOptions = exchange.getConnection().getUndertowOptions();
if (undertowOptions.get(UndertowOptions.DECODE_URL, true)) {
encoding = undertowOptions.get(UndertowOptions.URL_CHARSET, StandardCharsets.UTF_8.name());
}
return encoding;
}
use of org.xnio.OptionMap in project undertow by undertow-io.
the class QueryParametersTestCase method testQueryParametersShiftJIS.
@Test
@ProxyIgnore
public void testQueryParametersShiftJIS() throws IOException {
OptionMap old = DefaultServer.getUndertowOptions();
try {
DefaultServer.setUndertowOptions(OptionMap.create(UndertowOptions.URL_CHARSET, "Shift_JIS"));
TestHttpClient client = new TestHttpClient();
try {
runTest(client, "{unicode=>ใในใ}", "/path?unicode=%83e%83X%83g");
} finally {
client.getConnectionManager().shutdown();
}
} finally {
DefaultServer.setUndertowOptions(old);
}
}
use of org.xnio.OptionMap in project undertow by undertow-io.
the class DefaultServer method startSSLServer.
/**
* Start the SSL server using a custom SSLContext with additional options to pass to the JsseXnioSsl instance.
*
* @param context - The SSLContext to use for JsseXnioSsl initialisation.
* @param options - Additional options to be passed to the JsseXnioSsl, this will be merged with the default options where
* applicable.
*/
public static void startSSLServer(final SSLContext context, final OptionMap options, ChannelListener openListener, int port) throws IOException {
if (isApacheTest()) {
return;
}
OptionMap combined = OptionMap.builder().addAll(serverOptions).addAll(options).set(Options.USE_DIRECT_BUFFERS, true).getMap();
UndertowXnioSsl ssl = new UndertowXnioSsl(worker.getXnio(), OptionMap.EMPTY, SSL_BUFFER_POOL, context);
sslServer = ssl.createSslConnectionServer(worker, new InetSocketAddress(getHostAddress("default"), port), openListener, combined);
sslServer.getAcceptSetter().set(openListener);
sslServer.resumeAccepts();
}
Aggregations