class EtiqetHandlers {

    public void sendNamedRestMessageWithPayloadHeaders
        (String httpVerb, Map<String, String> headers, String payload, String endpoint,
            UrlExtension extensionsUrl)
        throws EtiqetException, IOException {
        if (endpoint == null) {
            throw new EtiqetException("Cannot send REST request without an endpoint");
        }

        URL url = getFullExtensionsUrl(extensionsUrl.getUri(), endpoint);
        HttpURLConnection con;
        if (url.toString().startsWith("https")) {
            con = (HttpsURLConnection) url.openConnection();
        } else {
            con = (HttpURLConnection) url.openConnection();
        }
        assertNotNull("Couldn't open an HTTP connection", con);
        con.setDoOutput(true);
        con.setRequestMethod(httpVerb);
        for (Map.Entry<String, String> entry : headers.entrySet()) {
            con.setRequestProperty(entry.getKey(), entry.getValue());
        }

        DataOutputStream wr = new DataOutputStream(con.getOutputStream());
        wr.writeBytes(payload);
        wr.flush();
        wr.close();

        if (con.getResponseCode() != 200) {
            String resMsg = con.getResponseMessage();
            throw new EtiqetException(
                "Did not receive 200 (OK) response. Response from server: " + resMsg);
        }
        LOG.info("Rest request: " + httpVerb + " to: " + extensionsUrl + endpoint + payload);
    }

    public  EtiqetHandlers();

}