presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/client/AwsRequestSigner.java/AwsRequestSigner/process
class AwsRequestSigner:    @Override
    public void process(final HttpRequest request, final HttpContext context)
            throws IOException
    {
        String method = request.getRequestLine().getMethod();

        URI uri = URI.create(request.getRequestLine().getUri());
        URIBuilder uriBuilder = new URIBuilder(uri);

        Map<String, List<String>> parameters = new TreeMap<>(CASE_INSENSITIVE_ORDER);
        for (NameValuePair parameter : uriBuilder.getQueryParams()) {
            parameters.computeIfAbsent(parameter.getName(), key -> new ArrayList<>())
                    .add(parameter.getValue());
        }

        Map<String, String> headers = Arrays.stream(request.getAllHeaders())
                .collect(toImmutableMap(Header::getName, Header::getValue));

        InputStream content = null;
        if (request instanceof HttpEntityEnclosingRequest) {
            HttpEntityEnclosingRequest enclosingRequest = (HttpEntityEnclosingRequest) request;
            if (enclosingRequest.getEntity() != null) {
                content = enclosingRequest.getEntity().getContent();
            }
        }

        DefaultRequest<?> awsRequest = new DefaultRequest<>(SERVICE_NAME);

        HttpHost host = (HttpHost) context.getAttribute(HTTP_TARGET_HOST);
        if (host != null) {
            awsRequest.setEndpoint(URI.create(host.toURI()));
        }
        awsRequest.setHttpMethod(HttpMethodName.fromValue(method));
        awsRequest.setResourcePath(uri.getRawPath());
        awsRequest.setContent(content);
        awsRequest.setParameters(parameters);
        awsRequest.setHeaders(headers);

        signer.sign(awsRequest, credentialsProvider.getCredentials());

        Header[] newHeaders = awsRequest.getHeaders().entrySet().stream()
                .map(entry -> new BasicHeader(entry.getKey(), entry.getValue()))
                .toArray(Header[]::new);

        request.setHeaders(newHeaders);

        InputStream newContent = awsRequest.getContent();
        checkState(newContent == null || request instanceof HttpEntityEnclosingRequest);
        if (newContent != null) {
            BasicHttpEntity entity = new BasicHttpEntity();
            entity.setContent(newContent);
            ((HttpEntityEnclosingRequest) request).setEntity(entity);
        }
    }