Skip to content

Commit 4a7ac9d

Browse files
committed
android-async-http#988 additional changes as of comments in PR
1 parent c36c45b commit 4a7ac9d

File tree

4 files changed

+41
-14
lines changed

4 files changed

+41
-14
lines changed

library/src/main/java/com/loopj/android/http/AsyncHttpClient.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
import android.content.Context;
19-
import android.media.session.MediaSession;
2019
import android.os.Looper;
2120

2221
import java.io.IOException;
@@ -75,7 +74,6 @@
7574
import cz.msebera.android.httpclient.conn.ssl.SSLSocketFactory;
7675
import cz.msebera.android.httpclient.entity.HttpEntityWrapper;
7776
import cz.msebera.android.httpclient.impl.auth.BasicScheme;
78-
import cz.msebera.android.httpclient.impl.client.BasicCredentialsProvider;
7977
import cz.msebera.android.httpclient.impl.client.DefaultHttpClient;
8078
import cz.msebera.android.httpclient.impl.conn.tsccm.ThreadSafeClientConnManager;
8179
import cz.msebera.android.httpclient.params.BasicHttpParams;
@@ -264,11 +262,10 @@ public void process(final HttpRequest request, final HttpContext context) throws
264262
if (authState.getAuthScheme() == null) {
265263
AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
266264
Credentials creds = credsProvider.getCredentials(authScope);
267-
if(creds instanceof TokenCredentials) {
265+
if (creds instanceof TokenCredentials) {
268266
authState.setAuthScheme(new BearerAuthSchemeFactory.BearerAuthScheme());
269267
authState.setCredentials(creds);
270-
}
271-
else if (creds != null) {
268+
} else if (creds != null) {
272269
authState.setAuthScheme(new BasicScheme());
273270
authState.setCredentials(creds);
274271
}
@@ -803,6 +800,7 @@ public void removeHeader(String header) {
803800
/**
804801
* Sets bearer authentication for the request. Uses AuthScope.ANY. This is the same as
805802
* setBearerAuth('token',AuthScope.ANY, false)
803+
*
806804
* @param token Bearer Token
807805
*/
808806
public void setBearerAuth(String token) {
@@ -813,8 +811,9 @@ public void setBearerAuth(String token) {
813811
/**
814812
* Sets bearer authentication for the request. You should pass in your AuthScope for security. It
815813
* should be like this setBearerAuth("token", new AuthScope("host",port,AuthScope.ANY_REALM), false)
816-
* @param token Bearer Token
817-
* @param scope an AuthScope object
814+
*
815+
* @param token Bearer Token
816+
* @param scope an AuthScope object
818817
* @param preemptive sets authorization in preemptive manner
819818
*/
820819
public void setBearerAuth(String token, AuthScope scope, boolean preemptive) {

library/src/main/java/com/loopj/android/http/AsyncHttpResponseHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
* });
7979
* </pre>
8080
*/
81-
@SuppressWarnings("ALL")
81+
@SuppressWarnings("DesignForExtension")
8282
public abstract class AsyncHttpResponseHandler implements ResponseHandlerInterface {
8383

8484
public static final String DEFAULT_CHARSET = "UTF-8";

library/src/main/java/com/loopj/android/http/BearerAuthSchemeFactory.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
Android Asynchronous Http Client
3+
Copyright (c) 2011 James Smith <[email protected]>
4+
https://loopj.com
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
https://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
118
package com.loopj.android.http;
219

320
import cz.msebera.android.httpclient.Header;
@@ -14,9 +31,6 @@
1431
import cz.msebera.android.httpclient.protocol.HttpContext;
1532
import cz.msebera.android.httpclient.util.CharArrayBuffer;
1633

17-
/**
18-
* Created by chase on 08/10/2015.
19-
*/
2034
public class BearerAuthSchemeFactory implements AuthSchemeFactory {
2135

2236
@Override

library/src/main/java/com/loopj/android/http/TokenCredentials.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1+
/*
2+
Android Asynchronous Http Client
3+
Copyright (c) 2011 James Smith <[email protected]>
4+
https://loopj.com
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
https://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
118
package com.loopj.android.http;
219

3-
/**
4-
* Created by chase on 08/10/2015.
5-
*/
620
import java.security.Principal;
721

822
import cz.msebera.android.httpclient.auth.BasicUserPrincipal;

0 commit comments

Comments
 (0)