Best code examples for Android HttpContext class (org.apache.http.protocol.HttpContext)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android HttpContext class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android HttpContext examples from Open Source projects
This code example shows how to use the following methods: setAttribute
    /** 
     * Sets an optional CookieStore to use when making requests 
     * @param cookieStore The CookieStore implementation to use, usually an instance of {@link PersistentCookieStore} 
     */ 
    public void setCookieStore(CookieStore cookieStore) {
        httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
    } 
 
    /** 
     * Overrides the threadpool implementation used when queuing/pooling 
     * requests. By default, Executors.newCachedThreadPool() is used. 
     * @param threadPool an instance of {@link ThreadPoolExecutor} to use for queuing/pooling requests. 
     */ 
    public void setThreadPool(ThreadPoolExecutor threadPool) {
        this.threadPool = threadPool;
    } 
 
    /** 
     * Sets the User-Agent header to be sent with each request. By default, 
     * "Android Asynchronous Http Client/VERSION (http://loopj.com/android-async-http/)" is used. 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getAttribute
     * If the authentication failed, this method only responses with 401 
     * Unauthorized. 
     */ 
    @Override 
    public final void handle(final HttpRequest request, final HttpResponse response, HttpContext context) throws HttpException, IOException {
        Object authAttribute = context.getAttribute("authenticated");
 
        if (authAttribute == null || (authAttribute instanceof Boolean && ((Boolean) authAttribute).booleanValue())) {
            getResponse(request, response, context);
            return; 
        } 
 
        AbstractHttpEntity entity = new StringEntity("401 Unauthorized");
        entity.setContentType("text/plain");
        response.setEntity(entity);
        response.setStatusCode(401);
    } 
 
    /** 
     * This method is only called if the authentication was successful. 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setAttribute
        HttpClient httpClient = getNewHttpClient();
 
        URL urlObj = new URL(url);
        HttpHost host = new HttpHost(urlObj.getHost(), urlObj.getPort(), urlObj.getProtocol());
 
        HttpContext credContext = new BasicHttpContext();
        credContext.setAttribute(ClientContext.CREDS_PROVIDER, cp);
 
        HttpGet job = new HttpGet(url);
        HttpResponse response = httpClient.execute(host, job, credContext);
 
        HttpEntity entity = response.getEntity();
        return EntityUtils.toString(entity).toCharArray();
    } 
 
    /** 
     * Gets data from URL as char[] throws {@link RuntimeException} If anything 
     * goes wrong 
     *  
     * @return The content of the URL as a char[] 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setAttribute
This code example shows how to use the following methods: setAttribute
5
CodeRank
Related Android HttpContext Questions & Answers:
See Code Examples for Android HttpContext Methods: