private void tryDownloadingArtifact(HttpClient client, int port, URL artifactUrl, File pluginFile, Promise<File> promise) {
        final HttpClientRequest request = client.get(port, artifactUrl.getHost(), artifactUrl.getPath(),
            (Handler<HttpClientResponse>) response -> {

                response.exceptionHandler((Handler<Throwable>) promise::fail);

                // Body Handler. If RAM usage is too high we can change this to write chunks to disk.
                response.bodyHandler((Handler<Buffer>) buffer -> {
                    try {
                        // Response status code for request [x] : y
                        LOG.debug(Messages.format("VertxPluginRegistry.ResponseStatusCode",
                            response.request().absoluteURI(),
                            response.statusCode()));

                        // If status code is bad, do not handle the buffer.
                        if (!(response.statusCode() / 100 == 2)) {
                            LOG.warn("Received a bad status code from remote server");
                            promise.fail(new BadResponseCodeError("Server returned non-200 status code "
                                + response.statusCode()));
                            return;
                        }

                        Files.write(pluginFile.toPath(), buffer.getBytes(), StandardOpenOption.APPEND,
                            StandardOpenOption.CREATE, StandardOpenOption.WRITE);

                        LOG.debug("Successfully wrote artifact to {0} to {1}", artifactUrl, pluginFile);

                        promise.complete(pluginFile);
                    } catch (IOException ioe) {
                        LOG.error(ioe);
                        promise.fail(ioe);
                    }
                });
            });

        // Add the Basic authentication if contained in URL
        if (artifactUrl.getUserInfo() != null) {
            String up = artifactUrl.getUserInfo();
            request.putHeader(
                HttpHeaders.AUTHORIZATION,
                "Basic " + Base64.getEncoder().encodeToString(up.getBytes(StandardCharsets.ISO_8859_1))
            );
        }

        request.exceptionHandler((Handler<Throwable>) promise::fail);

        request.end();
    }
@see io.apiman.gateway.engine.impl.DefaultPluginRegistry#downloadArtifactTo(java.net.URL, java.io.File,
     io.apiman.gateway.engine.async.IAsyncResultHandler)
gateway/platforms/vertx3/vertx3/src/main/java/io/apiman/gateway/platforms/vertx3/engine/VertxPluginRegistry.java