Android BasicHttpContext - 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 BasicHttpContext class.

This code example shows how to use the following methods:
This code example shows how to use the following methods:
                checkMultipartParams((HttpPut) method, request);
            } else { 
                logAndThrow("Method " + request.getMethod() + " is not implemented yet");
            } 
            method.setParams(params);
            HttpContext context = new BasicHttpContext();
            eventBus.fireOnPreProcess(request, method, context);
            final HttpResponse httpResponse = client.execute(method, context);
            eventBus.fireOnPostProcess(request, httpResponse, context);
            if (httpResponse == null) {
                logAndThrow("Response from " + request.getUri() + " is null");
            } 
            response.setHttpResponse(httpResponse);
            response.setIntentWrapper(request);
            if (verboseLoggingEnabled()) { 
                v("Request returning response"); 
            } 
            return response;
        } catch (Throwable t) {
            t.printStackTrace();
6
CodeRank
This code example shows how to use the following methods:
	HttpPost httpPost = null;
	HttpGet httpGet = null;
 
	public HttpRequestHelper() { 
		httpClient = createHttpClient();
		localContext = new BasicHttpContext();
	} 
 
	public static DefaultHttpClient createHttpClient() {
		HttpParams params = new BasicHttpParams();
		HttpConnectionParams.setConnectionTimeout(params, 20000);
		HttpConnectionParams.setSoTimeout(params, 20000);
		HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
		HttpProtocolParams.setContentCharset(params,
				HTTP.DEFAULT_CONTENT_CHARSET);
 
		SchemeRegistry schReg = new SchemeRegistry();
		schReg.register(new Scheme("http", PlainSocketFactory
				.getSocketFactory(), 80));
		schReg.register(new Scheme("https",
6
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[] 
5
CodeRank
This code example shows how to use the following methods:
	HttpPost httpPost = null;
	HttpGet httpGet = null;
 
	public HttpRequestHelper() { 
		httpClient = createHttpClient();
		localContext = new BasicHttpContext();
	} 
 
	public static DefaultHttpClient createHttpClient() {
		HttpParams params = new BasicHttpParams();
		HttpConnectionParams.setConnectionTimeout(params, 20000);
		HttpConnectionParams.setSoTimeout(params, 20000);
		HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
		HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
 
		SchemeRegistry schReg = new SchemeRegistry();
		schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
		schReg.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
		ClientConnectionManager conMgr = new ThreadSafeClientConnManager(params, schReg);
 
5
CodeRank
This code example shows how to use the following methods:setAttribute
This code example shows how to use the following methods:
This code example shows how to use the following methods:setAttribute
5
CodeRank
This code example shows how to use the following methods:setAttribute
    } 
 
    @Test 
    public void testConnectionKeepAliveForDirectRequests() throws Exception { 
        HttpRequest request = new BasicHttpRequest("GET", "/");
        HttpContext context = new BasicHttpContext();
 
        HttpHost target = new HttpHost("localhost", 80, "http");
        HttpRoute route = new HttpRoute(target, null, false);
 
        HttpRoutedConnection conn = Mockito.mock(HttpRoutedConnection.class);
        Mockito.when(conn.getRoute()).thenReturn(route);
 
        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
 
        HttpRequestInterceptor interceptor = new RequestClientConnControl();
        interceptor.process(request, context);
 
        Header header1 = request.getFirstHeader(HTTP.CONN_DIRECTIVE);
        Assert.assertNotNull(header1);

5
CodeRank
This code example shows how to use the following methods:getAttribute, setAttribute
 
        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);
        context.setAttribute(ClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
 
        HttpRequestInterceptor interceptor = new RequestAddCookies();
        interceptor.process(request, context);
 
        CookieSpec cookieSpec = (CookieSpec) context.getAttribute(
                ClientContext.COOKIE_SPEC);
        Assert.assertTrue(cookieSpec instanceof BrowserCompatSpec);
 
        Header[] headers1 = request.getHeaders(SM.COOKIE);
        Assert.assertNotNull(headers1);
5
CodeRank

Related Android BasicHttpContext Questions & Answers:

See Code Examples for Android BasicHttpContext Methods: