reactor.netty.http.server.HttpServer.tcpConfiguration()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(317)

本文整理了Java中reactor.netty.http.server.HttpServer.tcpConfiguration()方法的一些代码示例,展示了HttpServer.tcpConfiguration()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpServer.tcpConfiguration()方法的具体详情如下:
包路径:reactor.netty.http.server.HttpServer
类名称:HttpServer
方法名:tcpConfiguration

HttpServer.tcpConfiguration介绍

[英]Materialize a TcpServer from the parent HttpServer chain to use with #bind(TcpServer) or separately
[中]从父HttpServer链具体化TcpServer,以便与#bind(TcpServer)一起使用或单独使用

代码示例

代码示例来源:origin: spring-projects/spring-framework

  1. @Override
  2. protected void initServer() {
  3. this.reactorHandler = createHttpHandlerAdapter();
  4. this.reactorServer = reactor.netty.http.server.HttpServer.create()
  5. .tcpConfiguration(server -> server.host(getHost()))
  6. .port(getPort());
  7. }

代码示例来源:origin: spring-cloud/spring-cloud-gateway

  1. @Override
  2. protected void initServer() {
  3. this.reactorHandler = createHttpHandlerAdapter();
  4. this.reactorServer = reactor.netty.http.server.HttpServer.create()
  5. .tcpConfiguration(server -> server.host(getHost()))
  6. .port(getPort());
  7. }

代码示例来源:origin: org.springframework.boot/spring-boot

  1. private HttpServer createHttpServer() {
  2. HttpServer server = HttpServer.create();
  3. if (this.resourceFactory != null) {
  4. LoopResources resources = this.resourceFactory.getLoopResources();
  5. Assert.notNull(resources,
  6. "No LoopResources: is ReactorResourceFactory not initialized yet?");
  7. server = server.tcpConfiguration((tcpServer) -> tcpServer.runOn(resources)
  8. .addressSupplier(this::getListenAddress));
  9. }
  10. else {
  11. server = server.tcpConfiguration(
  12. (tcpServer) -> tcpServer.addressSupplier(this::getListenAddress));
  13. }
  14. if (getSsl() != null && getSsl().isEnabled()) {
  15. SslServerCustomizer sslServerCustomizer = new SslServerCustomizer(getSsl(),
  16. getHttp2(), getSslStoreProvider());
  17. server = sslServerCustomizer.apply(server);
  18. }
  19. if (getCompression() != null && getCompression().getEnabled()) {
  20. CompressionCustomizer compressionCustomizer = new CompressionCustomizer(
  21. getCompression());
  22. server = compressionCustomizer.apply(server);
  23. }
  24. server = server.protocol(listProtocols()).forwarded(this.useForwardHeaders);
  25. return applyCustomizers(server);
  26. }

代码示例来源:origin: reactor/reactor-netty

  1. @Override
  2. protected TcpServer tcpConfiguration() {
  3. return source.tcpConfiguration();
  4. }

代码示例来源:origin: reactor/reactor-netty

  1. @Override
  2. protected TcpServer tcpConfiguration() {
  3. return Objects.requireNonNull(tcpServerMapper.apply(source.tcpConfiguration()),
  4. "tcpServerMapper");
  5. }
  6. }

代码示例来源:origin: io.projectreactor.netty/reactor-netty

  1. @Override
  2. protected TcpServer tcpConfiguration() {
  3. return Objects.requireNonNull(tcpServerMapper.apply(source.tcpConfiguration()),
  4. "tcpServerMapper");
  5. }
  6. }

代码示例来源:origin: reactor/reactor-netty

  1. /**
  2. * The port to which this server should bind.
  3. *
  4. * @param port The port to bind to.
  5. *
  6. * @return a new {@link HttpServer}
  7. */
  8. public final HttpServer port(int port) {
  9. return tcpConfiguration(tcpServer -> tcpServer.port(port));
  10. }

代码示例来源:origin: reactor/reactor-netty

  1. /**
  2. * The host to which this server should bind.
  3. *
  4. * @param host The host to bind to.
  5. *
  6. * @return a new {@link HttpServer}
  7. */
  8. public final HttpServer host(String host) {
  9. return tcpConfiguration(tcpServer -> tcpServer.host(host));
  10. }

代码示例来源:origin: reactor/reactor-netty

  1. @Override
  2. protected TcpServer tcpConfiguration() {
  3. return source.tcpConfiguration().secure(this.sslProvider);
  4. }
  5. }

代码示例来源:origin: reactor/reactor-netty

  1. @Override
  2. protected TcpServer tcpConfiguration() {
  3. return source.tcpConfiguration().bootstrap(this);
  4. }

代码示例来源:origin: io.projectreactor.netty/reactor-netty

  1. /**
  2. * The host to which this server should bind.
  3. *
  4. * @param host The host to bind to.
  5. *
  6. * @return a new {@link HttpServer}
  7. */
  8. public final HttpServer host(String host) {
  9. return tcpConfiguration(tcpServer -> tcpServer.host(host));
  10. }

代码示例来源:origin: reactor/reactor-netty

  1. /**
  2. * Apply a wire logger configuration using {@link HttpServer} category
  3. * and {@code DEBUG} logger level
  4. *
  5. * @return a new {@link HttpServer}
  6. * @deprecated Use {@link HttpServer#wiretap(boolean)}
  7. */
  8. @Deprecated
  9. public final HttpServer wiretap() {
  10. return tcpConfiguration(tcpServer ->
  11. tcpServer.bootstrap(b -> BootstrapHandlers.updateLogSupport(b, LOGGING_HANDLER)));
  12. }

代码示例来源:origin: reactor/reactor-netty

  1. /**
  2. * Configure the {@link io.netty.handler.codec.http.HttpServerCodec}'s request decoding options.
  3. *
  4. * @param requestDecoderOptions a function to mutate the provided Http request decoder options
  5. * @return a new {@link HttpServer}
  6. */
  7. public final HttpServer httpRequestDecoder(Function<HttpRequestDecoderSpec, HttpRequestDecoderSpec> requestDecoderOptions) {
  8. return tcpConfiguration(
  9. requestDecoderOptions.apply(new HttpRequestDecoderSpec())
  10. .build());
  11. }

代码示例来源:origin: io.projectreactor.netty/reactor-netty

  1. /**
  2. * Apply a wire logger configuration using {@link HttpServer} category
  3. * and {@code DEBUG} logger level
  4. *
  5. * @return a new {@link HttpServer}
  6. * @deprecated Use {@link HttpServer#wiretap(boolean)}
  7. */
  8. @Deprecated
  9. public final HttpServer wiretap() {
  10. return tcpConfiguration(tcpServer ->
  11. tcpServer.bootstrap(b -> BootstrapHandlers.updateLogSupport(b, LOGGING_HANDLER)));
  12. }

代码示例来源:origin: io.projectreactor.netty/reactor-netty

  1. /**
  2. * Configure the {@link io.netty.handler.codec.http.HttpServerCodec}'s request decoding options.
  3. *
  4. * @param requestDecoderOptions a function to mutate the provided Http request decoder options
  5. * @return a new {@link HttpServer}
  6. */
  7. public final HttpServer httpRequestDecoder(Function<HttpRequestDecoderSpec, HttpRequestDecoderSpec> requestDecoderOptions) {
  8. return tcpConfiguration(
  9. requestDecoderOptions.apply(new HttpRequestDecoderSpec())
  10. .build());
  11. }

代码示例来源:origin: reactor/reactor-netty

  1. /**
  2. * The HTTP protocol to support. Default is {@link HttpProtocol#HTTP11}.
  3. *
  4. * @param supportedProtocols The various {@link HttpProtocol} this server will support
  5. *
  6. * @return a new {@link HttpServer}
  7. */
  8. public final HttpServer protocol(HttpProtocol... supportedProtocols) {
  9. return tcpConfiguration(tcpServer -> tcpServer.bootstrap(b -> HttpServerConfiguration.protocols(b, supportedProtocols)));
  10. }

代码示例来源:origin: io.projectreactor.netty/reactor-netty

  1. /**
  2. * The HTTP protocol to support. Default is {@link HttpProtocol#HTTP11}.
  3. *
  4. * @param supportedProtocols The various {@link HttpProtocol} this server will support
  5. *
  6. * @return a new {@link HttpServer}
  7. */
  8. public final HttpServer protocol(HttpProtocol... supportedProtocols) {
  9. return tcpConfiguration(tcpServer -> tcpServer.bootstrap(b -> HttpServerConfiguration.protocols(b, supportedProtocols)));
  10. }

代码示例来源:origin: reactor/reactor-netty

  1. /**
  2. * Configure the
  3. * {@link ServerCookieEncoder} and {@link ServerCookieDecoder}
  4. *
  5. * @param encoder the preferred ServerCookieEncoder
  6. * @param decoder the preferred ServerCookieDecoder
  7. *
  8. * @return a new {@link HttpServer}
  9. */
  10. public final HttpServer cookieCodec(ServerCookieEncoder encoder, ServerCookieDecoder decoder) {
  11. return tcpConfiguration(tcp -> tcp.bootstrap(
  12. b -> HttpServerConfiguration.cookieCodec(b, encoder, decoder)));
  13. }

代码示例来源:origin: reactor/reactor-netty

  1. @Test
  2. public void gettingOptionsDuplicates() {
  3. HttpServer server = HttpServer.create()
  4. .port(123)
  5. .host(("foo"))
  6. .compress(true);
  7. assertThat(server.tcpConfiguration().configure())
  8. .isNotSameAs(HttpServer.DEFAULT_TCP_SERVER)
  9. .isNotSameAs(server.tcpConfiguration().configure());
  10. }

代码示例来源:origin: reactor/reactor-netty

  1. @Test
  2. public void testRestart() {
  3. doTestRestart(HttpServer.create()
  4. .port(8080),
  5. HttpClient.create()
  6. .port(8080));
  7. doTestRestart(HttpServer.create()
  8. // Any local address
  9. .tcpConfiguration(tcpServer -> tcpServer.addressSupplier(() -> new InetSocketAddress(8080))),
  10. HttpClient.create()
  11. .port(8080));
  12. }

相关文章