Skip to content

Commit

Permalink
Made basic authentication work for synchronous requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlkalberer committed May 21, 2013
1 parent 2ef2b28 commit 5d444cd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/com/loopj/android/http/AsyncHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.HttpEntityWrapper;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
Expand Down Expand Up @@ -266,8 +267,11 @@ public void setBasicAuth(String user, String pass){
*
*/
public void setBasicAuth( String user, String pass, AuthScope scope){
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user,pass);
this.httpClient.getCredentialsProvider().setCredentials(scope, credentials);
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user, pass);
Header header = BasicScheme.authenticate(credentials, "UTF-8", false);
this.addHeader(header.getName(), header.getValue());
//UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user,pass);
//this.httpClient.getCredentialsProvider().setCredentials(scope, credentials);
}

/**
Expand Down

0 comments on commit 5d444cd

Please sign in to comment.