case "maxInitialLineLength": if (member.getValue() instanceof Number) { obj.setMaxInitialLineLength(((Number)member.getValue()).intValue());
private void testServerMaxInitialLineLength(int maxInitialLength) { String longParam = TestUtils.randomAlphaString(5000); server.close(); server = vertx.createHttpServer(new HttpServerOptions().setMaxInitialLineLength(maxInitialLength) .setHost("localhost").setPort(8080)).requestHandler(req -> { assertEquals(req.getParam("t"), longParam); req.response().end(); }).listen(onSuccess(res -> { HttpClientRequest req = vertx.createHttpClient(new HttpClientOptions()) .request(HttpMethod.GET, 8080, "localhost", "/?t=" + longParam, onSuccess(resp -> { if (maxInitialLength > HttpServerOptions.DEFAULT_MAX_INITIAL_LINE_LENGTH) { assertEquals(200, resp.statusCode()); testComplete(); } else { assertEquals(414, resp.statusCode()); resp.request().connection().closeHandler(v -> { testComplete(); }); } })); req.end(); })); await(); }
case "maxInitialLineLength": if (member.getValue() instanceof Number) { obj.setMaxInitialLineLength(((Number)member.getValue()).intValue());
private void testServerMaxInitialLineLength(int maxInitialLength) { String longParam = TestUtils.randomAlphaString(5000); server.close(); server = vertx.createHttpServer(new HttpServerOptions().setMaxInitialLineLength(maxInitialLength) .setHost("localhost").setPort(8080)).requestHandler(req -> { assertEquals(req.getParam("t"), longParam); req.response().end(); }).listen(onSuccess(res -> { HttpClientRequest req = vertx.createHttpClient(new HttpClientOptions()) .request(HttpMethod.GET, 8080, "localhost", "/?t=" + longParam); req.handler(resp -> { if (maxInitialLength > HttpServerOptions.DEFAULT_MAX_INITIAL_LINE_LENGTH) { assertEquals(200, resp.statusCode()); testComplete(); } else { assertEquals(414, resp.statusCode()); req.connection().closeHandler(v -> { testComplete(); }); } }); req.end(); })); await(); }
private HttpServerOptions createDefaultHttpServerOptions() { HttpServerOptions serverOptions = new HttpServerOptions(); serverOptions.setUsePooledBuffers(true); serverOptions.setIdleTimeout(TransportConfig.getConnectionIdleTimeoutInSeconds()); serverOptions.setCompressionSupported(TransportConfig.getCompressed()); serverOptions.setMaxHeaderSize(TransportConfig.getMaxHeaderSize()); serverOptions.setMaxInitialLineLength(TransportConfig.getMaxInitialLineLength()); if (endpointObject.isHttp2Enabled()) { serverOptions.setUseAlpn(TransportConfig.getUseAlpn()) .setInitialSettings(new Http2Settings().setMaxConcurrentStreams(TransportConfig.getMaxConcurrentStreams())); } if (endpointObject.isSslEnabled()) { SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null); SSLOption sslOption; if (factory == null) { sslOption = SSLOption.buildFromYaml(SSL_KEY); } else { sslOption = factory.createSSLOption(); } SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass()); VertxTLSBuilder.buildNetServerOptions(sslOption, sslCustom, serverOptions); } return serverOptions; } }
public void run() { InternalLoggerFactory.setDefaultFactory(Slf4JLoggerFactory.INSTANCE); Vertx vertx = Vertx.vertx(); HttpClient client = vertx.createHttpClient(new HttpClientOptions() .setMaxInitialLineLength(10000) .setLogActivity(true)); HttpProxy proxy = HttpProxy .reverseProxy(client) .target(8081, "96.126.115.136"); HttpServer proxyServer = vertx.createHttpServer(new HttpServerOptions() .setPort(port) .setMaxInitialLineLength(10000) .setLogActivity(true)) .requestHandler(req -> { System.out.println("------------------------------------------"); System.out.println(req.path()); proxy.handle(req); }); proxyServer.listen(ar -> { if (ar.succeeded()) { System.out.println("Proxy server started on " + port); } else { ar.cause().printStackTrace(); } }); } }
@Test public void testHandleLongInitialLength(TestContext ctx) { proxyOptions.setMaxInitialLineLength(10000); Async latch = ctx.async(); String uri = "/" + randomAlphaString(5999); SocketAddress backend = startHttpBackend(ctx, new HttpServerOptions().setPort(8081).setMaxInitialLineLength(10000), req -> { ctx.assertEquals(uri, req.uri()); req.response().end(); }); startProxy(backend); HttpClient client = vertx.createHttpClient(); client.getNow(8080, "localhost", "" + uri, resp -> { ctx.assertEquals(200, resp.statusCode()); latch.complete(); }); }
private HttpServerOptions createDefaultHttpServerOptions() { HttpServerOptions serverOptions = new HttpServerOptions(); serverOptions.setUsePooledBuffers(true); serverOptions.setIdleTimeout(TransportConfig.getConnectionIdleTimeoutInSeconds()); serverOptions.setCompressionSupported(TransportConfig.getCompressed()); serverOptions.setMaxHeaderSize(TransportConfig.getMaxHeaderSize()); serverOptions.setMaxInitialLineLength(TransportConfig.getMaxInitialLineLength()); if (endpointObject.isHttp2Enabled()) { serverOptions.setUseAlpn(TransportConfig.getUseAlpn()) .setInitialSettings(new Http2Settings().setMaxConcurrentStreams(TransportConfig.getMaxConcurrentStreams())); } if (endpointObject.isSslEnabled()) { SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null); SSLOption sslOption; if (factory == null) { sslOption = SSLOption.buildFromYaml(SSL_KEY); } else { sslOption = factory.createSSLOption(); } SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass()); VertxTLSBuilder.buildNetServerOptions(sslOption, sslCustom, serverOptions); } return serverOptions; } }