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

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

Introduction

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

Prototype

String METHOD_NAME

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

Click Source Link

Usage

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.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 w w  . j  a v  a  2  s  .  c om
        return new HttpGet(uri);
    }
}

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.googlecode.webutilities.servlets.WebProxyServlet.java

@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    if (HttpOptions.METHOD_NAME.equals(req.getMethod())) {
        resp.setStatus(200);//from   w  w w.j av  a  2 s .  co m
        this.responseHeadersToInject.forEach(resp::setHeader);
        LOGGER.debug("Sending headers headers with status 200");
        return;
    }

    try {
        this.makeProxyRequest(req, resp);
    } catch (IOException ioe) {
        LOGGER.error("Failed to make proxy request", ioe);
        resp.setStatus(404); // Return 404
    }
}

From source file:org.camunda.connect.httpclient.impl.AbstractHttpRequest.java

public Q options() {
    return method(HttpOptions.METHOD_NAME);
}

From source file:org.camunda.connect.httpclient.impl.AbstractHttpConnector.java

@SuppressWarnings("unchecked")
protected <T extends HttpRequestBase> T createHttpRequestBase(Q request) {
    String url = request.getUrl();
    if (url != null && !url.trim().isEmpty()) {
        String method = request.getMethod();
        if (HttpGet.METHOD_NAME.equals(method)) {
            return (T) new HttpGet(url);
        } else if (HttpPost.METHOD_NAME.equals(method)) {
            return (T) new HttpPost(url);
        } else if (HttpPut.METHOD_NAME.equals(method)) {
            return (T) new HttpPut(url);
        } else if (HttpDelete.METHOD_NAME.equals(method)) {
            return (T) new HttpDelete(url);
        } else if (HttpPatch.METHOD_NAME.equals(method)) {
            return (T) new HttpPatch(url);
        } else if (HttpHead.METHOD_NAME.equals(method)) {
            return (T) new HttpHead(url);
        } else if (HttpOptions.METHOD_NAME.equals(method)) {
            return (T) new HttpOptions(url);
        } else if (HttpTrace.METHOD_NAME.equals(method)) {
            return (T) new HttpTrace(url);
        } else {//  w w  w.  j av  a  2  s  . co  m
            throw LOG.unknownHttpMethod(method);
        }
    } else {
        throw LOG.requestUrlRequired();
    }
}

From source file:com.googlecode.webutilities.servlets.WebProxyServlet.java

private HttpUriRequest getRequest(String method, String url) {
    if (HttpPost.METHOD_NAME.equals(method)) {
        return new HttpPost(url);
    } else if (HttpPut.METHOD_NAME.equals(method)) {
        return new HttpPut(url);
    } else if (HttpDelete.METHOD_NAME.equals(method)) {
        return new HttpDelete(url);
    } else if (HttpOptions.METHOD_NAME.equals(method)) {
        return new HttpOptions(url);
    } else if (HttpHead.METHOD_NAME.equals(method)) {
        return new HttpHead(url);
    }/* w  w w .  j  a v  a2 s  . c  o  m*/
    return new HttpGet(url);
}

From source file:code.google.restclient.core.Hitter.java

/**
 * Method to make POST or PUT request by sending http entity (as body)
 *///  w w  w  .  j  a  v  a  2  s.co  m
public void hit(String url, String methodName, HttpHandler handler, Map<String, String> requestHeaders)
        throws Exception {

    if (DEBUG_ENABLED)
        LOG.debug("hit() - method => " + methodName + ", url => " + url);

    if (HttpGet.METHOD_NAME.equals(methodName)) {
        if (DEBUG_ENABLED)
            LOG.debug("hit() - ===> GET " + url);
        hit(url, new HttpGet(url), handler, requestHeaders);
    } else if (HttpHead.METHOD_NAME.equals(methodName)) {
        if (DEBUG_ENABLED)
            LOG.debug("hit() - ===> HEAD " + url);
        hit(url, new HttpHead(url), handler, requestHeaders);
    } else if (HttpDelete.METHOD_NAME.equals(methodName)) {
        if (DEBUG_ENABLED)
            LOG.debug("hit() - ===> DELETE " + url);
        hit(url, new HttpDelete(url), handler, requestHeaders);
    } else if (HttpOptions.METHOD_NAME.equals(methodName)) {
        if (DEBUG_ENABLED)
            LOG.debug("hit() - ===> OPTIONS " + url);
        hit(url, new HttpOptions(url), handler, requestHeaders);
    } else if (HttpTrace.METHOD_NAME.equals(methodName)) {
        if (DEBUG_ENABLED)
            LOG.debug("hit() - ===> TRACE " + url);
        hit(url, new HttpTrace(url), handler, requestHeaders);
    } else if (HttpPost.METHOD_NAME.equals(methodName)) { // POST
        if (DEBUG_ENABLED)
            LOG.debug("hit() - ===> POST " + url);
        HttpPost httpPost = new HttpPost(url);
        httpPost.setEntity(handler.getReqBodyEntity());
        hit(url, httpPost, handler, requestHeaders);
    } else if (HttpPut.METHOD_NAME.equals(methodName)) { // PUT
        if (DEBUG_ENABLED)
            LOG.debug("hit() - ===> PUT " + url);
        HttpPut httpPut = new HttpPut(url);
        httpPut.setEntity(handler.getReqBodyEntity());
        hit(url, httpPut, handler, requestHeaders);
    } else {
        throw new IllegalArgumentException("hit(): Unsupported method => " + methodName);
    }
}

From source file:org.jboss.as.test.integration.security.perimeter.WebConsoleSecurityTestCase.java

@Test
public void testOptions() throws Exception {
    getConnection().setRequestMethod(HttpOptions.METHOD_NAME);
    getConnection().connect();/*from  w w w . jav  a2s  .  c  o  m*/
    assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, getConnection().getResponseCode());
}

From source file:com.mirth.connect.client.core.ServerConnection.java

private HttpRequestBase createRequestBase(String method) {
    HttpRequestBase requestBase = null;/*from  w w w.  j  a v  a 2 s .  co  m*/

    if (StringUtils.equalsIgnoreCase(HttpGet.METHOD_NAME, method)) {
        requestBase = new HttpGet();
    } else if (StringUtils.equalsIgnoreCase(HttpPost.METHOD_NAME, method)) {
        requestBase = new HttpPost();
    } else if (StringUtils.equalsIgnoreCase(HttpPut.METHOD_NAME, method)) {
        requestBase = new HttpPut();
    } else if (StringUtils.equalsIgnoreCase(HttpDelete.METHOD_NAME, method)) {
        requestBase = new HttpDelete();
    } else if (StringUtils.equalsIgnoreCase(HttpOptions.METHOD_NAME, method)) {
        requestBase = new HttpOptions();
    } else if (StringUtils.equalsIgnoreCase(HttpPatch.METHOD_NAME, method)) {
        requestBase = new HttpPatch();
    }

    requestBase.setConfig(requestConfig);
    return requestBase;
}