Android HttpParams - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android HttpParams class.

This code example shows how to use the following methods:setIntParameter
 
    return gridClient;
  } 
 
  public HttpParams getHttpParams() {
    HttpParams params = new BasicHttpParams();
    HttpConnectionParams.setSoReuseaddr(params, true);
    HttpConnectionParams.setConnectionTimeout(params, 120 * 1000);
    HttpConnectionParams.setSoTimeout(params, TIMEOUT_THREE_HOURS);
    params.setIntParameter(ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE, 0);
    HttpConnectionParams.setStaleCheckingEnabled(params, true);
    return params;
  } 
 
  public HttpRoutePlanner getRoutePlanner(SchemeRegistry registry) {
    return new ProxySelectorRoutePlanner(registry, ProxySelector.getDefault());
  } 
 
  public HttpParams getGridHttpParams(int connection_timeout, int socket_timeout){
    final HttpParams params = getHttpParams();
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getIntParameter
     */ 
    public BasicConnPool(final SocketConfig sconfig, final ConnectionConfig cconfig) {
        super(new BasicConnFactory(sconfig, cconfig), 2, 20);
    } 
 
    /** 
     * @since 4.3 
     */ 
    public BasicConnPool() { 
        super(new BasicConnFactory(SocketConfig.DEFAULT, ConnectionConfig.DEFAULT), 2, 20); 
    } 
 
    @Override 
    protected BasicPoolEntry createEntry(
            final HttpHost host,
            final HttpClientConnection conn) {
        return new BasicPoolEntry(Long.toString(COUNTER.getAndIncrement()), host, conn);
    } 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setParameter
				return new Scheme("http", PlainSocketFactory.getSocketFactory(), port);
			} 
		} 
 
		public org.apache.http.client.HttpClient configureClient() {
			HttpParams params = new BasicHttpParams();
			HttpProtocolParams.setUseExpectContinue(params, useExpectContinue);
			HttpConnectionParams 
					.setConnectionTimeout(params, connectionTimeout);
			HttpConnectionParams.setSoTimeout(params, socketTimeout);
			HttpConnectionParams.setTcpNoDelay(params, Boolean.TRUE);
 
            String protocol = "http";
 
			if (enableSSL)
                protocol = "https";
 
			params.setParameter(ClientPNames.DEFAULT_HOST, new HttpHost(host,
					port, protocol));
			if (proxy != null) {

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getIntParameter
     *     SocketConfig, ConnectionConfig)}. 
     */ 
    @Deprecated 
    public BasicConnFactory(final SSLSocketFactory sslfactory, final HttpParams params) {
        super(); 
        Args.notNull(params, "HTTP params");
        this.plainfactory = null;
        this.sslfactory = sslfactory;
        this.connectTimeout = params.getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 0);
        this.sconfig = HttpParamConfig.getSocketConfig(params);
        this.connFactory = new DefaultBHttpClientConnectionFactory(
                HttpParamConfig.getConnectionConfig(params));
    } 
 
    /** 
     * @deprecated (4.3) use 
     *   {@link BasicConnFactory#BasicConnFactory(int, SocketConfig, ConnectionConfig)}. 
     */ 
    @Deprecated 
    public BasicConnFactory(final HttpParams params) {
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setIntParameter
        } catch (IOException expected) {
        } 
    } 
 
    public void testMaxHeaderCount() throws Exception { 
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
 
        params.setIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, 2);
        NHttpMessageParser<HttpRequest> requestParser = new DefaultHttpRequestParser(inbuf, null, requestFactory, params);
        requestParser.fillBuffer(newChannel("GET /whatever HTTP/1.0\r\nHeader: one\r\nHeader: two\r\n\r\n"));
        requestParser.parse();
        requestParser.reset();
 
        try { 
            requestParser.fillBuffer(newChannel("GET /whatever HTTP/1.0\r\nHeader: one\r\nHeader: two\r\nHeader: three\r\n\r\n"));
            requestParser.parse();
            fail("IOException should have been thrown");
        } catch (IOException expected) {
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getIntParameter
    public BasicNIOConnPool( 
            final ConnectingIOReactor ioreactor,
            final NIOConnFactory<HttpHost, NHttpClientConnection> connFactory,
            final HttpParams params) {
        super(ioreactor, connFactory, 2, 20);
        Args.notNull(params, "HTTP parameters");
        this.connectTimeout = params.getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 0);
    } 
 
    /** 
     * @deprecated (4.3) use {@link BasicNIOConnPool#BasicNIOConnPool(ConnectingIOReactor, 
     *   ConnectionConfig)} 
     */ 
    @Deprecated 
    public BasicNIOConnPool( 
            final ConnectingIOReactor ioreactor, final HttpParams params) {
        this(ioreactor, new BasicNIOConnFactory(params), params);
    } 
 
    /** 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setParameter, x 1
	public static HttpClient getHttpClient() {
		HttpClient httpClient = new DefaultHttpClient();
		HttpParams params = httpClient.getParams();
		HttpConnectionParams.setConnectionTimeout(params, HttpUtil.TIME_OUT);
		HttpConnectionParams.setSoTimeout(params, HttpUtil.TIME_OUT);
		params.setParameter("Connection", "keep-alive");
		params.setParameter("Accept-Encoding", "gzip,deflate");
		params.setParameter("Accept-Charset", "GBK,utf-8;q=0.7,*;q=0.3");
		params.setParameter("Accept",
				"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); 
		params.setParameter("Accept-Language",
				"zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3"); 
		params.setParameter(
				"User-Agent", 
				"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31"); 
		return httpClient;
	} 
 
	/** 
	 * 返回一个配置好报头的Jsoup连接. 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setBooleanParameter, setIntParameter, setParameter
    private final ConnectionReuseStrategy connStrategy;
 
    public TestHttpCore() { 
        super(); 
        this.params = new SyncBasicHttpParams();
        this.params.setParameter(HttpProtocolParams.PROTOCOL_VERSION,
                HttpVersion.HTTP_1_1);
        this.params.setBooleanParameter(HttpProtocolParams.USE_EXPECT_CONTINUE,
                false); 
        this.params.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK,
                false); 
        this.params.setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE,
                8 * 1024); 
        this.params.setIntParameter(HttpConnectionParams.SO_TIMEOUT,
                15000); 
 
        this.httpproc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
                new RequestContent(),
                new RequestTargetHost(),
                new RequestConnControl(),
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getParameter
 
            ClientConnectionManagerFactory factory = null;
 
            // Try first getting the factory directly as an object. 
            factory = (ClientConnectionManagerFactory) params
                    .getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY);
            if (factory == null) { // then try getting its class name.
                String className = (String) params.getParameter(
                        ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME);
                if (className != null) {
                    try { 
                        Class<?> clazz = Class.forName(className);
                        factory = (ClientConnectionManagerFactory) clazz.newInstance();
                    } catch (ClassNotFoundException ex) {
                        throw new IllegalStateException("Invalid class name: " + className);
                    } catch (IllegalAccessException ex) {
                        throw new IllegalAccessError(ex.getMessage());
                    } catch (InstantiationException ex) {
                        throw new InstantiationError(ex.getMessage());
                    } 

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setParameter
  
        schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(), 443));
  
        params = new BasicHttpParams();
        params.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 1);
        params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRouteBean(1));
        params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false);
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, "utf8");
  
        CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
         
//	        credentialsProvider.setCredentials(new AuthScope("cooper.apphb.com", AuthScope.ANY_PORT) 
//	        	, new UsernamePasswordCredentials("UserNameHere", "UserPasswordHere")); 
        clientConnectionManager = new ThreadSafeClientConnManager(params, schemeRegistry);
  
        context = new BasicHttpContext();
        context.setAttribute("http.auth.credentials-provider", credentialsProvider);
	} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android HttpParams Questions & Answers:

See Code Examples for Android HttpParams Methods: