Code example for DefaultHttpClient

Methods: getCredentialsProvidergetParamssetCookieStore

0
     */ 
    public BasicClient(String host, String username, String password, int portnum) {
    	if (portnum == 443) {
    		this.scheme = "https";
    	} 
        client = new DefaultHttpClient();
        client.getParams().setParameter(ClientPNames.DEFAULT_HOST, new HttpHost(host, portnum, scheme));
        HttpProtocolParams.setUserAgent(client.getParams(), "InSites Java Connection");
        client.setCookieStore(new BasicCookieStore());
 
        client.getCredentialsProvider().setCredentials(new AuthScope(host, portnum), new UsernamePasswordCredentials(username, password));
         
        //We can not use org.apache.commons.codec.binary.Base64, so use the equivalent Android encoder 
        authHeaderValue = "Basic " + Base64.encodeToString((username + ":" + password).getBytes(), Base64.NO_WRAP);
    } 
 
    /** 
     * Consumes an InputStream, and builds a String representation of the data. 
     *  
     * @param in	an InputStream to convert 
Stop searching for code, let great code find you!  Add Codota to your java IDE