Code example for BasicHttpContext

Methods: setAttribute

0
		// mClient.setAuthSchemes(authRegistry); 
		mClient.setCredentialsProvider(new BasicCredentialsProvider());
 
		// Generate BASIC scheme object and stick it to the local 
		// execution context 
		localcontext = new BasicHttpContext();
		localcontext.setAttribute("preemptive-auth", basicScheme);
 
		// first request interceptor 
		mClient.addRequestInterceptor(preemptiveAuth, 0);
	} 
 
	/** 
	 * HttpRequestInterceptor for DefaultHttpClient 默认HTTP客户端的请求拦截器 
	 */ 
	private HttpRequestInterceptor preemptiveAuth = new HttpRequestInterceptor() {
		@Override 
		public void process(final HttpRequest request, final HttpContext context) { 
			AuthState authState = (AuthState) context 
					.getAttribute(ClientContext.TARGET_AUTH_STATE); 
			CredentialsProvider credsProvider = (CredentialsProvider) context