当前位置: 首页>>代码示例>>Java>>正文


Java TunnelType.PLAIN属性代码示例

本文整理汇总了Java中org.apache.http.conn.routing.RouteInfo.TunnelType.PLAIN属性的典型用法代码示例。如果您正苦于以下问题:Java TunnelType.PLAIN属性的具体用法?Java TunnelType.PLAIN怎么用?Java TunnelType.PLAIN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.http.conn.routing.RouteInfo.TunnelType的用法示例。


在下文中一共展示了TunnelType.PLAIN属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProxyConnectionKeepAliveForRequestsOverProxy

@Test
public void testProxyConnectionKeepAliveForRequestsOverProxy() throws Exception {
    final HttpRequest request = new BasicHttpRequest("GET", "/");
    final HttpClientContext context = HttpClientContext.create();

    final HttpHost target = new HttpHost("localhost", 80, "http");
    final HttpHost proxy = new HttpHost("localhost", 8080);
    final HttpRoute route = new HttpRoute(target, null, proxy, false,
            TunnelType.PLAIN, LayerType.PLAIN);

    context.setAttribute(HttpClientContext.HTTP_ROUTE, route);

    final HttpRequestInterceptor interceptor = new RequestClientConnControl();
    interceptor.process(request, context);

    final Header header1 = request.getFirstHeader("Proxy-Connection");
    Assert.assertNotNull(header1);
    Assert.assertEquals(HTTP.CONN_KEEP_ALIVE, header1.getValue());
    final Header header2 = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
    Assert.assertNull(header2);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:21,代码来源:TestRequestClientConnControl.java

示例2: testPreserveCustomProxyConnectionHeader

@Test
public void testPreserveCustomProxyConnectionHeader() throws Exception {
    final HttpRequest request = new BasicHttpRequest("GET", "/");
    request.addHeader("Proxy-Connection", HTTP.CONN_CLOSE);
    final HttpClientContext context = HttpClientContext.create();

    final HttpHost target = new HttpHost("localhost", 80, "http");
    final HttpHost proxy = new HttpHost("localhost", 8080);
    final HttpRoute route = new HttpRoute(target, null, proxy, false,
            TunnelType.PLAIN, LayerType.PLAIN);

    context.setAttribute(HttpClientContext.HTTP_ROUTE, route);

    final HttpRequestInterceptor interceptor = new RequestClientConnControl();
    interceptor.process(request, context);

    final Header header1 = request.getFirstHeader("Proxy-Connection");
    Assert.assertNotNull(header1);
    Assert.assertEquals(HTTP.CONN_CLOSE, header1.getValue());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:20,代码来源:TestRequestClientConnControl.java

示例3: testCstr4

@SuppressWarnings("unused")
@Test
public void testCstr4() {
    // test convenience constructor with 4 arguments
    HttpRoute route = new HttpRoute(TARGET2, null, PROXY2, false);
    HttpRoute should = new HttpRoute
        (TARGET2, null, new HttpHost[]{ PROXY2 }, false,
         TunnelType.PLAIN, LayerType.PLAIN);
    Assert.assertEquals("bad convenience route 4/insecure", route, should);

    route = new HttpRoute(TARGET2, LOCAL42, PROXY1, true);
    should = new HttpRoute
        (TARGET2, LOCAL42, new HttpHost[]{ PROXY1 }, true,
         TunnelType.TUNNELLED, LayerType.LAYERED);
    Assert.assertEquals("bad convenience route 4/secure", route, should);

    // this constructor REQUIRES a proxy to be specified
    try {
        new HttpRoute(TARGET1, LOCAL61, null, false);
        Assert.fail("missing proxy not detected");
    } catch (final IllegalArgumentException iax) {
        // expected
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:24,代码来源:TestHttpRoute.java

示例4: testCstr6

@Test
public void testCstr6() {
    // test convenience constructor with 6 arguments
    HttpRoute route = new HttpRoute
        (TARGET2, null, PROXY2, true,
         TunnelType.TUNNELLED, LayerType.PLAIN);
    HttpRoute should = new HttpRoute
        (TARGET2, null, new HttpHost[]{ PROXY2 }, true,
         TunnelType.TUNNELLED, LayerType.PLAIN);
    Assert.assertEquals("bad convenience route 6/proxied", route, should);

    route = new HttpRoute
        (TARGET2, null, (HttpHost) null, true,
         TunnelType.PLAIN, LayerType.LAYERED);
    should = new HttpRoute
        (TARGET2, null, (HttpHost[]) null, true,
         TunnelType.PLAIN, LayerType.LAYERED);
    Assert.assertEquals("bad convenience route 6/direct", route, should);

    // handling of null vs. empty chain is checked in the equals tests
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:21,代码来源:TestHttpRoute.java

示例5: testImmutable

@Test
public void testImmutable() throws CloneNotSupportedException {

    final HttpHost[] proxies = new HttpHost[]{ PROXY1, PROXY2, PROXY3 };
    final HttpRoute route1 = new HttpRoute(TARGET1, null, proxies, false,
                                     TunnelType.PLAIN, LayerType.PLAIN);
    final HttpRoute route2 = (HttpRoute) route1.clone();
    final HttpRoute route3 = new HttpRoute(TARGET1, null,
                                     proxies.clone(), false,
                                     TunnelType.PLAIN, LayerType.PLAIN);

    // modify the array that was passed to the constructor of route1
    proxies[1] = PROXY3;
    proxies[2] = PROXY2;

    Assert.assertEquals("route differs from clone", route2, route1);
    Assert.assertEquals("route was modified", route3, route1);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestHttpRoute.java

示例6: testCstrFullRoute

@Test
public void testCstrFullRoute() {
    // create a route with all arguments and check the details
    final HttpHost[] chain3 = { PROXY1, PROXY2, PROXY3 };

    final HttpRoute route = new HttpRoute(TARGET1, LOCAL41, chain3, false,
                                    TunnelType.PLAIN, LayerType.PLAIN);
    Assert.assertEquals("wrong target",
                 TARGET1, route.getTargetHost());
    Assert.assertEquals("wrong local address",
                 LOCAL41, route.getLocalAddress());
    Assert.assertEquals("wrong proxy host",
                 PROXY1, route.getProxyHost());
    Assert.assertEquals("wrong hop count",
                 4, route.getHopCount());
    Assert.assertEquals("wrong hop 0",
                 PROXY1, route.getHopTarget(0));
    Assert.assertEquals("wrong hop 1",
                 PROXY2, route.getHopTarget(1));
    Assert.assertEquals("wrong hop 2",
                 PROXY3, route.getHopTarget(2));
    Assert.assertEquals("wrong hop 3",
                 TARGET1, route.getHopTarget(3));
    Assert.assertFalse("wrong flag: secured", route.isSecure());
    Assert.assertFalse("wrong flag: tunnelled", route.isTunnelled());
    Assert.assertFalse("wrong flag: layered", route.isLayered());

    final String routestr = route.toString();
    Assert.assertTrue("missing target in toString",
            routestr.contains(TARGET1.getHostName()));
    Assert.assertTrue("missing local address in toString",
            routestr.contains(LOCAL41.toString()));
    Assert.assertTrue("missing proxy 1 in toString",
            routestr.contains(PROXY1.getHostName()));
    Assert.assertTrue("missing proxy 2 in toString",
            routestr.contains(PROXY2.getHostName()));
    Assert.assertTrue("missing proxy 3 in toString",
            routestr.contains(PROXY3.getHostName()));
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:39,代码来源:TestHttpRoute.java

示例7: testCstr1

@Test
public void testCstr1() {
    final HttpRoute route = new HttpRoute(TARGET2);
    final HttpRoute should = new HttpRoute
        (TARGET2, null, (HttpHost[]) null, false,
         TunnelType.PLAIN, LayerType.PLAIN);
    Assert.assertEquals("bad convenience route", route, should);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:8,代码来源:TestHttpRoute.java

示例8: testCstr3

@Test
public void testCstr3() {
    // test convenience constructor with 3 arguments
    HttpRoute route = new HttpRoute(TARGET2, LOCAL61, false);
    HttpRoute should = new HttpRoute
        (TARGET2, LOCAL61, (HttpHost[]) null, false,
         TunnelType.PLAIN, LayerType.PLAIN);
    Assert.assertEquals("bad convenience route 3/insecure", route, should);

    route = new HttpRoute(TARGET2, null, true);
    should = new HttpRoute(TARGET2, null, (HttpHost[]) null, true,
                           TunnelType.PLAIN, LayerType.PLAIN);
    Assert.assertEquals("bad convenience route 3/secure", route, should);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:14,代码来源:TestHttpRoute.java

示例9: testProxyChainRoutes

@Test
public void testProxyChainRoutes() {

    final HttpRouteDirector rd = new BasicRouteDirector();
    HttpHost[] proxies = { PROXY1, PROXY2 };
    HttpRoute r = new HttpRoute(TARGET2, LOCAL42, proxies, false,
                                TunnelType.PLAIN, LayerType.PLAIN);
    RouteTracker rt = new RouteTracker(r);
    boolean complete = checkVia(rt, r, rd, 3);
    Assert.assertTrue("incomplete route 1", complete);

    // tunnelled, but neither secure nor layered
    proxies = new HttpHost[]{ PROXY3, PROXY2 };
    r = new HttpRoute(TARGET1, null, proxies, false,
                      TunnelType.TUNNELLED, LayerType.PLAIN);
    rt = new RouteTracker(r);
    complete = checkVia(rt, r, rd, 4);
    Assert.assertTrue("incomplete route 2", complete);

    // tunnelled, layered, but not secure
    proxies = new HttpHost[]{ PROXY3, PROXY2, PROXY1 };
    r = new HttpRoute(TARGET2, LOCAL61, proxies, false,
                      TunnelType.TUNNELLED, LayerType.LAYERED);
    rt = new RouteTracker(r);
    complete = checkVia(rt, r, rd, 6);
    Assert.assertTrue("incomplete route 3", complete);

    // tunnelled, layered, secure
    proxies = new HttpHost[]{ PROXY1, PROXY3 };
    r = new HttpRoute(TARGET1, LOCAL61, proxies, true,
                      TunnelType.TUNNELLED, LayerType.LAYERED);
    rt = new RouteTracker(r);
    complete = checkVia(rt, r, rd, 5);
    Assert.assertTrue("incomplete route 4", complete);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:35,代码来源:TestRouteTracker.java

示例10: determineRoute

public HttpRoute determineRoute(HttpHost target,
                                HttpRequest request,
                                HttpContext context)
    throws HttpException {

    if (request == null) {
        throw new IllegalStateException("Request must not be null.");
    }

    // If we have a forced route, we can do without a target.
    HttpRoute route =
        ConnRouteParams.getForcedRoute(request.getParams());
    if (route != null) {
        return route;
    }

    // If we get here, there is no forced route.
    // So we need a target to compute a route.

    if (target == null) {
        throw new IllegalStateException("Target host must not be null.");
    }

    final InetAddress local =
        ConnRouteParams.getLocalAddress(request.getParams());

    final Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
    // as it is typically used for TLS/SSL, we assume that
    // a layered scheme implies a secure connection
    final boolean secure = schm.isLayered();

    if (proxyChain == null || proxyChain.length == 0) {
        route = new HttpRoute(target, local, secure);
    } else {
        TunnelType tunnelType = secure ? TunnelType.TUNNELLED : TunnelType.PLAIN;
        LayerType layereType = secure ? LayerType.LAYERED : LayerType.PLAIN;
    	return new HttpRoute(target, null, proxyChain, secure, tunnelType, layereType);
    }
    return route;
}
 
开发者ID:cattong,项目名称:YiBo,代码行数:40,代码来源:LibHttpRoutePlanner.java

示例11: testProxyChain

@Test
public void testProxyChain() {
    final HttpHost[] chainA = { PROXY1 };
    final HttpHost[] chainB = { PROXY1, PROXY2 };
    final HttpHost[] chainC = { PROXY2, PROXY1 };

    final HttpRouteDirector rowdy = new BasicRouteDirector();
    final HttpRoute route1cA  = new HttpRoute(TARGET1, null, chainA, false,
                                        TunnelType.PLAIN, LayerType.PLAIN);
    final HttpRoute route1cB  = new HttpRoute(TARGET1, null, chainB, false,
                                        TunnelType.PLAIN, LayerType.PLAIN);
    final HttpRoute route1cC  = new HttpRoute(TARGET1, null, chainC, false,
                                        TunnelType.PLAIN, LayerType.PLAIN);
    final HttpRoute route1cD  = new HttpRoute(TARGET1, null, chainC, false,
                                        TunnelType.PLAIN, LayerType.PLAIN);

    int step = rowdy.nextStep(route1cA, null);
    Assert.assertEquals("wrong step to route1cA",
                 HttpRouteDirector.CONNECT_PROXY, step);

    step = rowdy.nextStep(route1cB, null);
    Assert.assertEquals("wrong step to route1cB",
                 HttpRouteDirector.CONNECT_PROXY, step);

    step = rowdy.nextStep(route1cC, null);
    Assert.assertEquals("wrong step to route1cC",
                 HttpRouteDirector.CONNECT_PROXY, step);

    step = rowdy.nextStep(route1cD, null);
    Assert.assertEquals("wrong step to route1cD",
                 HttpRouteDirector.CONNECT_PROXY, step);


    step = rowdy.nextStep(route1cB, route1cA);
    Assert.assertEquals("wrong step to route 1cB from 1cA",
                 HttpRouteDirector.TUNNEL_PROXY, step);

    step = rowdy.nextStep(route1cB, route1cB);
    Assert.assertEquals("complete route 1cB not detected",
                 HttpRouteDirector.COMPLETE, step);

    step = rowdy.nextStep(route1cB, route1cC);
    Assert.assertEquals("unreachable route 1cB from 1cC not detected",
                 HttpRouteDirector.UNREACHABLE, step);

    step = rowdy.nextStep(route1cB, route1cD);
    Assert.assertEquals("unreachable route 1cB from 1cD not detected",
                 HttpRouteDirector.UNREACHABLE, step);


    step = rowdy.nextStep(route1cA, route1cB);
    Assert.assertEquals("unreachable route 1cA from 1cB not detected",
                 HttpRouteDirector.UNREACHABLE, step);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:54,代码来源:TestRouteDirector.java


注:本文中的org.apache.http.conn.routing.RouteInfo.TunnelType.PLAIN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。