Examples of ClientBootstrap


Examples of org.jboss.netty.bootstrap.ClientBootstrap

            } else if (uri.getScheme().equalsIgnoreCase("https")) {
                port = 443;
            }
        }

        ClientBootstrap clientBootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(
                Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
        File tmpFile;
        try {
            tmpFile = File.createTempFile("http", "download");
        } catch (IOException e) {
            throw new DeploymentFailedException("Cannot create temporary file for fetching s4r data from http server",
                    e);
        }
        clientBootstrap.setPipelineFactory(new HttpClientPipelineFactory(tmpFile));
        ChannelFuture channelFuture = clientBootstrap.connect(new InetSocketAddress(host, port));
        // TODO timeout?
        Channel channel = channelFuture.awaitUninterruptibly().getChannel();
        if (!channelFuture.isSuccess()) {
            clientBootstrap.releaseExternalResources();
            throw new DeploymentFailedException("Cannot connect to http uri [" + uri.toString() + "]",
                    channelFuture.getCause());
        }

        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri.toASCIIString());
        request.setHeader(HttpHeaders.Names.HOST, host);
        request.setHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
        request.setHeader(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP);

        channel.write(request);

        channel.getCloseFuture().awaitUninterruptibly();

        clientBootstrap.releaseExternalResources();

        logger.debug("Finished downloading s4r file through http {}", uri.toString());
        try {
            return new FileInputStream(tmpFile);
        } catch (FileNotFoundException e) {
View Full Code Here

Examples of org.jboss.netty.bootstrap.ClientBootstrap

    // Set up.
    this.channelFactory = channelFactory;
    this.connectTimeoutMillis = (Long) nettyClientBootstrapOptions
        .get(NETTY_CONNECT_TIMEOUT_OPTION);
    bootstrap = new ClientBootstrap(channelFactory);
    remoteAddr = addr;
    this.nettyClientBootstrapOptions = nettyClientBootstrapOptions;
  }
View Full Code Here

Examples of org.jboss.netty.bootstrap.ClientBootstrap

      if (useServlet)
      {
         ClientSocketChannelFactory proxyChannelFactory = channelFactory;
         channelFactory = new HttpTunnelingClientSocketChannelFactory(proxyChannelFactory);
      }
      bootstrap = new ClientBootstrap(channelFactory);

      bootstrap.setOption("tcpNoDelay", tcpNoDelay);
      if (tcpReceiveBufferSize != -1)
      {
         bootstrap.setOption("receiveBufferSize", tcpReceiveBufferSize);
View Full Code Here

Examples of org.jboss.netty.bootstrap.ClientBootstrap

      if (useServlet)
      {
         ClientSocketChannelFactory proxyChannelFactory = channelFactory;
         channelFactory = new HttpTunnelingClientSocketChannelFactory(proxyChannelFactory);
      }
      bootstrap = new ClientBootstrap(channelFactory);

      bootstrap.setOption("tcpNoDelay", tcpNoDelay);

      if (connectTimeoutMillis != -1)
      {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.