Commit 9ca6f60c by olly Committed by Oliver Woodman

Preserve postBody in CacheDataSource when reading from upstream.

Set appropriate Content-Type when posting clientAbrState proto in post body.

PiperOrigin-RevId: 251322860
parent 871a88a9
...@@ -137,6 +137,7 @@ public final class CacheDataSource implements DataSource { ...@@ -137,6 +137,7 @@ public final class CacheDataSource implements DataSource {
@Nullable private Uri uri; @Nullable private Uri uri;
@Nullable private Uri actualUri; @Nullable private Uri actualUri;
@HttpMethod private int httpMethod; @HttpMethod private int httpMethod;
@Nullable private byte[] httpBody;
private int flags; private int flags;
@Nullable private String key; @Nullable private String key;
private long readPosition; private long readPosition;
...@@ -261,6 +262,7 @@ public final class CacheDataSource implements DataSource { ...@@ -261,6 +262,7 @@ public final class CacheDataSource implements DataSource {
uri = dataSpec.uri; uri = dataSpec.uri;
actualUri = getRedirectedUriOrDefault(cache, key, /* defaultUri= */ uri); actualUri = getRedirectedUriOrDefault(cache, key, /* defaultUri= */ uri);
httpMethod = dataSpec.httpMethod; httpMethod = dataSpec.httpMethod;
httpBody = dataSpec.httpBody;
flags = dataSpec.flags; flags = dataSpec.flags;
readPosition = dataSpec.position; readPosition = dataSpec.position;
...@@ -347,6 +349,7 @@ public final class CacheDataSource implements DataSource { ...@@ -347,6 +349,7 @@ public final class CacheDataSource implements DataSource {
uri = null; uri = null;
actualUri = null; actualUri = null;
httpMethod = DataSpec.HTTP_METHOD_GET; httpMethod = DataSpec.HTTP_METHOD_GET;
httpBody = null;
notifyBytesRead(); notifyBytesRead();
try { try {
closeCurrentSource(); closeCurrentSource();
...@@ -393,7 +396,7 @@ public final class CacheDataSource implements DataSource { ...@@ -393,7 +396,7 @@ public final class CacheDataSource implements DataSource {
nextDataSource = upstreamDataSource; nextDataSource = upstreamDataSource;
nextDataSpec = nextDataSpec =
new DataSpec( new DataSpec(
uri, httpMethod, null, readPosition, readPosition, bytesRemaining, key, flags); uri, httpMethod, httpBody, readPosition, readPosition, bytesRemaining, key, flags);
} else if (nextSpan.isCached) { } else if (nextSpan.isCached) {
// Data is cached, read from cache. // Data is cached, read from cache.
Uri fileUri = Uri.fromFile(nextSpan.file); Uri fileUri = Uri.fromFile(nextSpan.file);
...@@ -416,7 +419,7 @@ public final class CacheDataSource implements DataSource { ...@@ -416,7 +419,7 @@ public final class CacheDataSource implements DataSource {
} }
} }
nextDataSpec = nextDataSpec =
new DataSpec(uri, httpMethod, null, readPosition, readPosition, length, key, flags); new DataSpec(uri, httpMethod, httpBody, readPosition, readPosition, length, key, flags);
if (cacheWriteDataSource != null) { if (cacheWriteDataSource != null) {
nextDataSource = cacheWriteDataSource; nextDataSource = cacheWriteDataSource;
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment