- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
97 lines
4.3 KiB
Java
97 lines
4.3 KiB
Java
package com.amazonaws.http;
|
|
|
|
import com.amazonaws.AmazonWebServiceResponse;
|
|
import com.amazonaws.ResponseMetadata;
|
|
import com.amazonaws.internal.CRC32MismatchException;
|
|
import com.amazonaws.logging.Log;
|
|
import com.amazonaws.logging.LogFactory;
|
|
import com.amazonaws.transform.JsonUnmarshallerContext;
|
|
import com.amazonaws.transform.Unmarshaller;
|
|
import com.amazonaws.transform.VoidJsonUnmarshaller;
|
|
import com.amazonaws.util.CRC32ChecksumCalculatingInputStream;
|
|
import com.amazonaws.util.StringUtils;
|
|
import com.amazonaws.util.json.AwsJsonReader;
|
|
import com.applovin.impl.sdk.utils.JsonUtils;
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStreamReader;
|
|
import java.util.HashMap;
|
|
import java.util.zip.GZIPInputStream;
|
|
import org.apache.http.protocol.HTTP;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class JsonResponseHandler<T> implements HttpResponseHandler<AmazonWebServiceResponse<T>> {
|
|
public static final Log log = LogFactory.getLog("com.amazonaws.request");
|
|
public boolean needsConnectionLeftOpen = false;
|
|
public Unmarshaller responseUnmarshaller;
|
|
|
|
@Override // com.amazonaws.http.HttpResponseHandler
|
|
public boolean needsConnectionLeftOpen() {
|
|
return this.needsConnectionLeftOpen;
|
|
}
|
|
|
|
public JsonResponseHandler(Unmarshaller unmarshaller) {
|
|
this.responseUnmarshaller = unmarshaller;
|
|
if (unmarshaller == null) {
|
|
this.responseUnmarshaller = new VoidJsonUnmarshaller();
|
|
}
|
|
}
|
|
|
|
@Override // com.amazonaws.http.HttpResponseHandler
|
|
public AmazonWebServiceResponse handle(HttpResponse httpResponse) {
|
|
CRC32ChecksumCalculatingInputStream cRC32ChecksumCalculatingInputStream;
|
|
Log log2 = log;
|
|
log2.trace("Parsing service response JSON");
|
|
String str = (String) httpResponse.getHeaders().get("x-amz-crc32");
|
|
InputStream rawContent = httpResponse.getRawContent();
|
|
if (rawContent == null) {
|
|
rawContent = new ByteArrayInputStream(JsonUtils.EMPTY_JSON.getBytes(StringUtils.UTF8));
|
|
}
|
|
log2.debug("CRC32Checksum = " + str);
|
|
log2.debug("content encoding = " + ((String) httpResponse.getHeaders().get(HTTP.CONTENT_ENCODING)));
|
|
boolean equals = "gzip".equals(httpResponse.getHeaders().get(HTTP.CONTENT_ENCODING));
|
|
if (str != null) {
|
|
cRC32ChecksumCalculatingInputStream = new CRC32ChecksumCalculatingInputStream(rawContent);
|
|
rawContent = cRC32ChecksumCalculatingInputStream;
|
|
} else {
|
|
cRC32ChecksumCalculatingInputStream = null;
|
|
}
|
|
if (equals) {
|
|
rawContent = new GZIPInputStream(rawContent);
|
|
}
|
|
AwsJsonReader jsonReader = com.amazonaws.util.json.JsonUtils.getJsonReader(new InputStreamReader(rawContent, StringUtils.UTF8));
|
|
try {
|
|
AmazonWebServiceResponse amazonWebServiceResponse = new AmazonWebServiceResponse();
|
|
Object unmarshall = this.responseUnmarshaller.unmarshall(new JsonUnmarshallerContext(jsonReader, httpResponse));
|
|
if (cRC32ChecksumCalculatingInputStream != null) {
|
|
if (cRC32ChecksumCalculatingInputStream.getCRC32Checksum() != Long.parseLong(str)) {
|
|
throw new CRC32MismatchException("Client calculated crc32 checksum didn't match that calculated by server side");
|
|
}
|
|
}
|
|
amazonWebServiceResponse.setResult(unmarshall);
|
|
HashMap hashMap = new HashMap();
|
|
hashMap.put("AWS_REQUEST_ID", httpResponse.getHeaders().get("x-amzn-RequestId"));
|
|
amazonWebServiceResponse.setResponseMetadata(new ResponseMetadata(hashMap));
|
|
log2.trace("Done parsing service response");
|
|
if (!this.needsConnectionLeftOpen) {
|
|
try {
|
|
jsonReader.close();
|
|
} catch (IOException e) {
|
|
log.warn("Error closing json parser", e);
|
|
}
|
|
}
|
|
return amazonWebServiceResponse;
|
|
} catch (Throwable th) {
|
|
if (!this.needsConnectionLeftOpen) {
|
|
try {
|
|
jsonReader.close();
|
|
} catch (IOException e2) {
|
|
log.warn("Error closing json parser", e2);
|
|
}
|
|
}
|
|
throw th;
|
|
}
|
|
}
|
|
}
|