Java 类org.apache.http.client.methods.HttpOptions 实例源码

项目:aws-sdk-java-v2    文件:ApacheHttpRequestFactory.java   
private HttpRequestBase createApacheRequest(SdkHttpFullRequest request, String uri) {
    switch (request.method()) {
        case HEAD:
            return new HttpHead(uri);
        case GET:
            return new HttpGet(uri);
        case DELETE:
            return new HttpDelete(uri);
        case OPTIONS:
            return new HttpOptions(uri);
        case PATCH:
            return wrapEntity(request, new HttpPatch(uri));
        case POST:
            return wrapEntity(request, new HttpPost(uri));
        case PUT:
            return wrapEntity(request, new HttpPut(uri));
        default:
            throw new RuntimeException("Unknown HTTP method name: " + request.method());
    }
}
项目:elasticsearch_my    文件:RestClient.java   
private static HttpRequestBase createHttpRequest(String method, URI uri, HttpEntity entity) {
    switch(method.toUpperCase(Locale.ROOT)) {
        case HttpDeleteWithEntity.METHOD_NAME:
            return addRequestBody(new HttpDeleteWithEntity(uri), entity);
        case HttpGetWithEntity.METHOD_NAME:
            return addRequestBody(new HttpGetWithEntity(uri), entity);
        case HttpHead.METHOD_NAME:
            return addRequestBody(new HttpHead(uri), entity);
        case HttpOptions.METHOD_NAME:
            return addRequestBody(new HttpOptions(uri), entity);
        case HttpPatch.METHOD_NAME:
            return addRequestBody(new HttpPatch(uri), entity);
        case HttpPost.METHOD_NAME:
            HttpPost httpPost = new HttpPost(uri);
            addRequestBody(httpPost, entity);
            return httpPost;
        case HttpPut.METHOD_NAME:
            return addRequestBody(new HttpPut(uri), entity);
        case HttpTrace.METHOD_NAME:
            return addRequestBody(new HttpTrace(uri), entity);
        default:
            throw new UnsupportedOperationException("http method not supported: " + method);
    }
}
项目:elasticsearch_my    文件:RequestLoggerTests.java   
private static HttpUriRequest randomHttpRequest(URI uri) {
    int requestType = randomIntBetween(0, 7);
    switch(requestType) {
        case 0:
            return new HttpGetWithEntity(uri);
        case 1:
            return new HttpPost(uri);
        case 2:
            return new HttpPut(uri);
        case 3:
            return new HttpDeleteWithEntity(uri);
        case 4:
            return new HttpHead(uri);
        case 5:
            return new HttpTrace(uri);
        case 6:
            return new HttpOptions(uri);
        case 7:
            return new HttpPatch(uri);
        default:
            throw new UnsupportedOperationException();
    }
}
项目:lams    文件:HttpComponentsClientHttpRequestFactory.java   
/**
 * Create a Commons HttpMethodBase object for the given HTTP method and URI specification.
 * @param httpMethod the HTTP method
 * @param uri the URI
 * @return the Commons HttpMethodBase object
 */
protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) {
    switch (httpMethod) {
        case GET:
            return new HttpGet(uri);
        case DELETE:
            return new HttpDelete(uri);
        case HEAD:
            return new HttpHead(uri);
        case OPTIONS:
            return new HttpOptions(uri);
        case POST:
            return new HttpPost(uri);
        case PUT:
            return new HttpPut(uri);
        case TRACE:
            return new HttpTrace(uri);
        case PATCH:
            return new HttpPatch(uri);
        default:
            throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
    }
}
项目:light-4j    文件:CorsHttpHandlerTest.java   
@Test
public void testOptionsWrongOrigin() throws Exception {
    String url = "http://localhost:8080";
    CloseableHttpClient client = HttpClients.createDefault();
    HttpOptions httpOptions = new HttpOptions(url);
    httpOptions.setHeader("Origin", "http://example.com");
    httpOptions.setHeader("Access-Control-Request-Method", "POST");
    httpOptions.setHeader("Access-Control-Request-Headers", "X-Requested-With");

    try {
        CloseableHttpResponse response = client.execute(httpOptions);
        int statusCode = response.getStatusLine().getStatusCode();
        String body = IOUtils.toString(response.getEntity().getContent(), "utf8");
        Header header = response.getFirstHeader("Access-Control-Allow-Origin");
        Assert.assertEquals(200, statusCode);
        if(statusCode == 200) {
            Assert.assertNull(header);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:light-4j    文件:CorsHttpHandlerTest.java   
@Test
public void testOptionsCorrectOrigin() throws Exception {
    String url = "http://localhost:8080";
    CloseableHttpClient client = HttpClients.createDefault();
    HttpOptions httpOptions = new HttpOptions(url);
    httpOptions.setHeader("Origin", "http://localhost");
    httpOptions.setHeader("Access-Control-Request-Method", "POST");
    httpOptions.setHeader("Access-Control-Request-Headers", "X-Requested-With");

    try {
        CloseableHttpResponse response = client.execute(httpOptions);
        int statusCode = response.getStatusLine().getStatusCode();
        String body = IOUtils.toString(response.getEntity().getContent(), "utf8");
        Header[] headers = response.getAllHeaders();
        Header header = response.getFirstHeader("Access-Control-Allow-Origin");
        Assert.assertEquals(200, statusCode);
        if(statusCode == 200) {
            Assert.assertNotNull(header);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:spring4-understanding    文件:HttpComponentsClientHttpRequestFactory.java   
/**
 * Create a Commons HttpMethodBase object for the given HTTP method and URI specification.
 * @param httpMethod the HTTP method
 * @param uri the URI
 * @return the Commons HttpMethodBase object
 */
protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) {
    switch (httpMethod) {
        case GET:
            return new HttpGet(uri);
        case HEAD:
            return new HttpHead(uri);
        case POST:
            return new HttpPost(uri);
        case PUT:
            return new HttpPut(uri);
        case PATCH:
            return new HttpPatch(uri);
        case DELETE:
            return new HttpDelete(uri);
        case OPTIONS:
            return new HttpOptions(uri);
        case TRACE:
            return new HttpTrace(uri);
        default:
            throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
    }
}
项目:AuxiliumLib    文件:MattpRequestEnvoy.java   
private HttpUriRequest getRawMethodRequest()
{
    AbstractURL url = request.getUrl();

    switch(request.getMattpMethod())
    {
        case GET:
            return new HttpGet(url.toString());
        case HEAD:
            return new HttpHead(url.toString());
        case POST:
            return new HttpPost(url.toString());
        case PUT:
            return new HttpPut(url.toString());
        case DELETE:
            return new HttpDelete(url.toString());
        case TRACE:
            return new HttpTrace(url.toString());
        case OPTIONS:
            return new HttpOptions(url.toString());
        case PATCH:
            return new HttpPatch(url.toString());
    }

    throw new ShouldNeverHappenError();
}
项目:AuxiliumLib    文件:HttpFetch.java   
private HttpUriRequest getRequest(AbstractURL url)
{
    switch(this)
    {
        case GET:
            return new HttpGet(url.toString());
        case HEAD:
            return new HttpHead(url.toString());
        case POST:
            return new HttpPost(url.toString());
        case PUT:
            return new HttpPut(url.toString());
        case DELETE:
            return new HttpDelete(url.toString());
        case TRACE:
            return new HttpTrace(url.toString());
        case OPTIONS:
            return new HttpOptions(url.toString());
        case PATCH:
            return new HttpPatch(url.toString());
    }

    throw new ShouldNeverHappenError();
}
项目:cibet    文件:HttpSpringSecurity2IT.java   
@Test
public void testDeny2Man() throws Exception {
   log.info("start testDeny2Man()");

   HttpGet method = new HttpGet(
         getBaseURL() + "/test/spring/loginSpring?USER=Fred&ROLE=adminXXX" + "&TENANT=" + TENANT);
   HttpResponse response = client.execute(method);
   method.abort();
   Thread.sleep(20);

   log.debug("now the test");
   HttpOptions g = new HttpOptions(URL_TS + "?role=" + URLEncoder.encode("adminXXXX", "UTF-8"));
   response = client.execute(g);
   Assert.assertEquals(HttpStatus.SC_FORBIDDEN, response.getStatusLine().getStatusCode());
   readResponseBody(response);
   g.abort();
}
项目:cibet    文件:HttpSpringSecurity2IT.java   
@Test
public void testDeny2Man2() throws Exception {
   log.info("start testDeny2Man2()");
   HttpGet method = new HttpGet(
         getBaseURL() + "/test/spring/loginSpring?USER=Fred&secondUser=NULL&ROLE=admin" + "&TENANT=" + TENANT);
   HttpResponse response = client.execute(method);
   method.abort();

   Thread.sleep(20);
   log.debug("now the test");
   HttpOptions g = new HttpOptions(URL_TS + "?role=" + URLEncoder.encode("admin", "UTF-8") + "&secondUser="
         + URLEncoder.encode("NULL", "UTF-8"));
   response = client.execute(g);
   Assert.assertEquals(HttpStatus.SC_ACCEPTED, response.getStatusLine().getStatusCode());
   readResponseBody(response);
   g.abort();
}
项目:cibet    文件:HttpSpringSecurity2IT.java   
@Test
public void testDeny2Man3() throws Exception {
   log.info("start testDeny2Man3()");
   HttpGet method = new HttpGet(getBaseURL()
         + "/test/spring/loginSpring?secondUser=hall&USER=Fred&secondRole=NULL&ROLE=admin" + "&TENANT=" + TENANT);
   HttpResponse response = client.execute(method);
   method.abort();
   Thread.sleep(20);

   log.debug("now the test");
   HttpOptions g = new HttpOptions(URL_TS + "?role=" + URLEncoder.encode("admin", "UTF-8") + "&secondUser="
         + URLEncoder.encode("hall", "UTF-8") + "&secondRole=" + URLEncoder.encode("NULL", "UTF-8"));
   response = client.execute(g);
   Assert.assertEquals(HttpStatus.SC_ACCEPTED, response.getStatusLine().getStatusCode());
   readResponseBody(response);
   String erString = response.getFirstHeader(Headers.CIBET_EVENTRESULT.name()).getValue();
   EventResult er = CibetUtil.decodeEventResult(erString);
   log.debug("#### EventResult: " + er);
   Assert.assertEquals(ExecutionStatus.POSTPONED, er.getExecutionStatus());
   Assert.assertEquals(ExecutionStatus.DENIED, er.getChildResults().get(0).getExecutionStatus());
   g.abort();
}
项目:cibet    文件:HttpSpringSecurity2IT.java   
@Test
public void testDeny2Man4() throws Exception {
   log.info("start testDeny2Man4()");
   HttpGet method = new HttpGet(getBaseURL()
         + "/test/spring/loginSpring?secondUser=hil&secondRole=sssss&USER=Fred&ROLE=admin" + "&TENANT=" + TENANT);
   HttpResponse response = client.execute(method);
   method.abort();
   Thread.sleep(20);

   log.debug("now the test");
   HttpOptions g = new HttpOptions(URL_TS + "?role=" + URLEncoder.encode("admin", "UTF-8") + "&secondUser="
         + URLEncoder.encode("höl", "UTF-8") + "&secondRole=" + URLEncoder.encode("ssssssss", "UTF-8"));
   response = client.execute(g);
   Assert.assertEquals(HttpStatus.SC_ACCEPTED, response.getStatusLine().getStatusCode());
   readResponseBody(response);
   String erString = response.getFirstHeader(Headers.CIBET_EVENTRESULT.name()).getValue();
   EventResult er = CibetUtil.decodeEventResult(erString);
   Assert.assertEquals(ExecutionStatus.POSTPONED, er.getExecutionStatus());
   Assert.assertEquals(ExecutionStatus.DENIED, er.getChildResults().get(0).getExecutionStatus());

   g.abort();
}
项目:cibet    文件:HttpSpringSecurity2IT.java   
@Test
public void testGrant2Man() throws Exception {
   log.info("start testGrant2Man()");
   HttpGet method = new HttpGet(getBaseURL()
         + "/test/spring/loginSpring?USER=Fred&secondUser=hil&secondRole=second&ROLE=admin" + "&TENANT=" + TENANT);
   HttpResponse response = client.execute(method);
   method.abort();
   Thread.sleep(20);

   log.debug("now the test");
   HttpOptions g = new HttpOptions(URL_TS + "?role=" + URLEncoder.encode("admin", "UTF-8") + "&secondUser="
         + URLEncoder.encode("höl", "UTF-8") + "&secondRole=" + URLEncoder.encode("second", "UTF-8"));
   response = client.execute(g);
   Assert.assertEquals(HttpStatus.SC_ACCEPTED, response.getStatusLine().getStatusCode());
   readResponseBody(response);
   String erString = response.getFirstHeader(Headers.CIBET_EVENTRESULT.name()).getValue();
   EventResult er = CibetUtil.decodeEventResult(erString);
   Assert.assertEquals(ExecutionStatus.POSTPONED, er.getExecutionStatus());
   Assert.assertEquals(ExecutionStatus.EXECUTED, er.getChildResults().get(0).getExecutionStatus());

   g.abort();
}
项目:vespa    文件:JDiscHttpServletTest.java   
@Test
public void requireThatServerRespondsToAllMethods() throws Exception {
    final TestDriver driver = TestDrivers.newInstance(newEchoHandler());
    final URI uri = driver.client().newUri("/status.html");
    driver.client().execute(new HttpGet(uri))
          .expectStatusCode(is(OK));
    driver.client().execute(new HttpPost(uri))
          .expectStatusCode(is(OK));
    driver.client().execute(new HttpHead(uri))
          .expectStatusCode(is(OK));
    driver.client().execute(new HttpPut(uri))
          .expectStatusCode(is(OK));
    driver.client().execute(new HttpDelete(uri))
          .expectStatusCode(is(OK));
    driver.client().execute(new HttpOptions(uri))
          .expectStatusCode(is(OK));
    driver.client().execute(new HttpTrace(uri))
          .expectStatusCode(is(OK));
    driver.client().execute(new HttpPatch(uri))
            .expectStatusCode(is(OK));
    assertThat(driver.close(), is(true));
}
项目:fahrschein    文件:HttpComponentsRequestFactory.java   
/**
 * Create a Commons HttpMethodBase object for the given HTTP method and URI specification.
 * @param method the HTTP method
 * @param uri the URI
 * @return the Commons HttpMethodBase object
 */
private static HttpUriRequest createHttpUriRequest(String method, URI uri) {
    switch (method) {
        case "GET":
            return new HttpGet(uri);
        case "HEAD":
            return new HttpHead(uri);
        case "POST":
            return new HttpPost(uri);
        case "PUT":
            return new HttpPut(uri);
        case "PATCH":
            return new HttpPatch(uri);
        case "DELETE":
            return new HttpDelete(uri);
        case "OPTIONS":
            return new HttpOptions(uri);
        case "TRACE":
            return new HttpTrace(uri);
        default:
            throw new IllegalArgumentException("Invalid HTTP method: " + method);
    }
}
项目:here-aaa-java-sdk    文件:ApacheHttpClientProviderTest.java   
@Test
public void test_methods() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException {
    verifyApacheType("GET", HttpGet.class);
    verifyApacheType("POST", HttpPost.class);
    verifyApacheType("PUT", HttpPut.class);
    verifyApacheType("DELETE", HttpDelete.class);
    verifyApacheType("HEAD", HttpHead.class);
    verifyApacheType("OPTIONS", HttpOptions.class);
    verifyApacheType("TRACE", HttpTrace.class);
    verifyApacheType("PATCH", HttpPatch.class);
    try {
        verifyApacheType("BROKENMETHOD", null);
        fail("BROKENMETHOD should have thrown IllegalArgumentException, but didn't");
    } catch (IllegalArgumentException e) {
        // expected
        String message = e.getMessage();
        String expectedContains = "no support for request method=BROKENMETHOD";
        assertTrue("expected contains "+expectedContains+", actual "+message, message.contains(expectedContains));
    }
}
项目:oreva    文件:ODataCxfClient.java   
private HttpUriRequest getRequestByMethod(String method, URI uri) {
  switch (ODataHttpMethod.fromString(method)) {
  case GET:
    return new HttpGet(uri);
  case PUT:
    return new HttpPut(uri);
  case POST:
    return new HttpPost(uri);
  case DELETE:
    return new HttpDelete(uri);
  case OPTIONS:
    return new HttpOptions(uri);
  case HEAD:
    return new HttpHead(uri);
  default:
    throw new RuntimeException("Method unknown: " + method);
  }
}
项目:ShoppingMall    文件:HttpComponentsClientHttpRequestFactory.java   
/**
 * Create a HttpComponents HttpUriRequest object for the given HTTP method and URI specification.
 * 
 * @param httpMethod the HTTP method
 * @param uri the URI
 * @return the HttpComponents HttpUriRequest object
 */
protected HttpUriRequest createHttpRequest(HttpMethod httpMethod, URI uri) {
    switch (httpMethod) {
        case GET:
            return new HttpGet(uri);
        case DELETE:
            return new HttpDelete(uri);
        case HEAD:
            return new HttpHead(uri);
        case OPTIONS:
            return new HttpOptions(uri);
        case POST:
            return new HttpPost(uri);
        case PUT:
            return new HttpPut(uri);
        case TRACE:
            return new HttpTrace(uri);
        default:
            throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
    }
}
项目:ShoppingMall    文件:HttpComponentsClientHttpRequestFactory.java   
/**
 * Create a HttpComponents HttpUriRequest object for the given HTTP method and URI specification.
 * 
 * @param httpMethod
 *            the HTTP method
 * @param uri
 *            the URI
 * @return the HttpComponents HttpUriRequest object
 */
protected HttpUriRequest createHttpRequest(HttpMethod httpMethod, URI uri) {
    switch (httpMethod) {
    case GET:
        return new HttpGet(uri);
    case DELETE:
        return new HttpDelete(uri);
    case HEAD:
        return new HttpHead(uri);
    case OPTIONS:
        return new HttpOptions(uri);
    case POST:
        return new HttpPost(uri);
    case PUT:
        return new HttpPut(uri);
    case TRACE:
        return new HttpTrace(uri);
    default:
        throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
    }
}
项目:crestj    文件:CrestClient.java   
public Future<EveData> getOptions(CrestRequestData requestData, ClientElement client)
{
    String accessToken = null;
    if (requestData.clientInfo != null)
        accessToken = ((OAuth2AccessToken) requestData.clientInfo.getAccessToken()).getAccessToken();
    HttpOptions get = new HttpOptions(requestData.url);
    if (accessToken != null)
    {
        get.addHeader("Authorization", "Bearer " + accessToken);
        if (requestData.scope != null)
            get.addHeader("Scope", requestData.scope);
    }
    if (requestData.version != null)
        get.addHeader("Accept", requestData.version);
    return executor.submit(new CrestGetTask(client, get, requestData));
}
项目:openbd-core    文件:cfHttpConnection.java   
private HttpUriRequest resolveMethod( String _method, boolean _multipart ) throws cfmRunTimeException {
    String method = _method.toUpperCase();
    if ( method.equals( "GET" ) ) {
        return new HttpGet();
    } else if ( method.equals( "POST" ) ) {
        return new HttpPost();
    } else if ( method.equals( "HEAD" ) ) {
        return new HttpHead();
    } else if ( method.equals( "TRACE" ) ) {
        return new HttpTrace();
    } else if ( method.equals( "DELETE" ) ) {
        return new HttpDelete();
    } else if ( method.equals( "OPTIONS" ) ) {
        return new HttpOptions();
    } else if ( method.equals( "PUT" ) ) {
        return new HttpPut();
    }
    throw newRunTimeException( "Unsupported METHOD value [" + method + "]. Valid METHOD values are GET, POST, HEAD, TRACE, DELETE, OPTIONS and PUT." );
}
项目:detective    文件:HttpClientTask.java   
/**
 * Create a Commons HttpMethodBase object for the given HTTP method and URI specification.
 * @param httpMethod the HTTP method
 * @param uri the URI
 * @return the Commons HttpMethodBase object
 */
protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) {
  switch (httpMethod) {
    case GET:
      return new HttpGet(uri);
    case DELETE:
      return new HttpDeleteWithBody(uri);
    case HEAD:
      return new HttpHead(uri);
    case OPTIONS:
      return new HttpOptions(uri);
    case POST:
      return new HttpPost(uri);
    case PUT:
      return new HttpPut(uri);
    case TRACE:
      return new HttpTrace(uri);
    case PATCH:
      return new HttpPatch(uri);
    default:
      throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
  }
}
项目:class-guard    文件:HttpComponentsClientHttpRequestFactory.java   
/**
 * Create a Commons HttpMethodBase object for the given HTTP method and URI specification.
 * @param httpMethod the HTTP method
 * @param uri the URI
 * @return the Commons HttpMethodBase object
 */
protected HttpUriRequest createHttpUriRequest(HttpMethod httpMethod, URI uri) {
    switch (httpMethod) {
        case GET:
            return new HttpGet(uri);
        case DELETE:
            return new HttpDelete(uri);
        case HEAD:
            return new HttpHead(uri);
        case OPTIONS:
            return new HttpOptions(uri);
        case POST:
            return new HttpPost(uri);
        case PUT:
            return new HttpPut(uri);
        case TRACE:
            return new HttpTrace(uri);
        case PATCH:
            return new HttpPatch(uri);
        default:
            throw new IllegalArgumentException("Invalid HTTP method: " + httpMethod);
    }
}
项目:camunda-connect    文件: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);
}
项目:workspace_deluxe    文件:DocServerTest.java   
@Test
public void options() throws Exception {
    CloseableHttpResponse res = getClient().execute(
            new HttpOptions(docURL + ""));
    assertThat("correct access origin header",
            res.getFirstHeader("Access-Control-Allow-Origin").getValue(),
            is("*"));
    assertThat("correct access headers header",
            res.getFirstHeader("Access-Control-Allow-Headers").getValue(),
            is("authorization"));
    assertThat("correct content type",
            res.getFirstHeader("Content-Type").getValue(),
            is("application/json"));
    assertThat("correct content length",
            res.getFirstHeader("Content-Length").getValue(), is("0"));
    checkResponse(res, 200, "");
}
项目:pdi-platform-utils-plugin    文件:HttpConnectionHelper.java   
protected HttpRequestBase getHttpMethod( String url, List<HttpParameter> httpParameters, String httpMethod ) {
  Http method = Http.getHttpMethod( httpMethod );

  switch ( method ) {
    case GET:
      return new HttpGet( url + constructQueryString( httpParameters, false ) );
    case POST:
      HttpPost  postMethod = new HttpPost( url + constructQueryString( httpParameters, false, HttpParameter.ParamType.QUERY ) );
      setRequestEntity( postMethod, httpParameters, HttpParameter.ParamType.BODY, HttpParameter.ParamType.NONE );
      return postMethod;
    case PUT:
      HttpPut putMethod = new HttpPut( url + constructQueryString( httpParameters, false, HttpParameter.ParamType.QUERY ) );
      setRequestEntity( putMethod, httpParameters, HttpParameter.ParamType.BODY, HttpParameter.ParamType.NONE );
      return putMethod;
    case DELETE:
      return new HttpDelete( url + constructQueryString( httpParameters, false ) );
    case HEAD:
      return new HttpHead( url + constructQueryString( httpParameters, false ) );
    case OPTIONS:
      return new HttpOptions( url + constructQueryString( httpParameters, false ) );
    default:
      return new HttpGet( url + constructQueryString( httpParameters, false ) );
  }
}
项目:ZombieLink    文件:RequestUtils.java   
/**
 * <p>Retrieves the proper extension of {@link HttpRequestBase} for the given {@link InvocationContext}. 
 * This implementation is solely dependent upon the {@link RequestMethod} property in the annotated 
 * metdata of the endpoint method definition.</p>
 *
 * @param context
 *          the {@link InvocationContext} for which a {@link HttpRequestBase} is to be generated 
 * <br><br>
 * @return the {@link HttpRequestBase} translated from the {@link InvocationContext}'s {@link RequestMethod}
 * <br><br>
 * @throws NullPointerException
 *          if the supplied {@link InvocationContext} was {@code null} 
 * <br><br>
 * @since 1.3.0
 */
static HttpRequestBase translateRequestMethod(InvocationContext context) {

    RequestMethod requestMethod = Metadata.findMethod(assertNotNull(context).getRequest());

    switch (requestMethod) {

        case POST: return new HttpPost();
        case PUT: return new HttpPut();
        case PATCH: return new HttpPatch();
        case DELETE: return new HttpDelete();
        case HEAD: return new HttpHead();
        case TRACE: return new HttpTrace();
        case OPTIONS: return new HttpOptions();

        case GET: default: return new HttpGet();
    }
}
项目:RoboZombie    文件:RequestUtils.java   
/**
 * <p>Retrieves the proper extension of {@link HttpRequestBase} for the given {@link InvocationContext}. 
 * This implementation is solely dependent upon the {@link RequestMethod} property in the annotated 
 * metdata of the endpoint method definition.</p>
 *
 * @param context
 *          the {@link InvocationContext} for which a {@link HttpRequestBase} is to be generated 
 * <br><br>
 * @return the {@link HttpRequestBase} translated from the {@link InvocationContext}'s {@link RequestMethod}
 * <br><br>
 * @throws NullPointerException
 *          if the supplied {@link InvocationContext} was {@code null} 
 * <br><br>
 * @since 1.3.0
 */
static HttpRequestBase translateRequestMethod(InvocationContext context) {

    RequestMethod requestMethod = Metadata.findMethod(assertNotNull(context).getRequest());

    switch (requestMethod) {

        case POST: return new HttpPost();
        case PUT: return new HttpPut();
        case PATCH: return new HttpPatch();
        case DELETE: return new HttpDelete();
        case HEAD: return new HttpHead();
        case TRACE: return new HttpTrace();
        case OPTIONS: return new HttpOptions();

        case GET: default: return new HttpGet();
    }
}
项目:box-java-sdk-v2    文件:DefaultBoxRequest.java   
/**
 * Construct raw request. Currently only support GET/PUT/POST/DELETE.
 * 
 * @return raw request
 * @throws BoxRestException
 *             exception
 */
HttpRequestBase constructHttpUriRequest() throws BoxRestException {
    switch (getRestMethod()) {
        case GET:
            return new HttpGet();
        case PUT:
            return new HttpPut();
        case POST:
            return new HttpPost();
        case DELETE:
            return new HttpDelete();
        case OPTIONS:
            return new HttpOptions();
        default:
            throw new BoxRestException("Method Not Implemented");
    }
}
项目:GitHub    文件:HttpClientStackTest.java   
@Test public void createOptionsRequest() throws Exception {
    TestRequest.Options request = new TestRequest.Options();
    assertEquals(request.getMethod(), Method.OPTIONS);

    HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
    assertTrue(httpRequest instanceof HttpOptions);
}
项目:GitHub    文件:HttpClientStackTest.java   
@Test public void createOptionsRequest() throws Exception {
    TestRequest.Options request = new TestRequest.Options();
    assertEquals(request.getMethod(), Method.OPTIONS);

    HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
    assertTrue(httpRequest instanceof HttpOptions);
}
项目:Codeforces    文件:HttpClientStackTest.java   
@Test public void createOptionsRequest() throws Exception {
    TestRequest.Options request = new TestRequest.Options();
    assertEquals(request.getMethod(), Method.OPTIONS);

    HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
    assertTrue(httpRequest instanceof HttpOptions);
}
项目:HttpClientMock    文件:HttpClientVerifyTest.java   
@Test
public void shouldHandleAllHttpMethods() throws IOException {

    HttpClientMock httpClientMock = new HttpClientMock();

    httpClientMock.execute(new HttpGet("http://localhost"));
    httpClientMock.execute(new HttpPost("http://localhost"));
    httpClientMock.execute(new HttpDelete("http://localhost"));
    httpClientMock.execute(new HttpPut("http://localhost"));
    httpClientMock.execute(new HttpHead("http://localhost"));
    httpClientMock.execute(new HttpOptions("http://localhost"));
    httpClientMock.execute(new HttpPatch("http://localhost"));

    httpClientMock.verify()
            .get("http://localhost")
            .called();
    httpClientMock.verify()
            .post("http://localhost")
            .called();
    httpClientMock.verify()
            .delete("http://localhost")
            .called();
    httpClientMock.verify()
            .put("http://localhost")
            .called();
    httpClientMock.verify()
            .options("http://localhost")
            .called();
    httpClientMock.verify()
            .head("http://localhost")
            .called();
    httpClientMock.verify()
            .patch("http://localhost")
            .called();
}
项目:HttpClientMock    文件:HttpClientMockBuilderTest.java   
@Test
public void shouldUseRightMethod() throws IOException {
    HttpClientMock httpClientMock = new HttpClientMock("http://localhost");

    httpClientMock.onGet("/foo").doReturn("get");
    httpClientMock.onPost("/foo").doReturn("post");
    httpClientMock.onPut("/foo").doReturn("put");
    httpClientMock.onDelete("/foo").doReturn("delete");
    httpClientMock.onHead("/foo").doReturn("head");
    httpClientMock.onOptions("/foo").doReturn("options");
    httpClientMock.onPatch("/foo").doReturn("patch");

    HttpResponse getResponse = httpClientMock.execute(new HttpGet("http://localhost/foo"));
    HttpResponse postResponse = httpClientMock.execute(new HttpPost("http://localhost/foo"));
    HttpResponse putResponse = httpClientMock.execute(new HttpPut("http://localhost/foo"));
    HttpResponse deleteResponse = httpClientMock.execute(new HttpDelete("http://localhost/foo"));
    HttpResponse headResponse = httpClientMock.execute(new HttpHead("http://localhost/foo"));
    HttpResponse optionsResponse = httpClientMock.execute(new HttpOptions("http://localhost/foo"));
    HttpResponse patchResponse = httpClientMock.execute(new HttpPatch("http://localhost/foo"));

    assertThat(getResponse, hasContent("get"));
    assertThat(postResponse, hasContent("post"));
    assertThat(putResponse, hasContent("put"));
    assertThat(deleteResponse, hasContent("delete"));
    assertThat(headResponse, hasContent("head"));
    assertThat(optionsResponse, hasContent("options"));
    assertThat(patchResponse, hasContent("patch"));
}
项目:iosched-reader    文件:HttpClientStackTest.java   
public void testCreateOptionsRequest() throws Exception {
    TestRequest.Options request = new TestRequest.Options();
    assertEquals(request.getMethod(), Method.OPTIONS);

    HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
    assertTrue(httpRequest instanceof HttpOptions);
}
项目:ibm-cos-sdk-java    文件:ApacheHttpRequestFactory.java   
private HttpRequestBase createApacheRequest(Request<?> request, String uri, String encodedParams) throws FakeIOException {
    switch (request.getHttpMethod()) {
        case HEAD:
            return new HttpHead(uri);
        case GET:
            return new HttpGet(uri);
        case DELETE:
            return new HttpDelete(uri);
        case OPTIONS:
            return new HttpOptions(uri);
        case PATCH:
            return wrapEntity(request, new HttpPatch(uri), encodedParams);
        case POST:
            return wrapEntity(request, new HttpPost(uri), encodedParams);
        case PUT:
            return wrapEntity(request, new HttpPut(uri), encodedParams);
        default:
            throw new SdkClientException("Unknown HTTP method name: " + request.getHttpMethod());
    }
}
项目:VoV    文件:HttpClientStackTest.java   
@Test public void createOptionsRequest() throws Exception {
    TestRequest.Options request = new TestRequest.Options();
    assertEquals(request.getMethod(), Method.OPTIONS);

    HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
    assertTrue(httpRequest instanceof HttpOptions);
}
项目:smconf-android    文件:HttpClientStackTest.java   
public void testCreateOptionsRequest() throws Exception {
    TestRequest.Options request = new TestRequest.Options();
    assertEquals(request.getMethod(), Method.OPTIONS);

    HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
    assertTrue(httpRequest instanceof HttpOptions);
}
项目:volley    文件:HttpClientStackTest.java   
@Test public void createOptionsRequest() throws Exception {
    TestRequest.Options request = new TestRequest.Options();
    assertEquals(request.getMethod(), Method.OPTIONS);

    HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
    assertTrue(httpRequest instanceof HttpOptions);
}