protected Response requestHttpMethod(String url, String body, Map<String, String> headers,
                                         String httpMethod) {
        log.debug("Executing {} request to URL={}." + (body != null ? " Payload={}" : ""),
                httpMethod, url, body);

        try {
            Request req = httpClient.newRequest(url);
            req.method(httpMethod);
            if (body != null) {
                headers.forEach(req::header);
                req.content(new StringContentProvider(body), "application/json");
            }

            ContentResponse res = req.send();
            log.info("{} response for URL={} is {}",
                    httpMethod, url, res.getContentAsString().isEmpty() ? "empty" : res.getContentAsString());
            return Response.status(Response.Status.fromStatusCode(res.getStatus()))
                    .entity(res.getContentAsString())
                    .build();
        } catch (Exception e) {
            log.error("Could not execute " + httpMethod + " request to " + url, e);
            throw new ConnectException(e);
        }
    }
A general method that executes an HTTP request on a given URL.

@param url the HTTP endpoint
@param body the payload of the request; null if there isn't one
@param headers a map that stores the request headers; empty if there are no headers
@param httpMethod the name of the HTTP method to execute
@return the response to the HTTP request
@throws ConnectException if execution of the HTTP method fails
connect/runtime/src/test/java/org/apache/kafka/connect/util/clusters/EmbeddedConnect.java