Example usage for org.apache.http.client.fluent Request Options

List of usage examples for org.apache.http.client.fluent Request Options

Introduction

In this page you can find the example usage for org.apache.http.client.fluent Request Options.

Prototype

public static Request Options(final String uri) 

Source Link

Usage

From source file:org.ow2.proactive.addons.webhook.service.ApacheHttpClientRequestGetter.java

public Request getHttpRequestByString(String method, String url) {
    switch (method) {
    case "GET":
        return Request.Get(url);
    case "POST":
        return Request.Post(url);
    case "HEAD":
        return Request.Head(url);
    case "PUT":
        return Request.Put(url);
    case "DELETE":
        return Request.Delete(url);
    case "OPTIONS":
        return Request.Options(url);
    case "TRACE":
        return Request.Trace(url);
    default://from   w  w  w .  j a  va 2 s .c  o  m
        throw new IllegalArgumentException(method + " is not supported as a rest method");
    }
}

From source file:org.debux.webmotion.server.tools.RequestBuilder.java

/**
 * @return a option request// w  w  w .j  a v a2 s  .  c  om
 */
public Request Options() throws URISyntaxException {
    return Request.Options(this.build());
}

From source file:org.mule.module.http.functional.listener.HttpListenerMethodRoutingTestCase.java

@Test
public void callWithMethod() throws Exception {
    final String url = String.format("http://localhost:%s/%s", listenPort.getNumber(), path.getValue());
    Request request = null;/*  ww w  .ja  va  2s.  c  o m*/
    switch (method) {
    case "GET":
        request = Request.Get(url);
        break;
    case "POST":
        request = Request.Post(url);
        break;
    case "OPTIONS":
        request = Request.Options(url);
        break;
    case "DELETE":
        request = Request.Delete(url);
        break;
    case "PUT":
        request = Request.Put(url);
        break;
    }
    final Response response = request.connectTimeout(1000).execute();
    final HttpResponse httpResponse = response.returnResponse();
    assertThat(httpResponse.getStatusLine().getStatusCode(), is(200));
    assertThat(IOUtils.toString(httpResponse.getEntity().getContent()), is(expectedContent));
}

From source file:com.google.gerrit.acceptance.rest.change.CorsIT.java

@Test
public void preflightOk() throws Exception {
    Result change = createChange();

    String origin = "http://example.com";
    Request req = Request.Options(adminRestSession.url() + "/a/changes/" + change.getChangeId() + "/detail");
    req.addHeader(ORIGIN, origin);//from   w ww .  j  a  v a  2 s . c o m
    req.addHeader(ACCESS_CONTROL_REQUEST_METHOD, "GET");
    req.addHeader(ACCESS_CONTROL_REQUEST_HEADERS, "X-Requested-With");

    RestResponse res = adminRestSession.execute(req);
    res.assertOK();
    checkCors(res, true, origin);
}

From source file:com.google.gerrit.acceptance.rest.change.CorsIT.java

@Test
public void preflightBadOrigin() throws Exception {
    Result change = createChange();

    Request req = Request.Options(adminRestSession.url() + "/a/changes/" + change.getChangeId() + "/detail");
    req.addHeader(ORIGIN, "http://evil.attacker");
    req.addHeader(ACCESS_CONTROL_REQUEST_METHOD, "GET");

    adminRestSession.execute(req).assertBadRequest();
}

From source file:com.google.gerrit.acceptance.rest.change.CorsIT.java

@Test
public void preflightBadMethod() throws Exception {
    Result change = createChange();

    for (String method : new String[] { "POST", "PUT", "DELETE", "PATCH" }) {
        Request req = Request
                .Options(adminRestSession.url() + "/a/changes/" + change.getChangeId() + "/detail");
        req.addHeader(ORIGIN, "http://example.com");
        req.addHeader(ACCESS_CONTROL_REQUEST_METHOD, method);
        adminRestSession.execute(req).assertBadRequest();
    }//from  ww w.j a  v  a2  s.  c  o  m
}

From source file:org.schedulesdirect.api.json.DefaultJsonRequest.java

private Request initRequest() {
    Request r = null;/*from  w  w w  .  j ava  2s  .  c  o  m*/
    switch (action) {
    case GET:
        r = Request.Get(baseUrl);
        break;
    case PUT:
        r = Request.Put(baseUrl);
        break;
    case POST:
        r = Request.Post(baseUrl);
        break;
    case DELETE:
        r = Request.Delete(baseUrl);
        break;
    case OPTIONS:
        r = Request.Options(baseUrl);
        break;
    case HEAD:
        r = Request.Head(baseUrl);
        break;
    }
    return r.userAgent(userAgent);
}

From source file:io.coala.capability.online.FluentHCOnlineCapability.java

/**
 * @param method/*from  ww  w  .  j av a 2  s  .co m*/
 * @param uri
 * @return
 */
@SuppressWarnings("rawtypes")
public static Request getFluentRequest(final HttpMethod method, final URI uri, final Map.Entry... formData) {
    final Request request;
    switch (method) {
    case GET:
        request = Request.Get(toFormDataURI(uri, formData));
        break;
    case HEAD:
        request = Request.Head(toFormDataURI(uri, formData));
        break;
    case POST:
        request = Request.Post(uri);
        break;
    case PUT:
        request = Request.Put(uri);
        break;
    case DELETE:
        request = Request.Delete(toFormDataURI(uri, formData));
        break;
    case OPTIONS:
        request = Request.Options(toFormDataURI(uri, formData));
        break;
    case TRACE:
        request = Request.Trace(toFormDataURI(uri, formData));
        break;
    default:
        throw new IllegalStateException("UNSUPPORTED: " + method);
    }
    return request.useExpectContinue().version(HttpVersion.HTTP_1_1);
}

From source file:com.google.gerrit.acceptance.rest.change.CorsIT.java

@Test
public void preflightBadHeader() throws Exception {
    Result change = createChange();

    Request req = Request.Options(adminRestSession.url() + "/a/changes/" + change.getChangeId() + "/detail");
    req.addHeader(ORIGIN, "http://example.com");
    req.addHeader(ACCESS_CONTROL_REQUEST_METHOD, "GET");
    req.addHeader(ACCESS_CONTROL_REQUEST_HEADERS, "X-Gerrit-Auth");

    adminRestSession.execute(req).assertBadRequest();
}

From source file:org.apache.james.jmap.methods.integration.cucumber.UploadStepdefs.java

@When("^\"([^\"]*)\" checks for the availability of the upload endpoint$")
public void optionUpload(String username) throws Throwable {
    AccessToken accessToken = userStepdefs.tokenByUser.get(username);
    Request request = Request.Options(uploadUri);
    if (accessToken != null) {
        request.addHeader("Authorization", accessToken.serialize());
    }/*  ww w .j  a  va 2s . co m*/
    response = request.execute().returnResponse();
}