Package org.apache.http.conn

Examples of org.apache.http.conn.HttpRoutedConnection


        HttpRequest request = new BasicHttpRequest("GET", "/stuff");

        this.target = new HttpHost("localhost.local");
        HttpRoute route = new HttpRoute(this.target, null, new HttpHost("localhost", 8888), false);

        HttpRoutedConnection conn = Mockito.mock(HttpRoutedConnection.class);
        Mockito.when(conn.getRoute()).thenReturn(route);
        Mockito.when(conn.isSecure()).thenReturn(Boolean.FALSE);
        Mockito.when(conn.getRemotePort()).thenReturn(1234);

        HttpContext context = new BasicHttpContext();
        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        context.setAttribute(ClientContext.COOKIE_STORE, this.cookieStore);
View Full Code Here


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

        HttpRoutedConnection conn = Mockito.mock(HttpRoutedConnection.class);
        Mockito.when(conn.getRoute()).thenReturn(route);
        Mockito.when(conn.isSecure()).thenReturn(Boolean.TRUE);
        Mockito.when(conn.getRemoteAddress()).thenReturn(InetAddress.getByName("localhost"));
        Mockito.when(conn.getRemotePort()).thenReturn(1234);

        HttpContext context = new BasicHttpContext();
        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        context.setAttribute(ClientContext.COOKIE_STORE, this.cookieStore);
View Full Code Here

        this.cookieStore.addCookie(cookie3);

        HttpRoute route = new HttpRoute(this.target, null, false);

        HttpRoutedConnection conn = Mockito.mock(HttpRoutedConnection.class);
        Mockito.when(conn.getRoute()).thenReturn(route);
        Mockito.when(conn.isSecure()).thenReturn(Boolean.FALSE);

        HttpContext context = new BasicHttpContext();
        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        context.setAttribute(ClientContext.COOKIE_STORE, this.cookieStore);
View Full Code Here

        cookie3.setPath("/");
        this.cookieStore.addCookie(cookie3);

        HttpRoute route = new HttpRoute(this.target, null, false);

        HttpRoutedConnection conn = Mockito.mock(HttpRoutedConnection.class);
        Mockito.when(conn.getRoute()).thenReturn(route);
        Mockito.when(conn.isSecure()).thenReturn(Boolean.FALSE);

        HttpContext context = new BasicHttpContext();
        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        context.setAttribute(ClientContext.COOKIE_STORE, this.cookieStore);
View Full Code Here

        cookie2.setPath("/");
        this.cookieStore.addCookie(cookie2);

        HttpRoute route = new HttpRoute(this.target, null, false);

        HttpRoutedConnection conn = Mockito.mock(HttpRoutedConnection.class);
        Mockito.when(conn.getRoute()).thenReturn(route);
        Mockito.when(conn.isSecure()).thenReturn(Boolean.FALSE);

        HttpContext context = new BasicHttpContext();
        context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        context.setAttribute(ClientContext.COOKIE_STORE, this.cookieStore);
View Full Code Here

                userPrincipal = getAuthPrincipal(proxyAuthState);
            }
        }

        if (userPrincipal == null) {
            HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute(
                    ExecutionContext.HTTP_CONNECTION);
            if (conn.isOpen()) {
                SSLSession sslsession = conn.getSSLSession();
                if (sslsession != null) {
                    userPrincipal = sslsession.getLocalPrincipal();
                }
            }
        }
View Full Code Here

     final HttpHost targetHost = (HttpHost) context.getAttribute(
         ExecutionContext.HTTP_TARGET_HOST);
     if(targetHost == null) {
       return null;
     }
     final HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute(
         ExecutionContext.HTTP_CONNECTION);
     if(conn == null) {
       return null;
     }
    
     return new CookieOrigin(
         targetHost.getHostName(),
         getPort(targetHost, conn),
         getPathForRequest(request),
         conn.isSecure());
   }
View Full Code Here

        if (request.containsHeader(AUTH.PROXY_AUTH_RESP)) {
            return;
        }

        final HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute(
                ExecutionContext.HTTP_CONNECTION);
        if (conn == null) {
            this.log.debug("HTTP connection not set in the context");
            return;
        }
        final HttpRoute route = conn.getRoute();
        if (route.isTunnelled()) {
            return;
        }

        // Obtain authentication state
View Full Code Here

    if (localHttpHost == null)
    {
      this.log.debug("Target host not set in the context");
      return;
    }
    HttpRoutedConnection localHttpRoutedConnection = (HttpRoutedConnection)paramHttpContext.getAttribute("http.connection");
    if (localHttpRoutedConnection == null)
    {
      this.log.debug("HTTP connection not set in the context");
      return;
    }
    String str2 = HttpClientParams.getCookiePolicy(paramHttpRequest.getParams());
    if (this.log.isDebugEnabled())
      this.log.debug("CookieSpec selected: " + str2);
    URI localURI;
    if ((paramHttpRequest instanceof HttpUriRequest))
      localURI = ((HttpUriRequest)paramHttpRequest).getURI();
    else
      try
      {
        localURI = new URI(paramHttpRequest.getRequestLine().getUri());
      }
      catch (URISyntaxException localURISyntaxException)
      {
        throw new ProtocolException("Invalid request URI: " + paramHttpRequest.getRequestLine().getUri(), localURISyntaxException);
      }
    String str3 = localHttpHost.getHostName();
    int i = localHttpHost.getPort();
    if (i < 0)
    {
      localObject1 = localHttpRoutedConnection.getRoute();
      if (((HttpRoute)localObject1).getHopCount() == 1)
      {
        i = localHttpRoutedConnection.getRemotePort();
      }
      else
      {
        localObject2 = localHttpHost.getSchemeName();
        if (((String)localObject2).equalsIgnoreCase("http"))
          i = 80;
        else if (((String)localObject2).equalsIgnoreCase("https"))
          i = 443;
        else
          i = 0;
      }
    }
    Object localObject1 = new CookieOrigin(str3, i, localURI.getPath(), localHttpRoutedConnection.isSecure());
    Object localObject2 = localCookieSpecRegistry.getCookieSpec(str2, paramHttpRequest.getParams());
    ArrayList localArrayList1 = new ArrayList(localCookieStore.getCookies());
    ArrayList localArrayList2 = new ArrayList();
    Date localDate = new Date();
    Object localObject3 = localArrayList1.iterator();
View Full Code Here

    if (str.equalsIgnoreCase("CONNECT"))
    {
      paramHttpRequest.setHeader("Proxy-Connection", "Keep-Alive");
      return;
    }
    HttpRoutedConnection localHttpRoutedConnection = (HttpRoutedConnection)paramHttpContext.getAttribute("http.connection");
    if (localHttpRoutedConnection == null)
    {
      this.log.debug("HTTP connection not set in the context");
      return;
    }
    HttpRoute localHttpRoute = localHttpRoutedConnection.getRoute();
    if (((localHttpRoute.getHopCount() == 1) || (localHttpRoute.isTunnelled())) && (!paramHttpRequest.containsHeader("Connection")))
      paramHttpRequest.addHeader("Connection", "Keep-Alive");
    if ((localHttpRoute.getHopCount() == 2) && (!localHttpRoute.isTunnelled()) && (!paramHttpRequest.containsHeader("Proxy-Connection")))
      paramHttpRequest.addHeader("Proxy-Connection", "Keep-Alive");
  }
View Full Code Here

TOP

Related Classes of org.apache.http.conn.HttpRoutedConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.