You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2014/08/07 11:18:07 UTC
svn commit: r1616447 [1/2] - in
/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http:
client/protocol/ conn/ssl/ impl/auth/ impl/client/ impl/conn/
impl/execchain/ impl/io/
Author: olegk
Date: Thu Aug 7 09:18:06 2014
New Revision: 1616447
URL: http://svn.apache.org/r1616447
Log:
Replaced Commons Logging and Codec with Android logging and base64
Added:
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/DistinguishedNameParser.java (props changed)
- copied unchanged from r1616285, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/DistinguishedNameParser.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/TokenParser.java
- copied unchanged from r1616285, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/ssl/TokenParser.java
Modified:
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestAddCookiesHC4.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestClientConnControl.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/ResponseProcessCookiesHC4.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/AbstractVerifierHC4.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/BasicSchemeHC4.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/CPool.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/InMemoryDnsResolver.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/WireHC4.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/execchain/MainClientExec.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/execchain/MinimalClientExec.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/execchain/ProtocolExec.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/execchain/RetryExec.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/execchain/ServiceUnavailableRetryExec.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/io/AbstractMessageParserHC4.java
httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/io/ChunkedOutputStreamHC4.java
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestAddCookiesHC4.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestAddCookiesHC4.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestAddCookiesHC4.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestAddCookiesHC4.java Thu Aug 7 09:18:06 2014
@@ -34,8 +34,8 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.Header;
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
@@ -67,7 +67,7 @@ import org.apache.http.util.TextUtils;
@Immutable
public class RequestAddCookiesHC4 implements HttpRequestInterceptor {
- private final Log log = LogFactory.getLog(getClass());
+ private final static String TAG = "HttpClient";
public RequestAddCookiesHC4() {
super();
@@ -88,28 +88,36 @@ public class RequestAddCookiesHC4 implem
// Obtain cookie store
final CookieStore cookieStore = clientContext.getCookieStore();
if (cookieStore == null) {
- this.log.debug("Cookie store not specified in HTTP context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Cookie store not specified in HTTP context");
+ }
return;
}
// Obtain the registry of cookie specs
final Lookup<CookieSpecProvider> registry = clientContext.getCookieSpecRegistry();
if (registry == null) {
- this.log.debug("CookieSpec registry not specified in HTTP context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "CookieSpec registry not specified in HTTP context");
+ }
return;
}
// Obtain the target host, possibly virtual (required)
final HttpHost targetHost = clientContext.getTargetHost();
if (targetHost == null) {
- this.log.debug("Target host not set in the context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Target host not set in the context");
+ }
return;
}
// Obtain the route (required)
final RouteInfo route = clientContext.getHttpRoute();
if (route == null) {
- this.log.debug("Connection route not set in the context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connection route not set in the context");
+ }
return;
}
@@ -118,8 +126,8 @@ public class RequestAddCookiesHC4 implem
if (policy == null) {
policy = CookieSpecs.BEST_MATCH;
}
- if (this.log.isDebugEnabled()) {
- this.log.debug("CookieSpec selected: " + policy);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "CookieSpec selected: " + policy);
}
URI requestURI = null;
@@ -158,14 +166,14 @@ public class RequestAddCookiesHC4 implem
for (final Cookie cookie : cookies) {
if (!cookie.isExpired(now)) {
if (cookieSpec.match(cookie, cookieOrigin)) {
- if (this.log.isDebugEnabled()) {
- this.log.debug("Cookie " + cookie + " match " + cookieOrigin);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Cookie " + cookie + " match " + cookieOrigin);
}
matchedCookies.add(cookie);
}
} else {
- if (this.log.isDebugEnabled()) {
- this.log.debug("Cookie " + cookie + " expired");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Cookie " + cookie + " expired");
}
}
}
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java Thu Aug 7 09:18:06 2014
@@ -29,8 +29,8 @@ package org.apache.http.client.protocol;
import java.io.IOException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
@@ -57,7 +57,7 @@ import org.apache.http.util.Args;
@Immutable
public class RequestAuthCache implements HttpRequestInterceptor {
- private final Log log = LogFactory.getLog(getClass());
+ private final static String TAG = "HttpClient";
public RequestAuthCache() {
super();
@@ -72,25 +72,33 @@ public class RequestAuthCache implements
final AuthCache authCache = clientContext.getAuthCache();
if (authCache == null) {
- this.log.debug("Auth cache not set in the context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Auth cache not set in the context");
+ }
return;
}
final CredentialsProvider credsProvider = clientContext.getCredentialsProvider();
if (credsProvider == null) {
- this.log.debug("Credentials provider not set in the context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Credentials provider not set in the context");
+ }
return;
}
final RouteInfo route = clientContext.getHttpRoute();
if (route == null) {
- this.log.debug("Route info not set in the context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Route info not set in the context");
+ }
return;
}
HttpHost target = clientContext.getTargetHost();
if (target == null) {
- this.log.debug("Target host not set in the context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Target host not set in the context");
+ }
return;
}
@@ -125,8 +133,8 @@ public class RequestAuthCache implements
final AuthStateHC4 authState,
final CredentialsProvider credsProvider) {
final String schemeName = authScheme.getSchemeName();
- if (this.log.isDebugEnabled()) {
- this.log.debug("Re-using cached '" + schemeName + "' auth scheme for " + host);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Re-using cached '" + schemeName + "' auth scheme for " + host);
}
final AuthScope authScope = new AuthScope(host.getHostName(), host.getPort(), AuthScope.ANY_REALM, schemeName);
@@ -140,7 +148,9 @@ public class RequestAuthCache implements
}
authState.update(authScheme, creds);
} else {
- this.log.debug("No credentials for preemptive authentication");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "No credentials for preemptive authentication");
+ }
}
}
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestClientConnControl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestClientConnControl.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestClientConnControl.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/RequestClientConnControl.java Thu Aug 7 09:18:06 2014
@@ -29,8 +29,8 @@ package org.apache.http.client.protocol;
import java.io.IOException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
@@ -50,7 +50,7 @@ import org.apache.http.util.Args;
@Immutable
public class RequestClientConnControl implements HttpRequestInterceptor {
- private final Log log = LogFactory.getLog(getClass());
+ private final static String TAG = "HttpClient";
private static final String PROXY_CONN_DIRECTIVE = "Proxy-Connection";
@@ -73,7 +73,9 @@ public class RequestClientConnControl im
// Obtain the client connection (required)
final RouteInfo route = clientContext.getHttpRoute();
if (route == null) {
- this.log.debug("Connection route not set in the context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connection route not set in the context");
+ }
return;
}
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/ResponseProcessCookiesHC4.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/ResponseProcessCookiesHC4.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/ResponseProcessCookiesHC4.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/client/protocol/ResponseProcessCookiesHC4.java Thu Aug 7 09:18:06 2014
@@ -30,8 +30,8 @@ package org.apache.http.client.protocol;
import java.io.IOException;
import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.Header;
import org.apache.http.HeaderIterator;
import org.apache.http.HttpException;
@@ -56,7 +56,7 @@ import org.apache.http.util.Args;
@Immutable
public class ResponseProcessCookiesHC4 implements HttpResponseInterceptor {
- private final Log log = LogFactory.getLog(getClass());
+ private final static String TAG = "HttpClient";
public ResponseProcessCookiesHC4() {
super();
@@ -72,19 +72,25 @@ public class ResponseProcessCookiesHC4 i
// Obtain actual CookieSpec instance
final CookieSpec cookieSpec = clientContext.getCookieSpec();
if (cookieSpec == null) {
- this.log.debug("Cookie spec not specified in HTTP context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Cookie spec not specified in HTTP context");
+ }
return;
}
// Obtain cookie store
final CookieStore cookieStore = clientContext.getCookieStore();
if (cookieStore == null) {
- this.log.debug("Cookie store not specified in HTTP context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Cookie store not specified in HTTP context");
+ }
return;
}
// Obtain actual CookieOrigin instance
final CookieOrigin cookieOrigin = clientContext.getCookieOrigin();
if (cookieOrigin == null) {
- this.log.debug("Cookie origin not specified in HTTP context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Cookie origin not specified in HTTP context");
+ }
return;
}
HeaderIterator it = response.headerIterator(SM.SET_COOKIE);
@@ -113,19 +119,19 @@ public class ResponseProcessCookiesHC4 i
cookieSpec.validate(cookie, cookieOrigin);
cookieStore.addCookie(cookie);
- if (this.log.isDebugEnabled()) {
- this.log.debug("Cookie accepted [" + formatCooke(cookie) + "]");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Cookie accepted [" + formatCooke(cookie) + "]");
}
} catch (final MalformedCookieException ex) {
- if (this.log.isWarnEnabled()) {
- this.log.warn("Cookie rejected [" + formatCooke(cookie) + "] "
+ if (Log.isLoggable(TAG, Log.WARN)) {
+ Log.w(TAG, "Cookie rejected [" + formatCooke(cookie) + "] "
+ ex.getMessage());
}
}
}
} catch (final MalformedCookieException ex) {
- if (this.log.isWarnEnabled()) {
- this.log.warn("Invalid cookie header: \""
+ if (Log.isLoggable(TAG, Log.WARN)) {
+ Log.w(TAG, "Invalid cookie header: \""
+ header + "\". " + ex.getMessage());
}
}
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/AbstractVerifierHC4.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/AbstractVerifierHC4.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/AbstractVerifierHC4.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/AbstractVerifierHC4.java Thu Aug 7 09:18:06 2014
@@ -41,22 +41,17 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
-import java.util.NoSuchElementException;
-import javax.naming.InvalidNameException;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.ldap.LdapName;
-import javax.naming.ldap.Rdn;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
+import org.apache.http.NameValuePair;
import org.apache.http.annotation.Immutable;
import org.apache.http.conn.util.InetAddressUtilsHC4;
+import org.apache.http.util.TextUtils;
/**
* Abstract base class for all standard {@link X509HostnameVerifier}
@@ -86,7 +81,7 @@ public abstract class AbstractVerifierHC
Arrays.sort(BAD_COUNTRY_2LDS);
}
- private final Log log = LogFactory.getLog(getClass());
+ private final static String TAG = "HttpClient";
public AbstractVerifierHC4() {
super();
@@ -273,26 +268,17 @@ public abstract class AbstractVerifierHC
return null;
}
final List<String> cns = new ArrayList<String>();
- try {
- final LdapName subjectDN = new LdapName(subjectPrincipal);
- final List<Rdn> rdns = subjectDN.getRdns();
- for (int i = rdns.size() - 1; i >= 0; i--) {
- final Rdn rds = rdns.get(i);
- final Attributes attributes = rds.toAttributes();
- final Attribute cn = attributes.get("cn");
- if (cn != null) {
- try {
- final Object value = cn.get();
- if (value != null) {
- cns.add(value.toString());
- }
- } catch (NoSuchElementException ignore) {
- } catch (NamingException ignore) {
- }
- }
+ final List<NameValuePair> nvps = DistinguishedNameParser.INSTANCE.parse(subjectPrincipal);
+ for (int i = 0; i < nvps.size(); i++) {
+ final NameValuePair nvp = nvps.get(i);
+ final String attribName = nvp.getName();
+ final String attribValue = nvp.getValue();
+ if (TextUtils.isBlank(attribValue)) {
+ throw new SSLException(subjectPrincipal + " is not a valid X500 distinguished name");
+ }
+ if (attribName.equalsIgnoreCase("cn")) {
+ cns.add(attribValue);
}
- } catch (InvalidNameException e) {
- throw new SSLException(subjectPrincipal + " is not a valid X500 distinguished name");
}
return cns.isEmpty() ? null : cns.toArray(new String[ cns.size() ]);
}
@@ -390,7 +376,7 @@ public abstract class AbstractVerifierHC
final InetAddress inetAddress = InetAddress.getByName(hostname);
return inetAddress.getHostAddress();
} catch (final UnknownHostException uhe) { // Should not happen, because we check for IPv6 address above
- log.error("Unexpected error converting "+hostname, uhe);
+ Log.e(TAG, "Unexpected error converting "+hostname, uhe);
return hostname;
}
}
Propchange: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/DistinguishedNameParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/DistinguishedNameParser.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/DistinguishedNameParser.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Aug 7 09:18:06 2014
@@ -0,0 +1,6 @@
+/httpcomponents/httpclient/branches/4.0.x/httpclient/src/main/java/org/apache/http/conn/ssl/DistinguishedNameParser.java:950681-950688
+/httpcomponents/httpclient/branches/4.1.x/httpclient/src/main/java/org/apache/http/conn/ssl/DistinguishedNameParser.java:1079518-1080165
+/httpcomponents/httpclient/branches/4.2.x/httpclient/src/main/java/org/apache/http/conn/ssl/DistinguishedNameParser.java:1376150-1376151,1447062
+/httpcomponents/httpclient/branches/branch_4_1/httpclient/src/main/java/org/apache/http/conn/ssl/DistinguishedNameParser.java:755593-811107
+/httpcomponents/httpclient/branches/conn-mgmt-redesign/httpclient/src/main/java/org/apache/http/conn/ssl/DistinguishedNameParser.java:1154913-1160573
+/httpcomponents/httpclient/branches/notice-plugin-test/httpclient/src/main/java/org/apache/http/conn/ssl/DistinguishedNameParser.java:1024348-1031454
Propchange: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/conn/ssl/DistinguishedNameParser.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/BasicSchemeHC4.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/BasicSchemeHC4.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/BasicSchemeHC4.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/BasicSchemeHC4.java Thu Aug 7 09:18:06 2014
@@ -28,7 +28,7 @@ package org.apache.http.impl.auth;
import java.nio.charset.Charset;
-import org.apache.commons.codec.binary.Base64;
+import android.util.Base64;
import org.apache.http.Consts;
import org.apache.http.Header;
import org.apache.http.HttpRequest;
@@ -53,7 +53,6 @@ import org.apache.http.util.EncodingUtil
@NotThreadSafe
public class BasicSchemeHC4 extends RFC2617SchemeHC4 {
- private final Base64 base64codec;
/** Whether the basic authentication process is complete */
private boolean complete;
@@ -62,7 +61,6 @@ public class BasicSchemeHC4 extends RFC2
*/
public BasicSchemeHC4(final Charset credentialsCharset) {
super(credentialsCharset);
- this.base64codec = new Base64();
this.complete = false;
}
@@ -77,7 +75,6 @@ public class BasicSchemeHC4 extends RFC2
@Deprecated
public BasicSchemeHC4(final ChallengeState challengeState) {
super(challengeState);
- this.base64codec = new Base64();
}
public BasicSchemeHC4() {
@@ -162,8 +159,9 @@ public class BasicSchemeHC4 extends RFC2
tmp.append(":");
tmp.append((credentials.getPassword() == null) ? "null" : credentials.getPassword());
- final byte[] base64password = base64codec.encode(
- EncodingUtils.getBytes(tmp.toString(), getCredentialsCharset(request)));
+ final byte[] base64password = Base64.decode(
+ EncodingUtils.getBytes(tmp.toString(), getCredentialsCharset(request)),
+ Base64.NO_WRAP);
final CharArrayBuffer buffer = new CharArrayBuffer(32);
if (isProxy()) {
@@ -201,8 +199,9 @@ public class BasicSchemeHC4 extends RFC2
tmp.append(":");
tmp.append((credentials.getPassword() == null) ? "null" : credentials.getPassword());
- final byte[] base64password = Base64.encodeBase64(
- EncodingUtils.getBytes(tmp.toString(), charset), false);
+ final byte[] base64password = Base64.encode(
+ EncodingUtils.getBytes(tmp.toString(), charset),
+ Base64.NO_WRAP);
final CharArrayBuffer buffer = new CharArrayBuffer(32);
if (proxy) {
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java Thu Aug 7 09:18:06 2014
@@ -32,8 +32,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.Queue;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.Header;
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
@@ -56,15 +56,10 @@ import org.apache.http.util.Asserts;
*/
public class HttpAuthenticator {
- private final Log log;
-
- public HttpAuthenticator(final Log log) {
- super();
- this.log = log != null ? log : LogFactory.getLog(getClass());
- }
+ private final static String TAG = "HttpClient";
public HttpAuthenticator() {
- this(null);
+ super();
}
public boolean isAuthenticationRequested(
@@ -74,7 +69,9 @@ public class HttpAuthenticator {
final AuthStateHC4 authState,
final HttpContext context) {
if (authStrategy.isAuthenticationRequested(host, response, context)) {
- this.log.debug("Authentication required");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Authentication required");
+ }
if (authState.getState() == AuthProtocolState.SUCCESS) {
authStrategy.authFailed(host, authState.getAuthScheme(), context);
}
@@ -83,7 +80,9 @@ public class HttpAuthenticator {
switch (authState.getState()) {
case CHALLENGED:
case HANDSHAKE:
- this.log.debug("Authentication succeeded");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Authentication succeeded");
+ }
authState.setState(AuthProtocolState.SUCCESS);
authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
break;
@@ -103,12 +102,14 @@ public class HttpAuthenticator {
final AuthStateHC4 authState,
final HttpContext context) {
try {
- if (this.log.isDebugEnabled()) {
- this.log.debug(host.toHostString() + " requested authentication");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, host.toHostString() + " requested authentication");
}
final Map<String, Header> challenges = authStrategy.getChallenges(host, response, context);
if (challenges.isEmpty()) {
- this.log.debug("Response contains no authentication challenges");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Response contains no authentication challenges");
+ }
return false;
}
@@ -122,7 +123,9 @@ public class HttpAuthenticator {
case CHALLENGED:
case HANDSHAKE:
if (authScheme == null) {
- this.log.debug("Auth scheme is null");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Auth scheme is null");
+ }
authStrategy.authFailed(host, null, context);
authState.reset();
authState.setState(AuthProtocolState.FAILURE);
@@ -133,10 +136,14 @@ public class HttpAuthenticator {
final String id = authScheme.getSchemeName();
final Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
if (challenge != null) {
- this.log.debug("Authorization challenge processed");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Authorization challenge processed");
+ }
authScheme.processChallenge(challenge);
if (authScheme.isComplete()) {
- this.log.debug("Authentication failed");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Authentication failed");
+ }
authStrategy.authFailed(host, authState.getAuthScheme(), context);
authState.reset();
authState.setState(AuthProtocolState.FAILURE);
@@ -153,8 +160,8 @@ public class HttpAuthenticator {
}
final Queue<AuthOption> authOptions = authStrategy.select(challenges, host, response, context);
if (authOptions != null && !authOptions.isEmpty()) {
- if (this.log.isDebugEnabled()) {
- this.log.debug("Selected authentication options: " + authOptions);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Selected authentication options: " + authOptions);
}
authState.setState(AuthProtocolState.CHALLENGED);
authState.update(authOptions);
@@ -163,8 +170,8 @@ public class HttpAuthenticator {
return false;
}
} catch (final MalformedChallengeException ex) {
- if (this.log.isWarnEnabled()) {
- this.log.warn("Malformed challenge: " + ex.getMessage());
+ if (Log.isLoggable(TAG, Log.WARN)) {
+ Log.w(TAG, "Malformed challenge: " + ex.getMessage());
}
authState.reset();
return false;
@@ -194,8 +201,8 @@ public class HttpAuthenticator {
authScheme = authOption.getAuthScheme();
creds = authOption.getCredentials();
authState.update(authScheme, creds);
- if (this.log.isDebugEnabled()) {
- this.log.debug("Generating response to an authentication challenge using "
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Generating response to an authentication challenge using "
+ authScheme.getSchemeName() + " scheme");
}
try {
@@ -203,8 +210,8 @@ public class HttpAuthenticator {
request.addHeader(header);
break;
} catch (final AuthenticationException ex) {
- if (this.log.isWarnEnabled()) {
- this.log.warn(authScheme + " authentication error: " + ex.getMessage());
+ if (Log.isLoggable(TAG, Log.WARN)) {
+ Log.w(TAG, authScheme + " authentication error: " + ex.getMessage());
}
}
}
@@ -218,8 +225,8 @@ public class HttpAuthenticator {
final Header header = doAuth(authScheme, creds, request, context);
request.addHeader(header);
} catch (final AuthenticationException ex) {
- if (this.log.isErrorEnabled()) {
- this.log.error(authScheme + " authentication error: " + ex.getMessage());
+ if (Log.isLoggable(TAG, Log.ERROR)) {
+ Log.e(TAG, authScheme + " authentication error: " + ex.getMessage());
}
}
}
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java Thu Aug 7 09:18:06 2014
@@ -35,7 +35,7 @@ import java.util.Locale;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
-import org.apache.commons.codec.binary.Base64;
+import android.util.Base64;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.util.EncodingUtils;
@@ -843,8 +843,8 @@ final class NTLMEngineImpl implements NT
/** Constructor to use when message contents are known */
NTLMMessage(final String messageBody, final int expectedType) throws NTLMEngineException {
- messageContents = Base64.decodeBase64(EncodingUtils.getBytes(messageBody,
- DEFAULT_CHARSET));
+ messageContents = Base64.decode(EncodingUtils.getBytes(messageBody, DEFAULT_CHARSET),
+ Base64.NO_WRAP);
// Look for NTLM message
if (messageContents.length < SIGNATURE.length) {
throw new NTLMEngineException("NTLM message decoding error - packet too short");
@@ -983,7 +983,7 @@ final class NTLMEngineImpl implements NT
} else {
resp = messageContents;
}
- return EncodingUtils.getAsciiString(Base64.encodeBase64(resp));
+ return EncodingUtils.getAsciiString(Base64.encode(resp, Base64.NO_WRAP));
}
}
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java Thu Aug 7 09:18:06 2014
@@ -37,8 +37,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.Queue;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.FormattedHeader;
import org.apache.http.Header;
import org.apache.http.HttpHost;
@@ -65,7 +65,7 @@ import org.apache.http.util.CharArrayBuf
@Immutable
abstract class AuthenticationStrategyImpl implements AuthenticationStrategy {
- private final Log log = LogFactory.getLog(getClass());
+ private final static String TAG = "HttpClient";
private static final List<String> DEFAULT_SCHEME_PRIORITY =
Collections.unmodifiableList(Arrays.asList(AuthSchemes.SPNEGO,
@@ -144,12 +144,16 @@ abstract class AuthenticationStrategyImp
final Queue<AuthOption> options = new LinkedList<AuthOption>();
final Lookup<AuthSchemeProvider> registry = clientContext.getAuthSchemeRegistry();
if (registry == null) {
- this.log.debug("Auth scheme registry not set in the context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Auth scheme registry not set in the context");
+ }
return options;
}
final CredentialsProvider credsProvider = clientContext.getCredentialsProvider();
if (credsProvider == null) {
- this.log.debug("Credentials provider not set in the context");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Credentials provider not set in the context");
+ }
return options;
}
final RequestConfig config = clientContext.getRequestConfig();
@@ -157,8 +161,8 @@ abstract class AuthenticationStrategyImp
if (authPrefs == null) {
authPrefs = DEFAULT_SCHEME_PRIORITY;
}
- if (this.log.isDebugEnabled()) {
- this.log.debug("Authentication schemes in the order of preference: " + authPrefs);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Authentication schemes in the order of preference: " + authPrefs);
}
for (final String id: authPrefs) {
@@ -166,8 +170,8 @@ abstract class AuthenticationStrategyImp
if (challenge != null) {
final AuthSchemeProvider authSchemeProvider = registry.lookup(id);
if (authSchemeProvider == null) {
- if (this.log.isWarnEnabled()) {
- this.log.warn("Authentication scheme " + id + " not supported");
+ if (Log.isLoggable(TAG, Log.WARN)) {
+ Log.w(TAG, "Authentication scheme " + id + " not supported");
// Try again
}
continue;
@@ -186,8 +190,8 @@ abstract class AuthenticationStrategyImp
options.add(new AuthOption(authScheme, credentials));
}
} else {
- if (this.log.isDebugEnabled()) {
- this.log.debug("Challenge for " + id + " authentication scheme not available");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Challenge for " + id + " authentication scheme not available");
// Try again
}
}
@@ -209,8 +213,8 @@ abstract class AuthenticationStrategyImp
authCache = new BasicAuthCache();
clientContext.setAuthCache(authCache);
}
- if (this.log.isDebugEnabled()) {
- this.log.debug("Caching '" + authScheme.getSchemeName() +
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Caching '" + authScheme.getSchemeName() +
"' auth scheme for " + authhost);
}
authCache.put(authhost, authScheme);
@@ -235,8 +239,8 @@ abstract class AuthenticationStrategyImp
final AuthCache authCache = clientContext.getAuthCache();
if (authCache != null) {
- if (this.log.isDebugEnabled()) {
- this.log.debug("Clearing cached auth scheme for " + authhost);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Clearing cached auth scheme for " + authhost);
}
authCache.remove(authhost);
}
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java Thu Aug 7 09:18:06 2014
@@ -32,8 +32,8 @@ import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
import java.net.URI;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
@@ -57,7 +57,7 @@ import org.apache.http.util.EntityUtilsH
@ThreadSafe
public abstract class CloseableHttpClient implements HttpClient, Closeable {
- private final Log log = LogFactory.getLog(getClass());
+ private final static String TAG = "HttpClient";
protected abstract CloseableHttpResponse doExecute(HttpHost target, HttpRequest request,
HttpContext context) throws IOException, ClientProtocolException;
@@ -223,7 +223,9 @@ public abstract class CloseableHttpClien
} catch (final Exception t2) {
// Log this exception. The original exception is more
// important and will be thrown to the caller.
- this.log.warn("Error consuming content after an exception.", t2);
+ if (Log.isLoggable(TAG, Log.WARN)) {
+ Log.w(TAG, "Error consuming content after an exception.", t2);
+ }
}
if (t instanceof RuntimeException) {
throw (RuntimeException) t;
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java Thu Aug 7 09:18:06 2014
@@ -31,8 +31,8 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.Locale;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
@@ -72,7 +72,7 @@ import org.apache.http.util.TextUtils;
@Immutable
public class DefaultRedirectStrategy implements RedirectStrategy {
- private final Log log = LogFactory.getLog(getClass());
+ private final static String TAG = "HttpClient";
/**
* @deprecated (4.3) use {@link org.apache.http.client.protocol.HttpClientContext#REDIRECT_LOCATIONS}.
@@ -136,8 +136,8 @@ public class DefaultRedirectStrategy imp
+ " but no location header");
}
final String location = locationHeader.getValue();
- if (this.log.isDebugEnabled()) {
- this.log.debug("Redirect requested to location '" + location + "'");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Redirect requested to location '" + location + "'");
}
final RequestConfig config = clientContext.getRequestConfig();
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/InternalHttpClient.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/InternalHttpClient.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/client/InternalHttpClient.java Thu Aug 7 09:18:06 2014
@@ -32,8 +32,8 @@ import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.HttpException;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
@@ -76,7 +76,7 @@ import org.apache.http.util.Args;
@SuppressWarnings("deprecation")
class InternalHttpClient extends CloseableHttpClient {
- private final Log log = LogFactory.getLog(getClass());
+ private final static String TAG = "HttpClient";
private final ClientExecChain execChain;
private final HttpClientConnectionManager connManager;
@@ -194,7 +194,7 @@ class InternalHttpClient extends Closeab
try {
closeable.close();
} catch (final IOException ex) {
- this.log.error(ex.getMessage(), ex);
+ Log.e(TAG, ex.getMessage(), ex);
}
}
}
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/BasicHttpClientConnectionManager.java Thu Aug 7 09:18:06 2014
@@ -34,8 +34,8 @@ import java.util.Date;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.HttpClientConnection;
import org.apache.http.HttpHost;
import org.apache.http.annotation.GuardedBy;
@@ -79,7 +79,7 @@ import org.apache.http.util.LangUtils;
@ThreadSafe
public class BasicHttpClientConnectionManager implements HttpClientConnectionManager, Closeable {
- private final Log log = LogFactory.getLog(getClass());
+ private final static String TAG = "HttpClient";
private final HttpClientConnectionOperator connectionOperator;
private final HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory;
@@ -205,12 +205,14 @@ public class BasicHttpClientConnectionMa
private void closeConnection() {
if (this.conn != null) {
- this.log.debug("Closing connection");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Closing connection");
+ }
try {
this.conn.close();
} catch (final IOException iox) {
- if (this.log.isDebugEnabled()) {
- this.log.debug("I/O exception closing connection", iox);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "I/O exception closing connection", iox);
}
}
this.conn = null;
@@ -219,12 +221,14 @@ public class BasicHttpClientConnectionMa
private void shutdownConnection() {
if (this.conn != null) {
- this.log.debug("Shutting down connection");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Shutting down connection");
+ }
try {
this.conn.shutdown();
} catch (final IOException iox) {
- if (this.log.isDebugEnabled()) {
- this.log.debug("I/O exception shutting down connection", iox);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "I/O exception shutting down connection", iox);
}
}
this.conn = null;
@@ -233,8 +237,8 @@ public class BasicHttpClientConnectionMa
private void checkExpiry() {
if (this.conn != null && System.currentTimeMillis() >= this.expiry) {
- if (this.log.isDebugEnabled()) {
- this.log.debug("Connection expired @ " + new Date(this.expiry));
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connection expired @ " + new Date(this.expiry));
}
closeConnection();
}
@@ -242,8 +246,8 @@ public class BasicHttpClientConnectionMa
synchronized HttpClientConnection getConnection(final HttpRoute route, final Object state) {
Asserts.check(!this.isShutdown.get(), "Connection manager has been shut down");
- if (this.log.isDebugEnabled()) {
- this.log.debug("Get connection for route " + route);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Get connection for route " + route);
}
Asserts.check(!this.leased, "Connection is still allocated");
if (!LangUtils.equals(this.route, route) || !LangUtils.equals(this.state, state)) {
@@ -265,8 +269,8 @@ public class BasicHttpClientConnectionMa
final long keepalive, final TimeUnit tunit) {
Args.notNull(conn, "Connection");
Asserts.check(conn == this.conn, "Connection not obtained from this manager");
- if (this.log.isDebugEnabled()) {
- this.log.debug("Releasing connection " + conn);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Releasing connection " + conn);
}
if (this.isShutdown.get()) {
return;
@@ -280,14 +284,14 @@ public class BasicHttpClientConnectionMa
this.expiry = Long.MAX_VALUE;
} else {
this.state = state;
- if (this.log.isDebugEnabled()) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
final String s;
if (keepalive > 0) {
s = "for " + keepalive + " " + tunit;
} else {
s = "indefinitely";
}
- this.log.debug("Connection can be kept alive " + s);
+ Log.d(TAG, "Connection can be kept alive " + s);
}
if (keepalive > 0) {
this.expiry = this.updated + tunit.toMillis(keepalive);
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/CPool.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/CPool.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/CPool.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/CPool.java Thu Aug 7 09:18:06 2014
@@ -29,8 +29,8 @@ package org.apache.http.impl.conn;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.conn.ManagedHttpClientConnection;
import org.apache.http.conn.routing.HttpRoute;
@@ -45,7 +45,6 @@ class CPool extends AbstractConnPool<Htt
private static final AtomicLong COUNTER = new AtomicLong();
- private final Log log = LogFactory.getLog(CPool.class);
private final long timeToLive;
private final TimeUnit tunit;
@@ -61,7 +60,7 @@ class CPool extends AbstractConnPool<Htt
@Override
protected CPoolEntry createEntry(final HttpRoute route, final ManagedHttpClientConnection conn) {
final String id = Long.toString(COUNTER.getAndIncrement());
- return new CPoolEntry(this.log, id, route, conn, this.timeToLive, this.tunit);
+ return new CPoolEntry(id, route, conn, this.timeToLive, this.tunit);
}
}
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/CPoolEntry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/CPoolEntry.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/CPoolEntry.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/CPoolEntry.java Thu Aug 7 09:18:06 2014
@@ -30,7 +30,7 @@ import java.io.IOException;
import java.util.Date;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.logging.Log;
+import android.util.Log;
import org.apache.http.HttpClientConnection;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.conn.ManagedHttpClientConnection;
@@ -43,17 +43,16 @@ import org.apache.http.pool.PoolEntry;
@ThreadSafe
class CPoolEntry extends PoolEntry<HttpRoute, ManagedHttpClientConnection> {
- private final Log log;
+ private final static String TAG = "HttpClient";
+
private volatile boolean routeComplete;
public CPoolEntry(
- final Log log,
final String id,
final HttpRoute route,
final ManagedHttpClientConnection conn,
final long timeToLive, final TimeUnit tunit) {
super(id, route, conn, timeToLive, tunit);
- this.log = log;
}
public void markRouteComplete() {
@@ -77,8 +76,8 @@ class CPoolEntry extends PoolEntry<HttpR
@Override
public boolean isExpired(final long now) {
final boolean expired = super.isExpired(now);
- if (expired && this.log.isDebugEnabled()) {
- this.log.debug("Connection " + this + " expired @ " + new Date(getExpiry()));
+ if (expired && Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connection " + this + " expired @ " + new Date(getExpiry()));
}
return expired;
}
@@ -94,7 +93,9 @@ class CPoolEntry extends PoolEntry<HttpR
try {
closeConnection();
} catch (final IOException ex) {
- this.log.debug("I/O error closing connection", ex);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "I/O error closing connection", ex);
+ }
}
}
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/DefaultHttpResponseParser.java Thu Aug 7 09:18:06 2014
@@ -29,8 +29,8 @@ package org.apache.http.impl.conn;
import java.io.IOException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.HttpException;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseFactory;
@@ -58,7 +58,7 @@ import org.apache.http.util.CharArrayBuf
@NotThreadSafe
public class DefaultHttpResponseParser extends AbstractMessageParserHC4<HttpResponse> {
- private final Log log = LogFactory.getLog(getClass());
+ private final static String TAG = "HttpClient";
private final HttpResponseFactory responseFactory;
private final CharArrayBuffer lineBuf;
@@ -151,8 +151,8 @@ public class DefaultHttpResponseParser e
throw new ProtocolException("The server failed to respond with a " +
"valid HTTP response");
}
- if (this.log.isDebugEnabled()) {
- this.log.debug("Garbage in response: " + this.lineBuf.toString());
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Garbage in response: " + this.lineBuf.toString());
}
count++;
} while(true);
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/HttpClientConnectionOperator.java Thu Aug 7 09:18:06 2014
@@ -34,8 +34,8 @@ import java.net.Socket;
import java.net.SocketTimeoutException;
import java.util.Arrays;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.HttpHost;
import org.apache.http.annotation.Immutable;
import org.apache.http.client.protocol.HttpClientContext;
@@ -57,7 +57,7 @@ class HttpClientConnectionOperator {
static final String SOCKET_FACTORY_REGISTRY = "http.socket-factory-registry";
- private final Log log = LogFactory.getLog(getClass());
+ private final static String TAG = "HttpClient";
private final Lookup<ConnectionSocketFactory> socketFactoryRegistry;
private final SchemePortResolver schemePortResolver;
@@ -117,15 +117,15 @@ class HttpClientConnectionOperator {
conn.bind(sock);
final InetSocketAddress remoteAddress = new InetSocketAddress(address, port);
- if (this.log.isDebugEnabled()) {
- this.log.debug("Connecting to " + remoteAddress);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connecting to " + remoteAddress);
}
try {
sock = sf.connectSocket(
connectTimeout, sock, host, remoteAddress, localAddress, context);
conn.bind(sock);
- if (this.log.isDebugEnabled()) {
- this.log.debug("Connection established " + conn);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connection established " + conn);
}
return;
} catch (final SocketTimeoutException ex) {
@@ -147,8 +147,8 @@ class HttpClientConnectionOperator {
}
}
}
- if (this.log.isDebugEnabled()) {
- this.log.debug("Connect to " + remoteAddress + " timed out. " +
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connect to " + remoteAddress + " timed out. " +
"Connection will be retried using another IP address");
}
}
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/InMemoryDnsResolver.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/InMemoryDnsResolver.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/InMemoryDnsResolver.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/InMemoryDnsResolver.java Thu Aug 7 09:18:06 2014
@@ -32,8 +32,8 @@ import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.conn.DnsResolver;
import org.apache.http.util.Args;
@@ -45,7 +45,7 @@ import org.apache.http.util.Args;
public class InMemoryDnsResolver implements DnsResolver {
/** Logger associated to this class. */
- private final Log log = LogFactory.getLog(InMemoryDnsResolver.class);
+ private final static String TAG = "HttpClient";
/**
* In-memory collection that will hold the associations between a host name
@@ -82,8 +82,8 @@ public class InMemoryDnsResolver impleme
*/
public InetAddress[] resolve(final String host) throws UnknownHostException {
final InetAddress[] resolvedAddresses = dnsMap.get(host);
- if (log.isInfoEnabled()) {
- log.info("Resolving " + host + " to " + Arrays.deepToString(resolvedAddresses));
+ if (Log.isLoggable(TAG, Log.INFO)) {
+ Log.i(TAG, "Resolving " + host + " to " + Arrays.deepToString(resolvedAddresses));
}
if(resolvedAddresses == null){
throw new UnknownHostException(host + " cannot be resolved");
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/LoggingManagedHttpClientConnection.java Thu Aug 7 09:18:06 2014
@@ -27,7 +27,7 @@
package org.apache.http.impl.conn;
-import org.apache.commons.logging.Log;
+import android.util.Log;
import org.apache.http.Header;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
@@ -47,15 +47,12 @@ import java.nio.charset.CharsetEncoder;
@NotThreadSafe
class LoggingManagedHttpClientConnection extends DefaultManagedHttpClientConnection {
- private final Log log;
- private final Log headerlog;
+ private final static String TAG = "HttpClient";
+ private final static String HEADER_TAG = "Headers";
private final WireHC4 wire;
public LoggingManagedHttpClientConnection(
final String id,
- final Log log,
- final Log headerlog,
- final Log wirelog,
final int buffersize,
final int fragmentSizeHint,
final CharsetDecoder chardecoder,
@@ -68,23 +65,21 @@ class LoggingManagedHttpClientConnection
super(id, buffersize, fragmentSizeHint, chardecoder, charencoder,
constraints, incomingContentStrategy, outgoingContentStrategy,
requestWriterFactory, responseParserFactory);
- this.log = log;
- this.headerlog = headerlog;
- this.wire = new WireHC4(wirelog, id);
+ this.wire = new WireHC4(id);
}
@Override
public void close() throws IOException {
- if (this.log.isDebugEnabled()) {
- this.log.debug(getId() + ": Close connection");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, getId() + ": Close connection");
}
super.close();
}
@Override
public void shutdown() throws IOException {
- if (this.log.isDebugEnabled()) {
- this.log.debug(getId() + ": Shutdown connection");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, getId() + ": Shutdown connection");
}
super.shutdown();
}
@@ -109,22 +104,22 @@ class LoggingManagedHttpClientConnection
@Override
protected void onResponseReceived(final HttpResponse response) {
- if (response != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(getId() + " << " + response.getStatusLine().toString());
+ if (response != null && Log.isLoggable(HEADER_TAG, Log.DEBUG)) {
+ Log.d(HEADER_TAG, getId() + " << " + response.getStatusLine().toString());
final Header[] headers = response.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(getId() + " << " + header.toString());
+ Log.d(HEADER_TAG, getId() + " << " + header.toString());
}
}
}
@Override
protected void onRequestSubmitted(final HttpRequest request) {
- if (request != null && this.headerlog.isDebugEnabled()) {
- this.headerlog.debug(getId() + " >> " + request.getRequestLine().toString());
+ if (request != null && Log.isLoggable(HEADER_TAG, Log.DEBUG)) {
+ Log.d(HEADER_TAG, getId() + " >> " + request.getRequestLine().toString());
final Header[] headers = request.getAllHeaders();
for (final Header header : headers) {
- this.headerlog.debug(getId() + " >> " + header.toString());
+ Log.d(HEADER_TAG, getId() + " >> " + header.toString());
}
}
}
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/ManagedHttpClientConnectionFactory.java Thu Aug 7 09:18:06 2014
@@ -33,8 +33,6 @@ import java.nio.charset.CharsetEncoder;
import java.nio.charset.CodingErrorAction;
import java.util.concurrent.atomic.AtomicLong;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.annotation.Immutable;
@@ -58,10 +56,6 @@ public class ManagedHttpClientConnection
public static final ManagedHttpClientConnectionFactory INSTANCE = new ManagedHttpClientConnectionFactory();
- private final Log log = LogFactory.getLog(DefaultManagedHttpClientConnection.class);
- private final Log headerlog = LogFactory.getLog("org.apache.http.headers");
- private final Log wirelog = LogFactory.getLog("org.apache.http.wire");
-
private final HttpMessageWriterFactory<HttpRequest> requestWriterFactory;
private final HttpMessageParserFactory<HttpResponse> responseParserFactory;
@@ -104,9 +98,6 @@ public class ManagedHttpClientConnection
final String id = "http-outgoing-" + Long.toString(COUNTER.getAndIncrement());
return new LoggingManagedHttpClientConnection(
id,
- log,
- headerlog,
- wirelog,
cconfig.getBufferSize(),
cconfig.getFragmentSizeHint(),
chardecoder,
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.java Thu Aug 7 09:18:06 2014
@@ -37,8 +37,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import android.util.Log;
+
import org.apache.http.HttpClientConnection;
import org.apache.http.HttpHost;
import org.apache.http.annotation.ThreadSafe;
@@ -87,7 +87,7 @@ import org.apache.http.util.Asserts;
public class PoolingHttpClientConnectionManager
implements HttpClientConnectionManager, ConnPoolControl<HttpRoute>, Closeable {
- private final Log log = LogFactory.getLog(getClass());
+ private final static String TAG = "HttpClient";
private final ConfigData configData;
private final CPool pool;
@@ -215,8 +215,8 @@ public class PoolingHttpClientConnection
final HttpRoute route,
final Object state) {
Args.notNull(route, "HTTP route");
- if (this.log.isDebugEnabled()) {
- this.log.debug("Connection request: " + format(route, state) + formatStats(route));
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connection request: " + format(route, state) + formatStats(route));
}
final Future<CPoolEntry> future = this.pool.lease(route, state, null);
return new ConnectionRequest() {
@@ -246,8 +246,8 @@ public class PoolingHttpClientConnection
throw new InterruptedException();
}
Asserts.check(entry.getConnection() != null, "Pool entry with no connection");
- if (this.log.isDebugEnabled()) {
- this.log.debug("Connection leased: " + format(entry) + formatStats(entry.getRoute()));
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connection leased: " + format(entry) + formatStats(entry.getRoute()));
}
return CPoolProxy.newProxy(entry);
} catch (final TimeoutException ex) {
@@ -270,20 +270,20 @@ public class PoolingHttpClientConnection
if (conn.isOpen()) {
entry.setState(state);
entry.updateExpiry(keepalive, tunit != null ? tunit : TimeUnit.MILLISECONDS);
- if (this.log.isDebugEnabled()) {
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
final String s;
if (keepalive > 0) {
s = "for " + (double) keepalive / 1000 + " seconds";
} else {
s = "indefinitely";
}
- this.log.debug("Connection " + format(entry) + " can be kept alive " + s);
+ Log.d(TAG, "Connection " + format(entry) + " can be kept alive " + s);
}
}
} finally {
this.pool.release(entry, conn.isOpen() && entry.isRouteComplete());
- if (this.log.isDebugEnabled()) {
- this.log.debug("Connection released: " + format(entry) + formatStats(entry.getRoute()));
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connection released: " + format(entry) + formatStats(entry.getRoute()));
}
}
}
@@ -347,25 +347,31 @@ public class PoolingHttpClientConnection
public void shutdown() {
if (this.isShutDown.compareAndSet(false, true)) {
- this.log.debug("Connection manager is shutting down");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connection manager is shutting down");
+ }
try {
this.pool.shutdown();
} catch (final IOException ex) {
- this.log.debug("I/O exception shutting down connection manager", ex);
+ Log.d(TAG, "I/O exception shutting down connection manager", ex);
+ }
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connection manager shut down");
}
- this.log.debug("Connection manager shut down");
}
}
public void closeIdleConnections(final long idleTimeout, final TimeUnit tunit) {
- if (this.log.isDebugEnabled()) {
- this.log.debug("Closing connections idle longer than " + idleTimeout + " " + tunit);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Closing connections idle longer than " + idleTimeout + " " + tunit);
}
this.pool.closeIdle(idleTimeout, tunit);
}
public void closeExpiredConnections() {
- this.log.debug("Closing expired connections");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Closing expired connections");
+ }
this.pool.closeExpired();
}
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/WireHC4.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/WireHC4.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/WireHC4.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/conn/WireHC4.java Thu Aug 7 09:18:06 2014
@@ -30,7 +30,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import org.apache.commons.logging.Log;
+import android.util.Log;
import org.apache.http.annotation.Immutable;
import org.apache.http.util.Args;
@@ -43,21 +43,16 @@ import org.apache.http.util.Args;
@Immutable
public class WireHC4 {
- private final Log log;
+ private final static String TAG = "Wire";
private final String id;
/**
* @since 4.3
*/
- public WireHC4(final Log log, final String id) {
- this.log = log;
+ public WireHC4(final String id) {
this.id = id;
}
- public WireHC4(final Log log) {
- this(log, "");
- }
-
private void wire(final String header, final InputStream instream)
throws IOException {
final StringBuilder buffer = new StringBuilder();
@@ -69,7 +64,7 @@ public class WireHC4 {
buffer.append("[\\n]\"");
buffer.insert(0, "\"");
buffer.insert(0, header);
- log.debug(id + " " + buffer.toString());
+ Log.d(TAG, id + " " + buffer.toString());
buffer.setLength(0);
} else if ((ch < 32) || (ch > 127)) {
buffer.append("[0x");
@@ -83,13 +78,13 @@ public class WireHC4 {
buffer.append('\"');
buffer.insert(0, '\"');
buffer.insert(0, header);
- log.debug(id + " " + buffer.toString());
+ Log.d(TAG, id + " " + buffer.toString());
}
}
public boolean enabled() {
- return log.isDebugEnabled();
+ return Log.isLoggable(TAG, Log.DEBUG);
}
public void output(final InputStream outstream)
Modified: httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java?rev=1616447&r1=1616446&r2=1616447&view=diff
==============================================================================
--- httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java (original)
+++ httpcomponents/httpclient-android/branches/4.3.5-android/src/main/java/org/apache/http/impl/execchain/ConnectionHolder.java Thu Aug 7 09:18:06 2014
@@ -31,7 +31,7 @@ import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
-import org.apache.commons.logging.Log;
+import android.util.Log;
import org.apache.http.HttpClientConnection;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.concurrent.Cancellable;
@@ -46,7 +46,7 @@ import org.apache.http.conn.HttpClientCo
@ThreadSafe
class ConnectionHolder implements ConnectionReleaseTrigger, Cancellable, Closeable {
- private final Log log;
+ private final static String TAG = "HttpClient";
private final HttpClientConnectionManager manager;
private final HttpClientConnection managedConn;
@@ -58,11 +58,9 @@ class ConnectionHolder implements Connec
private volatile boolean released;
public ConnectionHolder(
- final Log log,
final HttpClientConnectionManager manager,
final HttpClientConnection managedConn) {
super();
- this.log = log;
this.manager = manager;
this.managedConn = managedConn;
}
@@ -102,10 +100,12 @@ class ConnectionHolder implements Connec
} else {
try {
this.managedConn.close();
- log.debug("Connection discarded");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connection discarded");
+ }
} catch (final IOException ex) {
- if (this.log.isDebugEnabled()) {
- this.log.debug(ex.getMessage(), ex);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, ex.getMessage(), ex);
}
} finally {
this.manager.releaseConnection(
@@ -123,10 +123,12 @@ class ConnectionHolder implements Connec
this.released = true;
try {
this.managedConn.shutdown();
- log.debug("Connection discarded");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Connection discarded");
+ }
} catch (final IOException ex) {
- if (this.log.isDebugEnabled()) {
- this.log.debug(ex.getMessage(), ex);
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, ex.getMessage(), ex);
}
} finally {
this.manager.releaseConnection(
@@ -137,7 +139,9 @@ class ConnectionHolder implements Connec
public boolean cancel() {
final boolean alreadyReleased = this.released;
- log.debug("Cancelling request execution");
+ if (Log.isLoggable(TAG, Log.DEBUG)) {
+ Log.d(TAG, "Cancelling request execution");
+ }
abortConnection();
return !alreadyReleased;
}