Using HttpClient 4 for Apache Basic Authentication

| No TrackBacks

private static DefaultHttpClient addAuth(DefaultHttpClient httpclient){
HttpRequestInterceptor preemptiveAuth = new HttpRequestInterceptor() {

public void process(final HttpRequest request,
final HttpContext context) throws HttpException,
IOException {

String username = "philipz";
String password = "XXXXXXXX";
UsernamePasswordCredentials ucreds = new UsernamePasswordCredentials(
username, password);
request.addHeader(new BasicScheme().authenticate(ucreds,
request));
}

};

httpclient.addRequestInterceptor(preemptiveAuth, 0);
return httpclient;
}

No TrackBacks

TrackBack URL: http://server.everfine.com.tw/blog/mt-tb.cgi/311

February 2012

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      

Archives

Powered by Movable Type 4.34-en

About this Entry

This page contains a single entry by philipz published on March 11, 2011 3:23 PM.

SQL: Update with Subquery was the previous entry in this blog.

台灣法拍屋行事曆 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.