當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpTrace類代碼示例

本文整理匯總了Java中org.apache.http.client.methods.HttpTrace的典型用法代碼示例。如果您正苦於以下問題:Java HttpTrace類的具體用法?Java HttpTrace怎麽用?Java HttpTrace使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


HttpTrace類屬於org.apache.http.client.methods包,在下文中一共展示了HttpTrace類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createHttpRequest

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
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);
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:25,代碼來源:RestClient.java

示例2: randomHttpRequest

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
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();
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:24,代碼來源:RequestLoggerTests.java

示例3: createHttpUriRequest

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
/**
 * 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);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:HttpComponentsClientHttpRequestFactory.java

示例4: createHttpUriRequest

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
/**
 * 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);
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:29,代碼來源:HttpComponentsClientHttpRequestFactory.java

示例5: getRawMethodRequest

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
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();
}
 
開發者ID:domisum,項目名稱:AuxiliumLib,代碼行數:27,代碼來源:MattpRequestEnvoy.java

示例6: getRequest

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
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();
}
 
開發者ID:domisum,項目名稱:AuxiliumLib,代碼行數:25,代碼來源:HttpFetch.java

示例7: requireThatServerRespondsToAllMethods

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
@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));
}
 
開發者ID:vespa-engine,項目名稱:vespa,代碼行數:23,代碼來源:JDiscHttpServletTest.java

示例8: createHttpUriRequest

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:zalando-nakadi,項目名稱:fahrschein,代碼行數:29,代碼來源:HttpComponentsRequestFactory.java

示例9: testGetRedirectRequestForTemporaryRedirect

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
@Test
public void testGetRedirectRequestForTemporaryRedirect() throws Exception {
    final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
    final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,
            HttpStatus.SC_TEMPORARY_REDIRECT, "Temporary Redirect");
    response.addHeader("Location", "http://localhost/stuff");
    final HttpContext context1 = new BasicHttpContext();
    final HttpUriRequest redirect1 = redirectStrategy.getRedirect(
            new HttpTrace("http://localhost/"), response, context1);
    Assert.assertEquals("TRACE", redirect1.getMethod());
    final HttpContext context2 = new BasicHttpContext();
    final HttpPost httppost = new HttpPost("http://localhost/");
    final HttpEntity entity = new BasicHttpEntity();
    httppost.setEntity(entity);
    final HttpUriRequest redirect2 = redirectStrategy.getRedirect(
            httppost, response, context2);
    Assert.assertEquals("POST", redirect2.getMethod());
    Assert.assertTrue(redirect2 instanceof HttpEntityEnclosingRequest);
    Assert.assertSame(entity, ((HttpEntityEnclosingRequest) redirect2).getEntity());
}
 
開發者ID:MyPureCloud,項目名稱:purecloud-iot,代碼行數:21,代碼來源:TestDefaultRedirectStrategy.java

示例10: test_methods

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
@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));
    }
}
 
開發者ID:heremaps,項目名稱:here-aaa-java-sdk,代碼行數:21,代碼來源:ApacheHttpClientProviderTest.java

示例11: createHttpRequest

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
/**
 * 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);
	}
}
 
開發者ID:bestarandyan,項目名稱:ShoppingMall,代碼行數:28,代碼來源:HttpComponentsClientHttpRequestFactory.java

示例12: createHttpRequest

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
/**
 * 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);
	}
}
 
開發者ID:bestarandyan,項目名稱:ShoppingMall,代碼行數:30,代碼來源:HttpComponentsClientHttpRequestFactory.java

示例13: resolveMethod

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
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." );
}
 
開發者ID:OpenBD,項目名稱:openbd-core,代碼行數:20,代碼來源:cfHttpConnection.java

示例14: createHttpUriRequest

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
/**
 * 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);
  }
}
 
開發者ID:detectiveframework,項目名稱:detective,代碼行數:29,代碼來源:HttpClientTask.java

示例15: setHttpMethod

import org.apache.http.client.methods.HttpTrace; //導入依賴的package包/類
@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);
}
 
開發者ID:camunda,項目名稱:camunda-connect,代碼行數:27,代碼來源:HttpRequestTest.java


注:本文中的org.apache.http.client.methods.HttpTrace類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。