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

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

Introduction

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

Prototype

String METHOD_NAME

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

Click Source Link

Usage

From source file:com.blacklocus.jres.request.mapping.JresTypeExists.java

@Override
public String getHttpMethod() {
    return HttpHead.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.robolectric.shadows.httpclient.HttpRedirect.java

public HttpRedirect(final String method, final URI uri) {
    super();/*from  ww  w.  j  av a 2 s  .  c  o  m*/
    if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {
        this.method = HttpHead.METHOD_NAME;
    } else {
        this.method = HttpGet.METHOD_NAME;
    }
    setURI(uri);
}

From source file:org.gradle.internal.resource.transport.http.AlwaysRedirectRedirectStrategy.java

public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context)
        throws ProtocolException {
    URI uri = this.getLocationURI(request, response, context);
    String method = request.getRequestLine().getMethod();
    if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {
        return new HttpHead(uri);
    } else if (method.equalsIgnoreCase(HttpPost.METHOD_NAME)) {
        return this.copyEntity(new HttpPost(uri), request);
    } else if (method.equalsIgnoreCase(HttpPut.METHOD_NAME)) {
        return this.copyEntity(new HttpPut(uri), request);
    } else if (method.equalsIgnoreCase(HttpDelete.METHOD_NAME)) {
        return new HttpDelete(uri);
    } else if (method.equalsIgnoreCase(HttpTrace.METHOD_NAME)) {
        return new HttpTrace(uri);
    } else if (method.equalsIgnoreCase(HttpOptions.METHOD_NAME)) {
        return new HttpOptions(uri);
    } else if (method.equalsIgnoreCase(HttpPatch.METHOD_NAME)) {
        return this.copyEntity(new HttpPatch(uri), request);
    } else {/* w  ww. j  a v  a  2s. c o  m*/
        return new HttpGet(uri);
    }
}

From source file:com.openx.oauth.redirect.OpenXRedirectStrategy.java

/**
 * Custom redirect logic//from www .  ja v  a  2  s  .c  o  m
 * @param request
 * @param response
 * @param context
 * @return if the handler should redirect or not
 */
@Override
public boolean isRedirected(final HttpRequest request, final HttpResponse response, final HttpContext context) {
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }

    int statusCode = response.getStatusLine().getStatusCode();
    String method = request.getRequestLine().getMethod();
    Header locationHeader = response.getFirstHeader("location");
    switch (statusCode) {
    case HttpStatus.SC_MOVED_TEMPORARILY:
        if (method.equalsIgnoreCase(HttpPost.METHOD_NAME)) {
            return locationHeader != null;
        } else {
            return (method.equalsIgnoreCase(HttpGet.METHOD_NAME)
                    || method.equalsIgnoreCase(HttpHead.METHOD_NAME)) && locationHeader != null;
        }
    case HttpStatus.SC_MOVED_PERMANENTLY:
    case HttpStatus.SC_TEMPORARY_REDIRECT:
        return method.equalsIgnoreCase(HttpGet.METHOD_NAME) || method.equalsIgnoreCase(HttpHead.METHOD_NAME);
    case HttpStatus.SC_SEE_OTHER:
        return true;
    default:
        return false;
    }
}

From source file:com.asquera.elasticsearch.plugins.http.auth.integration.DisabledWhitelistIntegrationTest.java

@Test
public void testHealthCheckHeadMethod() throws Exception {
    HttpResponse response = httpClient().method(HttpHead.METHOD_NAME).path("/").execute();
    assertThat(response.getStatusCode(), equalTo(RestStatus.OK.getStatus()));
}

From source file:org.elasticsearch.test.rest.client.http.HttpResponse.java

public boolean supportsBody() {
    return !HttpHead.METHOD_NAME.equals(httpRequest.getMethod());
}

From source file:org.camunda.connect.httpclient.HttpRequestTest.java

@Test
public void setHttpMethod() {
    HttpRequest request = connector.createRequest().get();
    assertThat(request.getMethod()).isEqualTo(HttpGet.METHOD_NAME);

    request = connector.createRequest().post();
    assertThat(request.getMethod()).isEqualTo(HttpPost.METHOD_NAME);

    request = connector.createRequest().put();
    assertThat(request.getMethod()).isEqualTo(HttpPut.METHOD_NAME);

    request = connector.createRequest().delete();
    assertThat(request.getMethod()).isEqualTo(HttpDelete.METHOD_NAME);

    request = connector.createRequest().patch();
    assertThat(request.getMethod()).isEqualTo(HttpPatch.METHOD_NAME);

    request = connector.createRequest().head();
    assertThat(request.getMethod()).isEqualTo(HttpHead.METHOD_NAME);

    request = connector.createRequest().options();
    assertThat(request.getMethod()).isEqualTo(HttpOptions.METHOD_NAME);

    request = connector.createRequest().trace();
    assertThat(request.getMethod()).isEqualTo(HttpTrace.METHOD_NAME);
}

From source file:com.manning.androidhacks.hack023.net.FollowPostRedirectHandler.java

/**
 * HttpClient is compliant with the requirements of the HTTP specification
 * (RFC 2616) and does not automatically redirect other methods than GET and
 * HEAD. We have to override this method to automatically follow redirects
 * when using the POST method.//ww  w .j av a  2 s.  com
 */
@Override
public boolean isRedirectRequested(final HttpResponse response, final HttpContext context) {
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }

    int statusCode = response.getStatusLine().getStatusCode();
    switch (statusCode) {
    case HttpStatus.SC_MOVED_TEMPORARILY:
    case HttpStatus.SC_MOVED_PERMANENTLY:
    case HttpStatus.SC_TEMPORARY_REDIRECT:
        HttpRequest request = (HttpRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
        String method = request.getRequestLine().getMethod();
        return method.equalsIgnoreCase(HttpGet.METHOD_NAME) || method.equalsIgnoreCase(HttpHead.METHOD_NAME)
                || method.equalsIgnoreCase(HttpPost.METHOD_NAME);
    case HttpStatus.SC_SEE_OTHER:
        return true;
    default:
        return false;
    }
}

From source file:spaceRedirectStrategy.java

public boolean isRedirected(final HttpRequest request, final HttpResponse response, final HttpContext context)
        throws ProtocolException {
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }/* w  w  w.ja  v  a  2 s.  c o m*/

    int statusCode = response.getStatusLine().getStatusCode();
    String method = request.getRequestLine().getMethod();
    Header locationHeader = response.getFirstHeader("location");
    switch (statusCode) {
    case HttpStatus.SC_MOVED_TEMPORARILY:
        return (method.equalsIgnoreCase(HttpGet.METHOD_NAME) || method.equalsIgnoreCase(HttpHead.METHOD_NAME))
                && locationHeader != null;
    case HttpStatus.SC_MOVED_PERMANENTLY:
    case HttpStatus.SC_TEMPORARY_REDIRECT:
        return method.equalsIgnoreCase(HttpGet.METHOD_NAME) || method.equalsIgnoreCase(HttpHead.METHOD_NAME);
    case HttpStatus.SC_SEE_OTHER:
        return true;
    default:
        return false;
    } //end of switch
}