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


Java TunnelType.TUNNELLED属性代码示例

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


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

示例1: testAuthDefaultHttpsPortWhenProxy

@Test
public void testAuthDefaultHttpsPortWhenProxy() throws Exception {
    final HttpRequest request = new BasicHttpRequest("GET", "/stuff");

    this.target = new HttpHost("localhost", -1, "https");
    final HttpRoute route = new HttpRoute(
            new HttpHost("localhost", 443, "https"), null,
            new HttpHost("localhost", 8888), true, TunnelType.TUNNELLED, LayerType.LAYERED);

    final HttpClientContext context = HttpClientContext.create();
    context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
    context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
    context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
    context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);

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

    final CookieOrigin cookieOrigin = context.getCookieOrigin();
    Assert.assertNotNull(cookieOrigin);
    Assert.assertEquals(this.target.getHostName(), cookieOrigin.getHost());
    Assert.assertEquals(443, cookieOrigin.getPort());
    Assert.assertEquals("/stuff", cookieOrigin.getPath());
    Assert.assertTrue(cookieOrigin.isSecure());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:25,代码来源:TestRequestAddCookies.java

示例2: testConnectionKeepAliveForTunneledRequests

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

    final HttpHost target = new HttpHost("localhost", 443, "https");
    final HttpHost proxy = new HttpHost("localhost", 8080);
    final HttpRoute route = new HttpRoute(target, null, proxy, true,
            TunnelType.TUNNELLED, LayerType.LAYERED);

    context.setAttribute(HttpClientContext.HTTP_ROUTE, route);

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

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

示例3: testPreserveCustomConnectionHeader

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

    final HttpHost target = new HttpHost("localhost", 443, "https");
    final HttpHost proxy = new HttpHost("localhost", 8080);
    final HttpRoute route = new HttpRoute(target, null, proxy, true,
            TunnelType.TUNNELLED, LayerType.LAYERED);

    context.setAttribute(HttpClientContext.HTTP_ROUTE, route);

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

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

示例4: 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

示例5: 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

示例6: testProxyRoutes

@Test
public void testProxyRoutes() {

    final HttpRouteDirector rd = new BasicRouteDirector();
    HttpRoute r = new HttpRoute(TARGET2, null, PROXY1, false);
    RouteTracker rt = new RouteTracker(r);
    boolean complete = checkVia(rt, r, rd, 2);
    Assert.assertTrue("incomplete route 1", complete);

    // tunnelled, but neither secure nor layered
    r = new HttpRoute(TARGET1, LOCAL61, PROXY3, false,
                      TunnelType.TUNNELLED, LayerType.PLAIN);
    rt = new RouteTracker(r);
    complete = checkVia(rt, r, rd, 3);
    Assert.assertTrue("incomplete route 2", complete);

    // tunnelled, layered, but not secure
    r = new HttpRoute(TARGET1, LOCAL61, PROXY3, false,
                      TunnelType.TUNNELLED, LayerType.LAYERED);
    rt = new RouteTracker(r);
    complete = checkVia(rt, r, rd, 4);
    Assert.assertTrue("incomplete route 3", complete);

    // tunnelled, layered, secure
    r = new HttpRoute(TARGET1, LOCAL61, PROXY3, true);
    rt = new RouteTracker(r);
    complete = checkVia(rt, r, rd, 4);
    Assert.assertTrue("incomplete route 4", complete);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:29,代码来源:TestRouteTracker.java

示例7: 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

示例8: 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


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