private void handleProxyRequest(HttpClientRequest proxyRequest) {
        log.info("Connected to origin: {}", proxyRequest.connection().remoteAddress());

        HttpServerRequest request = context.getRequest();
        context.setProxyRequest(proxyRequest);

        Upstream upstream = context.getUpstreamRoute().get();
        ProxyUtil.copyHeaders(request.headers(), proxyRequest.headers());
        if (upstream != null && upstream.getKey() != null) {
            proxyRequest.putHeader(Proxy.HEADER_API_KEY, upstream.getKey());
        } else {
            ApiKeyData proxyApiKeyData = context.getProxyApiKeyData();
            proxyRequest.headers().add(Proxy.HEADER_API_KEY, proxyApiKeyData.getPerRequestKey());
        }

        Buffer proxyRequestBody = context.getRequestBody();
        proxyRequest.putHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(proxyRequestBody.length()));

        proxyRequest.send(proxyRequestBody)
                .onSuccess(this::handleProxyResponse)
                .onFailure(this::handleProxyRequestError);
    }
Called when proxy connected to the origin.
server/src/main/java/com/epam/aidial/core/server/controller/RouteController.java