public NettyHandlerAdapter(Stopper stopper, Handler handler, LaunchConfig launchConfig) {
    this.handlers = new Handler[] {handler};
    this.return404 = Handlers.notFound();
    RegistryBuilder registryBuilder =
        Registries.registry()
            // If you update this list, update the class level javadoc on Context.
            .add(Stopper.class, stopper)
            .add(MimeTypes.class, new ActivationBackedMimeTypes())
            .add(
                PublicAddress.class,
                new DefaultPublicAddress(
                    launchConfig.getPublicAddress(),
                    launchConfig.getSSLContext() == null ? "http" : "https"))
            .add(Redirector.class, new DefaultRedirector())
            .add(ClientErrorHandler.class, new DefaultClientErrorHandler())
            .add(ServerErrorHandler.class, new DefaultServerErrorHandler())
            .add(LaunchConfig.class, launchConfig)
            .add(FileRenderer.class, new DefaultFileRenderer())
            .add(CharSequenceRenderer.class, new DefaultCharSequenceRenderer())
            .add(FormParser.class, FormParser.multiPart())
            .add(FormParser.class, FormParser.urlEncoded())
            .add(HttpClient.class, HttpClients.httpClient(launchConfig));

    if (launchConfig.isHasBaseDir()) {
      registryBuilder.add(FileSystemBinding.class, launchConfig.getBaseDir());
    }

    this.registry = registryBuilder.build();

    this.addResponseTimeHeader = launchConfig.isTimeResponses();
    this.compressResponses = launchConfig.isCompressResponses();
    this.applicationConstants =
        new DefaultContext.ApplicationConstants(launchConfig, new DefaultRenderController());
    this.execController = launchConfig.getExecController();
  }
 @Override
 public HandlingResult handleChain(Action<? super Chain> chainAction) throws Exception {
   final DefaultHandlingResult.ResultsHolder results = new DefaultHandlingResult.ResultsHolder();
   Registry registry = getEffectiveRegistry(results);
   ServerConfig serverConfig = registry.get(ServerConfig.class);
   Handler handler = Handlers.chain(serverConfig, registry, chainAction);
   return invoke(handler, registry, results);
 }
  private HandlingResult invoke(
      Handler handler, Registry registry, DefaultHandlingResult.ResultsHolder results)
      throws HandlerTimeoutException {
    ServerConfig serverConfig = registry.get(ServerConfig.class);

    DefaultRequest request =
        new DefaultRequest(
            Instant.now(),
            requestHeaders,
            HttpMethod.valueOf(method.toUpperCase()),
            HttpVersion.valueOf(protocol),
            uri,
            new InetSocketAddress(remoteHostAndPort.getHostText(), remoteHostAndPort.getPort()),
            new InetSocketAddress(localHostAndPort.getHostText(), localHostAndPort.getPort()),
            serverConfig,
            new RequestBodyReader() {
              @Override
              public Promise<? extends ByteBuf> read(long maxContentLength, Block onTooLarge) {
                return Promise.value(requestBody)
                    .route(r -> r.readableBytes() > maxContentLength, onTooLarge.action());
              }

              @Override
              public TransformablePublisher<? extends ByteBuf> readStream(long maxContentLength) {
                return Streams.<ByteBuf>yield(
                    r -> {
                      if (r.getRequestNum() > 0) {
                        return null;
                      } else {
                        return requestBody;
                      }
                    });
              }
            });

    if (pathBinding != null) {
      handler =
          Handlers.chain(
              ctx -> {
                ctx.getExecution().get(PathBindingStorage.TYPE).push(pathBinding);
                ctx.next();
              },
              handler);
    }

    try {
      return new DefaultHandlingResult(
          request, results, responseHeaders, registry, timeout, handler);
    } catch (Exception e) {
      throw Exceptions.uncheck(e);
    } finally {
      registry.get(ExecController.class).close();
    }
  }