Read the group history response as a stream.

This commit is contained in:
Greyson Parrelli
2021-06-23 17:47:05 -04:00
committed by GitHub
parent b3ebf778fd
commit 6502ef64ce

View File

@@ -2189,7 +2189,7 @@ public class PushServiceSocket {
} }
public GroupHistory getGroupsV2GroupHistory(int fromVersion, GroupsV2AuthorizationString authorization) public GroupHistory getGroupsV2GroupHistory(int fromVersion, GroupsV2AuthorizationString authorization)
throws IOException, InvalidProtocolBufferException throws IOException
{ {
Response response = makeStorageRequestResponse(authorization.toString(), Response response = makeStorageRequestResponse(authorization.toString(),
String.format(Locale.US, GROUPSV2_GROUP_CHANGES, fromVersion), String.format(Locale.US, GROUPSV2_GROUP_CHANGES, fromVersion),
@@ -2197,7 +2197,16 @@ public class PushServiceSocket {
null, null,
GROUPS_V2_GET_LOGS_HANDLER); GROUPS_V2_GET_LOGS_HANDLER);
GroupChanges groupChanges = GroupChanges.parseFrom(readBodyBytes(response.body())); if (response.body() == null) {
throw new PushNetworkException("No body!");
}
GroupChanges groupChanges;
try {
groupChanges = GroupChanges.parseFrom(response.body().byteStream());
} catch (IOException e) {
throw new PushNetworkException(e);
}
if (response.code() == 206) { if (response.code() == 206) {
String contentRangeHeader = response.header("Content-Range"); String contentRangeHeader = response.header("Content-Range");