diff options
author | Debajit Ghosh <debajit@google.com> | 2009-09-17 13:33:54 -0700 |
---|---|---|
committer | Debajit Ghosh <debajit@google.com> | 2009-09-17 15:44:23 -0700 |
commit | 644d0449abb5510be086a8a5b407734b6d0d49a9 (patch) | |
tree | aee7084b9abb6ab83b180e7e04e0643a90edb66b /core/java/com/google | |
parent | d55de40481c6ec7d8fbd1a38c80a6c66bf462a71 (diff) | |
download | frameworks_base-644d0449abb5510be086a8a5b407734b6d0d49a9.zip frameworks_base-644d0449abb5510be086a8a5b407734b6d0d49a9.tar.gz frameworks_base-644d0449abb5510be086a8a5b407734b6d0d49a9.tar.bz2 |
add system property to disable gzip, to help with debugging.
Diffstat (limited to 'core/java/com/google')
-rw-r--r-- | core/java/com/google/android/gdata/client/AndroidGDataClient.java | 18 | ||||
-rw-r--r-- | core/java/com/google/android/gdata2/client/AndroidGDataClient.java | 21 |
2 files changed, 33 insertions, 6 deletions
diff --git a/core/java/com/google/android/gdata/client/AndroidGDataClient.java b/core/java/com/google/android/gdata/client/AndroidGDataClient.java index 998f940..9a2a51d 100644 --- a/core/java/com/google/android/gdata/client/AndroidGDataClient.java +++ b/core/java/com/google/android/gdata/client/AndroidGDataClient.java @@ -19,6 +19,7 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.entity.InputStreamEntity; import org.apache.http.entity.AbstractHttpEntity; +import org.apache.http.entity.ByteArrayEntity; import android.content.ContentResolver; import android.content.Context; @@ -26,6 +27,7 @@ import android.net.http.AndroidHttpClient; import android.text.TextUtils; import android.util.Config; import android.util.Log; +import android.os.SystemProperties; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -55,6 +57,10 @@ public class AndroidGDataClient implements GDataClient { private static final int MAX_REDIRECTS = 10; + // boolean system property that can be used to control whether or not + // requests/responses are gzip'd. + private static final String NO_GZIP_SYSTEM_PROPERTY = "sync.nogzip"; + private final GoogleHttpClient mHttpClient; private ContentResolver mResolver; @@ -212,7 +218,10 @@ public class AndroidGDataClient implements GDataClient { HttpUriRequest request = creator.createRequest(uri); - AndroidHttpClient.modifyRequestToAcceptGzipResponse(request); + if (!SystemProperties.getBoolean(NO_GZIP_SYSTEM_PROPERTY, false)) { + AndroidHttpClient.modifyRequestToAcceptGzipResponse(request); + } + // only add the auth token if not null (to allow for GData feeds that do not require // authentication.) if (!TextUtils.isEmpty(authToken)) { @@ -487,7 +496,12 @@ public class AndroidGDataClient implements GDataClient { } } - AbstractHttpEntity entity = AndroidHttpClient.getCompressedEntity(entryBytes, mResolver); + AbstractHttpEntity entity; + if (SystemProperties.getBoolean(NO_GZIP_SYSTEM_PROPERTY, false)) { + entity = new ByteArrayEntity(entryBytes); + } else { + entity = AndroidHttpClient.getCompressedEntity(entryBytes, mResolver); + } entity.setContentType(entry.getContentType()); return entity; } diff --git a/core/java/com/google/android/gdata2/client/AndroidGDataClient.java b/core/java/com/google/android/gdata2/client/AndroidGDataClient.java index 6ba791d..3721fa4 100644 --- a/core/java/com/google/android/gdata2/client/AndroidGDataClient.java +++ b/core/java/com/google/android/gdata2/client/AndroidGDataClient.java @@ -22,6 +22,7 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.entity.InputStreamEntity; import org.apache.http.entity.AbstractHttpEntity; +import org.apache.http.entity.ByteArrayEntity; import android.content.ContentResolver; import android.content.Context; @@ -29,6 +30,7 @@ import android.net.http.AndroidHttpClient; import android.text.TextUtils; import android.util.Config; import android.util.Log; +import android.os.SystemProperties; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -59,6 +61,9 @@ public class AndroidGDataClient implements GDataClient { private static final int MAX_REDIRECTS = 10; private static String DEFAULT_GDATA_VERSION = "2.0"; + // boolean system property that can be used to control whether or not + // requests/responses are gzip'd. + private static final String NO_GZIP_SYSTEM_PROPERTY = "sync.nogzip"; private String mGDataVersion; private final GoogleHttpClient mHttpClient; @@ -213,7 +218,7 @@ public class AndroidGDataClient implements GDataClient { HttpResponse response = null; int status = 500; int redirectsLeft = MAX_REDIRECTS; - + URI uri; try { uri = new URI(uriString); @@ -230,7 +235,10 @@ public class AndroidGDataClient implements GDataClient { HttpUriRequest request = creator.createRequest(uri); - AndroidHttpClient.modifyRequestToAcceptGzipResponse(request); + if (!SystemProperties.getBoolean(NO_GZIP_SYSTEM_PROPERTY, false)) { + AndroidHttpClient.modifyRequestToAcceptGzipResponse(request); + } + // only add the auth token if not null (to allow for GData feeds that do not require // authentication.) if (!TextUtils.isEmpty(authToken)) { @@ -547,7 +555,13 @@ public class AndroidGDataClient implements GDataClient { } } - AbstractHttpEntity entity = AndroidHttpClient.getCompressedEntity(entryBytes, mResolver); + AbstractHttpEntity entity; + if (SystemProperties.getBoolean(NO_GZIP_SYSTEM_PROPERTY, false)) { + entity = new ByteArrayEntity(entryBytes); + } else { + entity = AndroidHttpClient.getCompressedEntity(entryBytes, mResolver); + } + entity.setContentType(entry.getContentType()); return entity; } @@ -587,4 +601,3 @@ public class AndroidGDataClient implements GDataClient { throw new IOException("Unable to process batch request."); } } - |