Loading core/java/android/net/http/AndroidHttpClient.java +41 −6 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ import android.content.ContentResolver; import android.net.SSLCertificateSocketFactory; import android.net.SSLSessionCache; import android.os.Looper; import android.util.Base64; import android.util.Log; /** Loading @@ -81,6 +82,11 @@ public final class AndroidHttpClient implements HttpClient { private static final String TAG = "AndroidHttpClient"; private static String[] textContentTypes = new String[] { "text/", "application/xml", "application/json" }; /** Interceptor throws an exception if the executing thread is blocked */ private static final HttpRequestInterceptor sThreadCheckInterceptor = Loading Loading @@ -431,12 +437,17 @@ public final class AndroidHttpClient implements HttpClient { if (entity.getContentLength() < 1024) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); entity.writeTo(stream); String entityString = stream.toString(); // TODO: Check the content type, too. if (isBinaryContent(request)) { String base64 = Base64.encodeToString(stream.toByteArray(), Base64.NO_WRAP); builder.insert(0, "echo '" + base64 + "' | base64 -d > /tmp/$$.bin; "); builder.append(" --data-binary @/tmp/$$.bin"); } else { String entityString = stream.toString(); builder.append(" --data-ascii \"") .append(entityString) .append("\""); } } else { builder.append(" [TOO MUCH DATA TO INCLUDE]"); } Loading @@ -446,6 +457,30 @@ public final class AndroidHttpClient implements HttpClient { return builder.toString(); } private static boolean isBinaryContent(HttpUriRequest request) { Header[] headers; headers = request.getHeaders(Headers.CONTENT_ENCODING); if (headers != null) { for (Header header : headers) { if ("gzip".equalsIgnoreCase(header.getValue())) { return true; } } } headers = request.getHeaders(Headers.CONTENT_TYPE); if (headers != null) { for (Header header : headers) { for (String contentType : textContentTypes) { if (header.getValue().startsWith(contentType)) { return false; } } } } return true; } /** * Returns the date of the given HTTP date string. This method can identify * and parse the date formats emitted by common HTTP servers, such as Loading Loading
core/java/android/net/http/AndroidHttpClient.java +41 −6 Original line number Diff line number Diff line Loading @@ -61,6 +61,7 @@ import android.content.ContentResolver; import android.net.SSLCertificateSocketFactory; import android.net.SSLSessionCache; import android.os.Looper; import android.util.Base64; import android.util.Log; /** Loading @@ -81,6 +82,11 @@ public final class AndroidHttpClient implements HttpClient { private static final String TAG = "AndroidHttpClient"; private static String[] textContentTypes = new String[] { "text/", "application/xml", "application/json" }; /** Interceptor throws an exception if the executing thread is blocked */ private static final HttpRequestInterceptor sThreadCheckInterceptor = Loading Loading @@ -431,12 +437,17 @@ public final class AndroidHttpClient implements HttpClient { if (entity.getContentLength() < 1024) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); entity.writeTo(stream); String entityString = stream.toString(); // TODO: Check the content type, too. if (isBinaryContent(request)) { String base64 = Base64.encodeToString(stream.toByteArray(), Base64.NO_WRAP); builder.insert(0, "echo '" + base64 + "' | base64 -d > /tmp/$$.bin; "); builder.append(" --data-binary @/tmp/$$.bin"); } else { String entityString = stream.toString(); builder.append(" --data-ascii \"") .append(entityString) .append("\""); } } else { builder.append(" [TOO MUCH DATA TO INCLUDE]"); } Loading @@ -446,6 +457,30 @@ public final class AndroidHttpClient implements HttpClient { return builder.toString(); } private static boolean isBinaryContent(HttpUriRequest request) { Header[] headers; headers = request.getHeaders(Headers.CONTENT_ENCODING); if (headers != null) { for (Header header : headers) { if ("gzip".equalsIgnoreCase(header.getValue())) { return true; } } } headers = request.getHeaders(Headers.CONTENT_TYPE); if (headers != null) { for (Header header : headers) { for (String contentType : textContentTypes) { if (header.getValue().startsWith(contentType)) { return false; } } } } return true; } /** * Returns the date of the given HTTP date string. This method can identify * and parse the date formats emitted by common HTTP servers, such as Loading