private CompletableFuture<Response> send(Method method, String path, Option[] options, StreamConsumer outStreamConsumer) {
        return CompletableFuture.supplyAsync(() -> {
            HttpURLConnection conn = null;
            try {
                final Param[] params = Stream.of(options).filter(o -> o.getType() == PARAM).map(Param.class::cast).toArray(Param[]::new);
                final Header[] headers = Stream.of(options).filter(o -> o.getType() == HEADER).map(Header.class::cast).toArray(Header[]::new);
                final URL url = getUrl(path, params);

                conn = (HttpURLConnection) url.openConnection();

                switch (method) {
                    case POST    : conn.setRequestMethod("POST");    break;
                    case GET     : conn.setRequestMethod("GET");     break;
                    case DELETE  : conn.setRequestMethod("DELETE");  break;
                    case OPTIONS : conn.setRequestMethod("OPTIONS"); break;
                    case PUT     : conn.setRequestMethod("PUT");     break;
                    case HEAD    : conn.setRequestMethod("HEAD");    break;
                    default : throw new UnsupportedOperationException(
                        String.format("Unknown enum constant '%s'.", method)
                    );
                }

                if (username != null && password != null) {
                    final byte[] authentication = (username + ":" + password).getBytes();
                    final String encoding = Base64.getEncoder().encodeToString(authentication);
                    conn.setRequestProperty("Authorization", "Basic " + encoding);
                }

                for (final Header header : headers) {
                    conn.setRequestProperty(
                        header.getKey(),
                        header.getValue());
                }

                conn.setUseCaches(false);
                conn.setAllowUserInteraction(false);

                final boolean doOutput = outStreamConsumer != IGNORE;
                conn.setDoOutput(doOutput);

                conn.connect();
                if (doOutput) {
                    try (final OutputStream out = conn.getOutputStream()) {
                        outStreamConsumer.writeTo(out);
                        out.flush();
                    }
                }

                int status = getResponseCodeFrom(conn);
                final String text = tryGetResponseTextFrom(conn, status);

                return new Response(status, text, conn.getHeaderFields());
            } catch (final Exception ex) {
                throw new RestException(ex, protocol, method, username, host, port, path, options);
            } finally {
                if (conn != null) {
                    conn.disconnect();
                }
            }
        });
    }
Default implementation of the {@link Rest}-interface.

@author  Emil Forslund
@since   1.0.0
common-parent/rest/src/main/java/com/speedment/common/rest/RestImpl.java