class JettyHttpClient extends StandardHttpClient<JettyHttpClient, JettyHttpClientFactory, JettyHttpClientBuilder> {

  private final HttpClient jetty;
  private final WebSocketClient jettyWs;

  public JettyHttpClient(StandardHttpClientBuilder<JettyHttpClient, JettyHttpClientFactory, JettyHttpClientBuilder> builder,
      HttpClient jetty, WebSocketClient jettyWs) {
    this(builder, jetty, jettyWs, new AtomicBoolean());
  }

  public JettyHttpClient(StandardHttpClientBuilder<JettyHttpClient, JettyHttpClientFactory, JettyHttpClientBuilder> builder,
      HttpClient jetty, WebSocketClient jettyWs, AtomicBoolean closed) {
    super(builder, closed);
    this.jetty = jetty;
    this.jettyWs = jettyWs;
  }

  @Override
  public void doClose() {
    try {
      jetty.stop();
      jettyWs.stop();
    } catch (Exception e) {
      throw KubernetesClientException.launderThrowable(e);
    }
  }

  @Override
  public CompletableFuture<HttpResponse<AsyncBody>> consumeBytesDirect(StandardHttpRequest request,
      Consumer<List<ByteBuffer>> consumer) {
    return new JettyAsyncResponseListener(request) {

      @Override
      protected void onContent(ByteBuffer content) throws Exception {
        // we must clone as the buffer can be reused by the byte consumer
        consumer.consume(Collections.singletonList(copy(content)), this);
      }
    }.listen(newRequest(request));
  }

  private Request newRequest(StandardHttpRequest originalRequest) {<FILL_FUNCTION_BODY>}

  @Override
  public CompletableFuture<WebSocketResponse> buildWebSocketDirect(StandardWebSocketBuilder standardWebSocketBuilder,
      Listener listener) {
    try {
      jettyWs.start();
      StandardHttpRequest request = standardWebSocketBuilder.asHttpRequest();
      final ClientUpgradeRequest cur = new ClientUpgradeRequest();
      if (Utils.isNotNullOrEmpty(standardWebSocketBuilder.getSubprotocol())) {
        cur.setSubProtocols(standardWebSocketBuilder.getSubprotocol());
      }
      cur.setHeaders(request.headers());
      if (request.getTimeout() != null) {
        cur.setTimeout(request.getTimeout().toMillis(), TimeUnit.MILLISECONDS);
      }
      // Extra-future required because we can't Map the UpgradeException to a WebSocketHandshakeException easily
      final CompletableFuture<WebSocketResponse> future = new CompletableFuture<>();
      final JettyWebSocket webSocket = new JettyWebSocket(listener);
      jettyWs.connect(webSocket, Objects.requireNonNull(WebSocket.toWebSocketUri(request.uri())), cur)
          .whenComplete((s, ex) -> {
            if (ex != null) {
              if (ex instanceof CompletionException && ex.getCause() instanceof UpgradeException) {
                future.complete(JettyWebSocket.toWebSocketResponse(request, (UpgradeException) ex.getCause()));
              } else if (ex instanceof UpgradeException) {
                future.complete(JettyWebSocket.toWebSocketResponse(request, (UpgradeException) ex));
              } else {
                future.completeExceptionally(ex);
              }
            } else {
              future.complete(JettyWebSocket.toWebSocketResponse(request, webSocket, s));
            }
          });
      return future;
    } catch (Exception e) {
      throw KubernetesClientException.launderThrowable(e);
    }
  }

  HttpClient getJetty() {
    return jetty;
  }

  WebSocketClient getJettyWs() {
    return jettyWs;
  }

}

    try {
      jetty.start();
    } catch (Exception e) {
      throw KubernetesClientException.launderThrowable(e);
    }
    final var requestBuilder = originalRequest.newBuilder();
    final var request = requestBuilder.build();

    var jettyRequest = jetty.newRequest(request.uri()).method(request.method());
    if (originalRequest.getTimeout() != null) {
      jettyRequest.timeout(originalRequest.getTimeout().toMillis(), TimeUnit.MILLISECONDS);
    }
    jettyRequest.headers(m -> request.headers().forEach(m::put));

    final var contentType = Optional.ofNullable(request.getContentType());

    BodyContent body = request.body();
    if (body != null) {
      if (body instanceof StringBodyContent) {
        jettyRequest.body(new StringRequestContent(contentType.orElse(TEXT_PLAIN), ((StringBodyContent) body).getContent()));
      } else if (body instanceof ByteArrayBodyContent) {
        jettyRequest.body(
            new BytesRequestContent(contentType.orElse(APPLICATION_OCTET_STREAM), ((ByteArrayBodyContent) body).getContent()));
      } else if (body instanceof InputStreamBodyContent) {
        InputStreamBodyContent bodyContent = (InputStreamBodyContent) body;
        if (bodyContent.getLength() >= 0) {
          jettyRequest.headers(m -> m.put(StandardHttpHeaders.CONTENT_LENGTH, Long.toString(bodyContent.getLength())));
        }
        jettyRequest
            .body(new InputStreamRequestContent(contentType.orElse(APPLICATION_OCTET_STREAM), bodyContent.getContent()));
      } else {
        throw new AssertionError("Unsupported body content");
      }
    }

    if (request.isExpectContinue()) {
      jettyRequest.headers(m -> m.put(StandardHttpHeaders.EXPECT, StandardHttpHeaders.EXPECT_CONTINUE));
    }

    return jettyRequest;
  
<methods>public abstract CompletableFuture<io.fabric8.kubernetes.client.http.WebSocketResponse> buildWebSocketDirect(io.fabric8.kubernetes.client.http.StandardWebSocketBuilder, io.fabric8.kubernetes.client.http.WebSocket.Listener) ,public final void close() ,public CompletableFuture<HttpResponse<io.fabric8.kubernetes.client.http.AsyncBody>> consumeBytes(io.fabric8.kubernetes.client.http.HttpRequest, Consumer<List<java.nio.ByteBuffer>>) ,public abstract CompletableFuture<HttpResponse<io.fabric8.kubernetes.client.http.AsyncBody>> consumeBytesDirect(io.fabric8.kubernetes.client.http.StandardHttpRequest, Consumer<List<java.nio.ByteBuffer>>) ,public java.util.concurrent.atomic.AtomicBoolean getClosed() ,public V getTag(Class<V>) ,public boolean isClosed() ,public io.fabric8.kubernetes.client.http.HttpClient.DerivedClientBuilder newBuilder() ,public io.fabric8.kubernetes.client.http.HttpRequest.Builder newHttpRequestBuilder() ,public io.fabric8.kubernetes.client.http.WebSocket.Builder newWebSocketBuilder() ,public CompletableFuture<HttpResponse<V>> sendAsync(io.fabric8.kubernetes.client.http.HttpRequest, Class<V>) <variables>private static final Logger LOG,private static final long MAX_ADDITIONAL_REQUEST_TIMEOUT,protected StandardHttpClientBuilder<io.fabric8.kubernetes.client.jetty.JettyHttpClient,io.fabric8.kubernetes.client.jetty.JettyHttpClientFactory,io.fabric8.kubernetes.client.jetty.JettyHttpClientBuilder> builder,protected java.util.concurrent.atomic.AtomicBoolean closed