Example usage for org.apache.http.client.methods HttpGet METHOD_NAME

List of usage examples for org.apache.http.client.methods HttpGet METHOD_NAME

Introduction

In this page you can find the example usage for org.apache.http.client.methods HttpGet METHOD_NAME.

Prototype

String METHOD_NAME

To view the source code for org.apache.http.client.methods HttpGet METHOD_NAME.

Click Source Link

Usage

From source file:quarks.connectors.http.HttpStreams.java

public static TStream<JsonObject> getJson(TStream<JsonObject> stream,
        Supplier<CloseableHttpClient> clientCreator, Function<JsonObject, String> uri) {

    return HttpStreams.<JsonObject, JsonObject>requests(stream, clientCreator, t -> HttpGet.METHOD_NAME, uri,
            HttpResponders.json());/*from w  ww. j ava2 s  .c  om*/
}

From source file:com.twitter.hbc.core.HttpConstants.java

public static boolean checkHttpMethod(String httpMethod) {
    if (httpMethod.equalsIgnoreCase(HttpGet.METHOD_NAME)) {
        return true;
    } else if (httpMethod.equalsIgnoreCase(HttpPost.METHOD_NAME)) {
        return true;
    }/*  w ww.ja  va2s .  c  o m*/
    return false;
}

From source file:com.blacklocus.jres.request.document.JresGetDocument.java

@Override
public String getHttpMethod() {
    return HttpGet.METHOD_NAME;
}

From source file:org.fcrepo.camel.HttpMethodsTest.java

@Test
public void testMethods() {
    assertEquals(HttpMethods.DELETE.toString(), HttpDelete.METHOD_NAME);
    assertEquals(HttpMethods.GET.toString(), HttpGet.METHOD_NAME);
    assertEquals(HttpMethods.HEAD.toString(), HttpHead.METHOD_NAME);
    assertEquals(HttpMethods.OPTIONS.toString(), HttpOptions.METHOD_NAME);
    assertEquals(HttpMethods.PATCH.toString(), HttpPatch.METHOD_NAME);
    assertEquals(HttpMethods.POST.toString(), HttpPost.METHOD_NAME);
    assertEquals(HttpMethods.PUT.toString(), HttpPut.METHOD_NAME);
}

From source file:org.elasticsearch.client.PingAndInfoIT.java

@SuppressWarnings("unchecked")
public void testInfo() throws IOException {
    MainResponse info = highLevelClient().info();
    // compare with what the low level client outputs
    Map<String, Object> infoAsMap = entityAsMap(adminClient().performRequest(HttpGet.METHOD_NAME, "/"));
    assertEquals(infoAsMap.get("cluster_name"), info.getClusterName().value());
    assertEquals(infoAsMap.get("cluster_uuid"), info.getClusterUuid());

    // only check node name existence, might be a different one from what was hit by low level client in multi-node cluster
    assertNotNull(info.getNodeName());/*from   w w  w  .ja va  2 s .com*/
    Map<String, Object> versionMap = (Map<String, Object>) infoAsMap.get("version");
    assertEquals(versionMap.get("build_flavor"), info.getBuild().flavor().displayName());
    assertEquals(versionMap.get("build_type"), info.getBuild().type().displayName());
    assertEquals(versionMap.get("build_hash"), info.getBuild().shortHash());
    assertEquals(versionMap.get("build_date"), info.getBuild().date());
    assertEquals(versionMap.get("build_snapshot"), info.getBuild().isSnapshot());
    assertEquals(versionMap.get("number"), info.getVersion().toString());
    assertEquals(versionMap.get("lucene_version"), info.getVersion().luceneVersion.toString());
}

From source file:org.jolokia.client.request.J4pReadIntegrationTest.java

@Test
public void nameTest() throws MalformedObjectNameException, J4pException {
    checkNames(HttpGet.METHOD_NAME, itSetup.getStrangeNames(), itSetup.getEscapedNames());
    checkNames(HttpPost.METHOD_NAME, itSetup.getStrangeNames(), itSetup.getEscapedNames());
}

From source file:io.wcm.caravan.io.http.impl.RequestUtil.java

/**
 * @param urlPrefix URL prefix//from w  w  w  . java 2  s .c o  m
 * @param request Requset
 * @return HTTP client request object
 */
public static HttpUriRequest buildHttpRequest(String urlPrefix, Request request) {
    String url = urlPrefix + request.url();

    // http method
    HttpUriRequest httpRequest;
    String method = StringUtils.upperCase(request.method());
    switch (method) {
    case HttpGet.METHOD_NAME:
        httpRequest = new HttpGet(url);
        break;
    case HttpPost.METHOD_NAME:
        httpRequest = new HttpPost(url);
        break;
    case HttpPut.METHOD_NAME:
        httpRequest = new HttpPut(url);
        break;
    case HttpDelete.METHOD_NAME:
        httpRequest = new HttpDelete(url);
        break;
    default:
        throw new IllegalArgumentException("Unsupported HTTP method type: " + request.method());
    }

    // headers
    for (Entry<String, Collection<String>> entry : request.headers().entrySet()) {
        Streams.of(entry.getValue()).forEach(value -> httpRequest.addHeader(entry.getKey(), value));
    }

    // body
    if ((httpRequest instanceof HttpEntityEnclosingRequest) && request.body() != null) {
        HttpEntityEnclosingRequest entityHttpRequest = (HttpEntityEnclosingRequest) httpRequest;
        if (request.charset() != null) {
            entityHttpRequest.setEntity(
                    new StringEntity(new String(request.body(), request.charset()), request.charset()));
        } else {
            entityHttpRequest.setEntity(new ByteArrayEntity(request.body()));
        }
    }

    return httpRequest;
}

From source file:com.twitter.hbc.core.HttpConstants.java

public static HttpUriRequest constructRequest(String host, Endpoint endpoint, Authentication auth) {
    String url = host + endpoint.getURI();
    if (endpoint.getHttpMethod().equalsIgnoreCase(HttpGet.METHOD_NAME)) {
        HttpGet get = new HttpGet(url);
        if (auth != null)
            auth.signRequest(get, null);
        return get;
    } else if (endpoint.getHttpMethod().equalsIgnoreCase(HttpPost.METHOD_NAME)) {
        HttpPost post = new HttpPost(url);

        post.setEntity(new StringEntity(endpoint.getPostParamString(), Constants.DEFAULT_CHARSET));
        post.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");
        if (auth != null)
            auth.signRequest(post, endpoint.getPostParamString());

        return post;
    } else {/*from  w w w .  ja  va2 s. c  o  m*/
        throw new IllegalArgumentException("Bad http method: " + endpoint.getHttpMethod());
    }
}

From source file:me.ixfan.wechatkit.util.HttpClientUtil.java

/**
 * Send HTTP GET request and get JSON response.
 * @param url URL of request./*from   w  ww. ja va 2  s.c  om*/
 * @return JSON object of response.
 * @throws IOException If I/O error occurs.
 */
public static JsonObject sendGetRequestAndGetJsonResponse(String url) throws IOException {
    return sendRequestAndGetJsonResponse(url, HttpGet.METHOD_NAME);
}