Search in sources :

Example 1 with Url

use of org.opennms.netmgt.config.httpdatacollection.Url in project opennms by OpenNMS.

the class HttpCollector method buildHttpMethod.

private static HttpRequestBase buildHttpMethod(final HttpCollectorAgent collectorAgent) throws URISyntaxException {
    HttpRequestBase method;
    final URI uri = buildUri(collectorAgent);
    final Url url = collectorAgent.getUriDef().getUrl();
    if ("GET".equals(url.getMethod())) {
        method = buildGetMethod(uri, collectorAgent);
    } else {
        method = buildPostMethod(uri, collectorAgent);
    }
    if (url.getVirtualHost().isPresent()) {
        final String virtualHost = url.getVirtualHost().get();
        if (!virtualHost.trim().isEmpty()) {
            method.setHeader(HTTP.TARGET_HOST, virtualHost);
        }
    }
    return method;
}
Also used : HttpRequestBase(org.apache.http.client.methods.HttpRequestBase) URI(java.net.URI) Url(org.opennms.netmgt.config.httpdatacollection.Url)

Aggregations

URI (java.net.URI)1 HttpRequestBase (org.apache.http.client.methods.HttpRequestBase)1 Url (org.opennms.netmgt.config.httpdatacollection.Url)1