Source:
private HttpRequest buildJettyRequest(Request finalRequest) { HttpRequest jettyRequest = (HttpRequest) httpClient.newRequest(finalRequest.getUri()); JettyRequestListener listener = new JettyRequestListener(finalRequest.getUri()); jettyRequest.onRequestBegin(request -> listener.onRequestBegin()); jettyRequest.onRequestSuccess(request -> listener.onRequestEnd()); jettyRequest.onResponseBegin(response -> listener.onResponseBegin()); jettyRequest.onComplete(result -> listener.onFinish()); jettyRequest.attribute(PRESTO_STATS_KEY, listener); jettyRequest.getHeaders().remove(HttpHeader.USER_AGENT); jettyRequest.method(finalRequest.getMethod()); for (Entry<String, String> entry : finalRequest.getHeaders().entries()) { jettyRequest.header(entry.getKey(), entry.getValue()); } BodyGenerator bodyGenerator = finalRequest.getBodyGenerator(); if (bodyGenerator != null) { if (bodyGenerator instanceof StaticBodyGenerator) { StaticBodyGenerator staticBodyGenerator = (StaticBodyGenerator) bodyGenerator; jettyRequest.content(new BytesContentProvider(staticBodyGenerator.getBody())); } else { jettyRequest.content(new BodyGeneratorContentProvider(bodyGenerator, httpClient.getExecutor())); } } jettyRequest.timeout(requestTimeoutMillis, MILLISECONDS); jettyRequest.idleTimeout(idleTimeoutMillis, MILLISECONDS); if (jettyRequest.getURI().getScheme().equalsIgnoreCase("https")) { jettyRequest.header(io.airlift.security.utils.SecurityUtil.REALM_IN_CHALLENGE, "true"); AuthenticationStore authStore = httpClient.getAuthenticationStore(); if (securityConfig != null && securityConfig.enabled()) { String authScheme = securityConfig.getAuthScheme().toString(); if (authStore.findAuthentication(authScheme, jettyRequest.getURI(), null) == null) { httpClient.getAuthenticationStore().addAuthentication( authenticationProvider.createAuthentication(jettyRequest.getURI())); } } } return jettyRequest; }

Target:
private HttpRequest buildJettyRequest(Request finalRequest) { HttpRequest jettyRequest = (HttpRequest) httpClient.newRequest(finalRequest.getUri()); JettyRequestListener listener = new JettyRequestListener(finalRequest.getUri()); jettyRequest.onRequestBegin(request -> listener.onRequestBegin()); jettyRequest.onRequestSuccess(request -> listener.onRequestEnd()); jettyRequest.onResponseBegin(response -> listener.onResponseBegin()); jettyRequest.onComplete(result -> listener.onFinish()); jettyRequest.attribute(PRESTO_STATS_KEY, listener); jettyRequest.getHeaders().remove(HttpHeader.USER_AGENT); jettyRequest.method(finalRequest.getMethod()); for (Entry<String, String> entry : finalRequest.getHeaders().entries()) { jettyRequest.header(entry.getKey(), entry.getValue()); } BodyGenerator bodyGenerator = finalRequest.getBodyGenerator(); if (bodyGenerator != null) { if (bodyGenerator instanceof StaticBodyGenerator) { StaticBodyGenerator staticBodyGenerator = (StaticBodyGenerator) bodyGenerator; jettyRequest.content(new BytesContentProvider(staticBodyGenerator.getBody())); } else { jettyRequest.content(new BodyGeneratorContentProvider(bodyGenerator, httpClient.getExecutor())); } } jettyRequest.timeout(requestTimeoutMillis, MILLISECONDS); jettyRequest.idleTimeout(idleTimeoutMillis, MILLISECONDS); if (authenticationEnabled && "https".equalsIgnoreCase(jettyRequest.getURI().getScheme())) { jettyRequest.header(REALM_IN_CHALLENGE, "true"); } return jettyRequest; }