Package org.apache.http.impl.nio.client

Examples of org.apache.http.impl.nio.client.DefaultHttpAsyncClient


                    e.printStackTrace();
                }
            }
            ctx.setAttribute(ClientContext.SCHEME_REGISTRY, reg);
            connectionFuture = new BasicFuture<Boolean>(callback);
            DefaultHttpAsyncClient c = getHttpAsyncClient();
            CredentialsProvider credProvider = c.getCredentialsProvider();
            Credentials creds = (Credentials)outMessage.getContextualProperty(Credentials.class.getName());
            if (creds != null && credProvider != null) {
                credProvider.setCredentials(AuthScope.ANY, creds);
            }
            if (credProvider != null && credProvider.getCredentials(AuthScope.ANY) != null) {
                ctx.setAttribute(ClientContext.USER_TOKEN,
                                 credProvider.getCredentials(AuthScope.ANY).getUserPrincipal());
            }
           
            c.execute(new CXFHttpAsyncRequestProducer(entity, outbuf),
                      new CXFHttpAsyncResponseConsumer(this, inbuf, responseCallback),
                      ctx,
                      callback);
        }
View Full Code Here


    public DefaultHttpAsyncClient createClient(final AsyncHTTPConduit c) throws IOException {
        if (connectionManager == null) {
            setupNIOClient();
        }
       
        DefaultHttpAsyncClient dhac = new DefaultHttpAsyncClient(connectionManager) {
            @Override
            protected HttpParams createHttpParams() {
                HttpParams params = new SyncBasicHttpParams();
                HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
                HttpConnectionParams.setTcpNoDelay(params, true);
                int bufSize = c.getClient().getChunkLength() > 0 ? c.getClient().getChunkLength() : 16332;
                HttpConnectionParams.setSocketBufferSize(params, bufSize);
                HttpConnectionParams.setConnectionTimeout(params, (int)c.getClient().getConnectionTimeout());
                return params;
            }
            @Override
            protected BasicHttpProcessor createHttpProcessor() {
                return httpproc;
            }           
        };
        //CXF handles redirects ourselves
        dhac.setRedirectStrategy(new RedirectStrategy() {
            public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context)
                throws ProtocolException {
                return false;
            }
            public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context)
                throws ProtocolException {
                return null;
            }
        });
        dhac.setTargetAuthenticationStrategy(targetAuthenticationStrategy);
        dhac.setProxyAuthenticationStrategy(proxyAuthenticationStrategy);
        return dhac;
    }
View Full Code Here

    public void initClient() throws Exception {
        this.ioreactor = new DefaultConnectingIOReactor();
        AsyncSchemeRegistry schemeRegistry = new AsyncSchemeRegistry();
        schemeRegistry.register(new AsyncScheme("http", 80, null));
        this.connMgr = new PoolingAsyncClientConnectionManager(this.ioreactor, schemeRegistry);
        this.httpclient = new DefaultHttpAsyncClient(this.connMgr);
        this.httpclient.getParams()
            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 60000)
            .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 60000)
            .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
            .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
View Full Code Here

  public void init(QQContext context) throws QQException {
    super.init(context);
    try {
      SSLContext sslContext = new QQSSLSocketFactory().getSSLContext();
      SSLContext.setDefault(sslContext);
      asyncHttpClient = new DefaultHttpAsyncClient();
     
      HttpParams httpParams = asyncHttpClient.getParams();
          HttpConnectionParams.setSoTimeout(httpParams, QQConstants.HTTP_TIME_OUT);
          HttpConnectionParams.setConnectionTimeout(httpParams, QQConstants.HTTP_TIME_OUT);
          HttpConnectionParams.setTcpNoDelay(httpParams, true);
View Full Code Here

        return new PoolingClientConnectionManager(ioreactor, schemeRegistry);
    }

    protected DefaultHttpAsyncClient createClient(
            final ClientConnectionManager sessionManager) throws Exception {
        return new DefaultHttpAsyncClient(sessionManager);
    }
View Full Code Here

                    e.printStackTrace();
                }
            }
            ctx.setAttribute(ClientContext.SCHEME_REGISTRY, reg);
            connectionFuture = new BasicFuture<Boolean>(callback);
            DefaultHttpAsyncClient c = getHttpAsyncClient();
            Credentials creds = (Credentials)outMessage.getContextualProperty(Credentials.class.getName());
            if (creds != null) {
                c.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);
            }
            c.execute(new CXFHttpAsyncRequestProducer(entity, outbuf),
                      new CXFHttpAsyncResponseConsumer(inbuf, responseCallback),
                      ctx,
                      callback);
        }
View Full Code Here

    public DefaultHttpAsyncClient createClient(final AsyncHTTPConduit c) throws IOException {
        if (connectionManager == null) {
            setupNIOClient();
        }
       
        DefaultHttpAsyncClient dhac = new DefaultHttpAsyncClient(connectionManager) {
            @Override
            protected HttpParams createHttpParams() {
                HttpParams params = new SyncBasicHttpParams();
                HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
                HttpConnectionParams.setTcpNoDelay(params, true);
                HttpConnectionParams.setSocketBufferSize(params, 16332);
                HttpConnectionParams.setConnectionTimeout(params, (int)c.getClient().getConnectionTimeout());
                return params;
            }
            @Override
            protected BasicHttpProcessor createHttpProcessor() {
                return httpproc;
            }           
        };
        //CXF handles redirects ourselves
        dhac.setRedirectStrategy(new RedirectStrategy() {
            public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context)
                throws ProtocolException {
                return false;
            }
            public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context)
                throws ProtocolException {
                return null;
            }
        });
        dhac.setTargetAuthenticationStrategy(targetAuthenticationStrategy);
        dhac.setProxyAuthenticationStrategy(proxyAuthenticationStrategy);
        return dhac;
    }
View Full Code Here

                    e.printStackTrace();
                }
            }
            ctx.setAttribute(ClientContext.SCHEME_REGISTRY, reg);
            connectionFuture = new BasicFuture<Boolean>(callback);
            DefaultHttpAsyncClient c = getHttpAsyncClient();
            CredentialsProvider credProvider = c.getCredentialsProvider();
            Credentials creds = (Credentials)outMessage.getContextualProperty(Credentials.class.getName());
            if (creds != null && credProvider != null) {
                credProvider.setCredentials(AuthScope.ANY, creds);
            }
            if (credProvider != null && credProvider.getCredentials(AuthScope.ANY) != null) {
                ctx.setAttribute(ClientContext.USER_TOKEN,
                                 credProvider.getCredentials(AuthScope.ANY).getUserPrincipal());
            }
           
            c.execute(new CXFHttpAsyncRequestProducer(entity, outbuf),
                      new CXFHttpAsyncResponseConsumer(this, inbuf, responseCallback),
                      ctx,
                      callback);
        }
View Full Code Here

    public DefaultHttpAsyncClient createClient(final AsyncHTTPConduit c) throws IOException {
        if (connectionManager == null) {
            setupNIOClient();
        }
       
        DefaultHttpAsyncClient dhac = new DefaultHttpAsyncClient(connectionManager) {
            @Override
            protected HttpParams createHttpParams() {
                HttpParams params = new SyncBasicHttpParams();
                HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
                HttpConnectionParams.setTcpNoDelay(params, true);
                int bufSize = c.getClient().getChunkLength() > 0 ? c.getClient().getChunkLength() : 16332;
                HttpConnectionParams.setSocketBufferSize(params, bufSize);
                HttpConnectionParams.setConnectionTimeout(params, (int)c.getClient().getConnectionTimeout());
                return params;
            }
            @Override
            protected BasicHttpProcessor createHttpProcessor() {
                return httpproc;
            }           
        };
        //CXF handles redirects ourselves
        dhac.setRedirectStrategy(new RedirectStrategy() {
            public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context)
                throws ProtocolException {
                return false;
            }
            public HttpUriRequest getRedirect(HttpRequest request, HttpResponse response, HttpContext context)
                throws ProtocolException {
                return null;
            }
        });
        dhac.setTargetAuthenticationStrategy(targetAuthenticationStrategy);
        dhac.setProxyAuthenticationStrategy(proxyAuthenticationStrategy);
        return dhac;
    }
View Full Code Here

                    e.printStackTrace();
                }
            }
            ctx.setAttribute(ClientContext.SCHEME_REGISTRY, reg);
            connectionFuture = new BasicFuture<Boolean>(callback);
            DefaultHttpAsyncClient c = getHttpAsyncClient();
            CredentialsProvider credProvider = c.getCredentialsProvider();
            Credentials creds = (Credentials)outMessage.getContextualProperty(Credentials.class.getName());
            if (creds != null && credProvider != null) {
                credProvider.setCredentials(AuthScope.ANY, creds);
            }
            if (credProvider != null && credProvider.getCredentials(AuthScope.ANY) != null) {
                ctx.setAttribute(ClientContext.USER_TOKEN,
                                 credProvider.getCredentials(AuthScope.ANY).getUserPrincipal());
            }
           
            c.execute(new CXFHttpAsyncRequestProducer(entity, outbuf),
                      new CXFHttpAsyncResponseConsumer(this, inbuf, responseCallback),
                      ctx,
                      callback);
        }
View Full Code Here

TOP

Related Classes of org.apache.http.impl.nio.client.DefaultHttpAsyncClient

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.