Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,329 @@
package com.amazonaws.http;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.AmazonWebServiceRequest;
import com.amazonaws.AmazonWebServiceResponse;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.Request;
import com.amazonaws.RequestClientOptions;
import com.amazonaws.Response;
import com.amazonaws.handlers.RequestHandler2;
import com.amazonaws.internal.CRC32MismatchException;
import com.amazonaws.logging.Log;
import com.amazonaws.logging.LogFactory;
import com.amazonaws.metrics.RequestMetricCollector;
import com.amazonaws.retry.RetryPolicy;
import com.amazonaws.util.AWSRequestMetrics;
import com.amazonaws.util.DateUtils;
import com.amazonaws.util.TimingInfo;
import com.amazonaws.util.URIBuilder;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import org.apache.http.HttpStatus;
import org.apache.http.protocol.HTTP;
/* loaded from: classes.dex */
public class AmazonHttpClient {
public static final Log REQUEST_LOG = LogFactory.getLog("com.amazonaws.request");
public static final Log log = LogFactory.getLog(AmazonHttpClient.class);
public final ClientConfiguration config;
public final HttpClient httpClient;
public final HttpRequestFactory requestFactory = new HttpRequestFactory();
public final RequestMetricCollector requestMetricCollector = null;
public RequestMetricCollector getRequestMetricCollector() {
return this.requestMetricCollector;
}
public AmazonHttpClient(ClientConfiguration clientConfiguration, HttpClient httpClient) {
this.config = clientConfiguration;
this.httpClient = httpClient;
}
public Response execute(Request request, HttpResponseHandler httpResponseHandler, HttpResponseHandler httpResponseHandler2, ExecutionContext executionContext) {
Response response;
if (request.getHostPrefix() != null) {
try {
URI endpoint = request.getEndpoint();
request.setEndpoint(URIBuilder.builder(endpoint).host(request.getHostPrefix() + endpoint.getHost()).build());
} catch (URISyntaxException e) {
Log log2 = log;
if (log2.isDebugEnabled()) {
log2.debug("Failed to prepend host prefix: " + e.getMessage(), e);
}
}
}
if (executionContext == null) {
throw new AmazonClientException("Internal SDK Error: No execution context parameter specified.");
}
List requestHandler2s = requestHandler2s(request, executionContext);
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
try {
response = executeHelper(request, httpResponseHandler, httpResponseHandler2, executionContext);
} catch (AmazonClientException e2) {
e = e2;
response = null;
}
try {
afterResponse(request, requestHandler2s, response, awsRequestMetrics.getTimingInfo().endTiming());
return response;
} catch (AmazonClientException e3) {
e = e3;
afterError(request, response, requestHandler2s, e);
throw e;
}
}
public void afterError(Request request, Response response, List list, AmazonClientException amazonClientException) {
Iterator it = list.iterator();
while (it.hasNext()) {
((RequestHandler2) it.next()).afterError(request, response, amazonClientException);
}
}
public void afterResponse(Request request, List list, Response response, TimingInfo timingInfo) {
Iterator it = list.iterator();
while (it.hasNext()) {
((RequestHandler2) it.next()).afterResponse(request, response);
}
}
public List requestHandler2s(Request request, ExecutionContext executionContext) {
List requestHandler2s = executionContext.getRequestHandler2s();
if (requestHandler2s == null) {
return Collections.emptyList();
}
Iterator it = requestHandler2s.iterator();
while (it.hasNext()) {
((RequestHandler2) it.next()).beforeRequest(request);
}
return requestHandler2s;
}
/* JADX WARN: Removed duplicated region for block: B:41:0x0473 */
/* JADX WARN: Removed duplicated region for block: B:54:? A[SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:64:0x03ec A[Catch: all -> 0x03ab, TRY_ENTER, TryCatch #6 {all -> 0x03ab, blocks: (B:61:0x03e2, B:64:0x03ec, B:65:0x0402, B:67:0x0444, B:81:0x0470, B:246:0x03a5, B:247:0x03aa), top: B:60:0x03e2 }] */
/* JADX WARN: Removed duplicated region for block: B:67:0x0444 A[Catch: all -> 0x03ab, TRY_LEAVE, TryCatch #6 {all -> 0x03ab, blocks: (B:61:0x03e2, B:64:0x03ec, B:65:0x0402, B:67:0x0444, B:81:0x0470, B:246:0x03a5, B:247:0x03aa), top: B:60:0x03e2 }] */
/* JADX WARN: Removed duplicated region for block: B:80:0x0470 A[SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public com.amazonaws.Response executeHelper(com.amazonaws.Request r27, com.amazonaws.http.HttpResponseHandler r28, com.amazonaws.http.HttpResponseHandler r29, com.amazonaws.http.ExecutionContext r30) {
/*
Method dump skipped, instructions count: 1162
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: com.amazonaws.http.AmazonHttpClient.executeHelper(com.amazonaws.Request, com.amazonaws.http.HttpResponseHandler, com.amazonaws.http.HttpResponseHandler, com.amazonaws.http.ExecutionContext):com.amazonaws.Response");
}
public final Throwable handleUnexpectedFailure(Throwable th, AWSRequestMetrics aWSRequestMetrics) {
AWSRequestMetrics.Field field = AWSRequestMetrics.Field.Exception;
aWSRequestMetrics.incrementCounter(field);
aWSRequestMetrics.addProperty(field, th);
return th;
}
public void resetRequestAfterError(Request request, Exception exc) {
if (request.getContent() == null) {
return;
}
if (!request.getContent().markSupported()) {
throw new AmazonClientException("Encountered an exception and stream is not resettable", exc);
}
try {
request.getContent().reset();
} catch (IOException unused) {
throw new AmazonClientException("Encountered an exception and couldn't reset the stream to retry", exc);
}
}
public void setUserAgent(Request request) {
RequestClientOptions requestClientOptions;
String clientMarker;
String str = ClientConfiguration.DEFAULT_USER_AGENT;
AmazonWebServiceRequest originalRequest = request.getOriginalRequest();
String createUserAgentString = (originalRequest == null || (requestClientOptions = originalRequest.getRequestClientOptions()) == null || (clientMarker = requestClientOptions.getClientMarker(RequestClientOptions.Marker.USER_AGENT)) == null) ? str : createUserAgentString(str, clientMarker);
if (!str.equals(this.config.getUserAgent())) {
createUserAgentString = createUserAgentString(createUserAgentString, this.config.getUserAgent());
}
if (this.config.getUserAgentOverride() != null) {
createUserAgentString = this.config.getUserAgentOverride();
}
request.addHeader("User-Agent", createUserAgentString);
}
public static String createUserAgentString(String str, String str2) {
if (str.contains(str2)) {
return str;
}
return str.trim() + " " + str2.trim();
}
public void shutdown() {
this.httpClient.shutdown();
}
public final boolean shouldRetry(AmazonWebServiceRequest amazonWebServiceRequest, InputStream inputStream, AmazonClientException amazonClientException, int i, RetryPolicy retryPolicy) {
int i2 = i - 1;
int maxErrorRetry = this.config.getMaxErrorRetry();
if (maxErrorRetry < 0 || !retryPolicy.isMaxErrorRetryInClientConfigHonored()) {
maxErrorRetry = retryPolicy.getMaxErrorRetry();
}
if (i2 >= maxErrorRetry) {
return false;
}
if (inputStream != null && !inputStream.markSupported()) {
Log log2 = log;
if (log2.isDebugEnabled()) {
log2.debug("Content not repeatable");
}
return false;
}
return retryPolicy.getRetryCondition().shouldRetry(amazonWebServiceRequest, amazonClientException, i2);
}
public static boolean isTemporaryRedirect(HttpResponse httpResponse) {
int statusCode = httpResponse.getStatusCode();
String str = (String) httpResponse.getHeaders().get("Location");
return (statusCode != 307 || str == null || str.isEmpty()) ? false : true;
}
public final boolean isRequestSuccessful(HttpResponse httpResponse) {
int statusCode = httpResponse.getStatusCode();
return statusCode >= 200 && statusCode < 300;
}
public Object handleResponse(Request request, HttpResponseHandler httpResponseHandler, HttpResponse httpResponse, ExecutionContext executionContext) {
try {
AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
AWSRequestMetrics.Field field = AWSRequestMetrics.Field.ResponseProcessingTime;
awsRequestMetrics.startEvent(field);
try {
AmazonWebServiceResponse amazonWebServiceResponse = (AmazonWebServiceResponse) httpResponseHandler.handle(httpResponse);
awsRequestMetrics.endEvent(field);
if (amazonWebServiceResponse == null) {
throw new RuntimeException("Unable to unmarshall response metadata. Response Code: " + httpResponse.getStatusCode() + ", Response Text: " + httpResponse.getStatusText());
}
Log log2 = REQUEST_LOG;
if (log2.isDebugEnabled()) {
log2.debug("Received successful response: " + httpResponse.getStatusCode() + ", AWS Request ID: " + amazonWebServiceResponse.getRequestId());
}
awsRequestMetrics.addProperty(AWSRequestMetrics.Field.AWSRequestID, amazonWebServiceResponse.getRequestId());
return amazonWebServiceResponse.getResult();
} catch (Throwable th) {
awsRequestMetrics.endEvent(AWSRequestMetrics.Field.ResponseProcessingTime);
throw th;
}
} catch (CRC32MismatchException e) {
throw e;
} catch (IOException e2) {
throw e2;
} catch (Exception e3) {
throw new AmazonClientException("Unable to unmarshall response (" + e3.getMessage() + "). Response Code: " + httpResponse.getStatusCode() + ", Response Text: " + httpResponse.getStatusText(), e3);
}
}
public AmazonServiceException handleErrorResponse(Request request, HttpResponseHandler httpResponseHandler, HttpResponse httpResponse) {
AmazonServiceException amazonServiceException;
int statusCode = httpResponse.getStatusCode();
try {
amazonServiceException = (AmazonServiceException) httpResponseHandler.handle(httpResponse);
REQUEST_LOG.debug("Received error response: " + amazonServiceException.toString());
} catch (Exception e) {
if (statusCode == 413) {
amazonServiceException = new AmazonServiceException("Request entity too large");
amazonServiceException.setServiceName(request.getServiceName());
amazonServiceException.setStatusCode(HttpStatus.SC_REQUEST_TOO_LONG);
amazonServiceException.setErrorType(AmazonServiceException.ErrorType.Client);
amazonServiceException.setErrorCode("Request entity too large");
} else if (statusCode == 503 && "Service Unavailable".equalsIgnoreCase(httpResponse.getStatusText())) {
amazonServiceException = new AmazonServiceException("Service unavailable");
amazonServiceException.setServiceName(request.getServiceName());
amazonServiceException.setStatusCode(HttpStatus.SC_SERVICE_UNAVAILABLE);
amazonServiceException.setErrorType(AmazonServiceException.ErrorType.Service);
amazonServiceException.setErrorCode("Service unavailable");
} else {
if (e instanceof IOException) {
throw ((IOException) e);
}
throw new AmazonClientException("Unable to unmarshall error response (" + e.getMessage() + "). Response Code: " + statusCode + ", Response Text: " + httpResponse.getStatusText() + ", Response Headers: " + httpResponse.getHeaders(), e);
}
}
amazonServiceException.setStatusCode(statusCode);
amazonServiceException.setServiceName(request.getServiceName());
amazonServiceException.fillInStackTrace();
return amazonServiceException;
}
public final long pauseBeforeNextRetry(AmazonWebServiceRequest amazonWebServiceRequest, AmazonClientException amazonClientException, int i, RetryPolicy retryPolicy) {
int i2 = i - 2;
long delayBeforeNextRetry = retryPolicy.getBackoffStrategy().delayBeforeNextRetry(amazonWebServiceRequest, amazonClientException, i2);
Log log2 = log;
if (log2.isDebugEnabled()) {
log2.debug("Retriable error detected, will retry in " + delayBeforeNextRetry + "ms, attempt number: " + i2);
}
try {
Thread.sleep(delayBeforeNextRetry);
return delayBeforeNextRetry;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new AmazonClientException(e.getMessage(), e);
}
}
public final String getServerDateFromException(String str) {
int indexOf;
int indexOf2 = str.indexOf("(");
if (str.contains(" + 15")) {
indexOf = str.indexOf(" + 15");
} else {
indexOf = str.indexOf(" - 15");
}
return str.substring(indexOf2 + 1, indexOf);
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r4v12 */
/* JADX WARN: Type inference failed for: r4v3, types: [java.lang.String] */
public long parseClockSkewOffset(HttpResponse httpResponse, AmazonServiceException amazonServiceException) {
Date parseRFC822Date;
Date date = new Date();
String str = (String) httpResponse.getHeaders().get(HTTP.DATE_HEADER);
try {
if (str != 0) {
try {
if (!str.isEmpty()) {
parseRFC822Date = DateUtils.parseRFC822Date(str);
long time = date.getTime() - parseRFC822Date.getTime();
str = 1000;
return time / 1000;
}
} catch (RuntimeException e) {
e = e;
str = 0;
log.warn("Unable to parse clock skew offset from response: " + str, e);
return 0L;
}
}
parseRFC822Date = DateUtils.parseCompressedISO8601Date(getServerDateFromException(amazonServiceException.getMessage()));
long time2 = date.getTime() - parseRFC822Date.getTime();
str = 1000;
return time2 / 1000;
} catch (RuntimeException e2) {
e = e2;
}
}
public void finalize() {
shutdown();
super.finalize();
}
}

View File

@@ -0,0 +1,64 @@
package com.amazonaws.http;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.logging.Log;
import com.amazonaws.logging.LogFactory;
import com.amazonaws.transform.Unmarshaller;
import com.amazonaws.util.IOUtils;
import com.amazonaws.util.XpathUtils;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import org.w3c.dom.Document;
/* loaded from: classes.dex */
public class DefaultErrorResponseHandler implements HttpResponseHandler<AmazonServiceException> {
public static final Log log = LogFactory.getLog(DefaultErrorResponseHandler.class);
public List unmarshallerList;
@Override // com.amazonaws.http.HttpResponseHandler
public boolean needsConnectionLeftOpen() {
return false;
}
public DefaultErrorResponseHandler(List list) {
this.unmarshallerList = list;
}
@Override // com.amazonaws.http.HttpResponseHandler
public AmazonServiceException handle(HttpResponse httpResponse) {
try {
String iOUtils = IOUtils.toString(httpResponse.getContent());
try {
Document documentFrom = XpathUtils.documentFrom(iOUtils);
Iterator it = this.unmarshallerList.iterator();
while (it.hasNext()) {
AmazonServiceException amazonServiceException = (AmazonServiceException) ((Unmarshaller) it.next()).unmarshall(documentFrom);
if (amazonServiceException != null) {
amazonServiceException.setStatusCode(httpResponse.getStatusCode());
return amazonServiceException;
}
}
throw new AmazonClientException("Unable to unmarshall error response from service");
} catch (Exception e) {
return newAmazonServiceException(String.format("Unable to unmarshall error response (%s)", iOUtils), httpResponse, e);
}
} catch (IOException e2) {
Log log2 = log;
if (log2.isDebugEnabled()) {
log2.debug("Failed in reading the error response", e2);
}
return newAmazonServiceException("Unable to unmarshall error response", httpResponse, e2);
}
}
public final AmazonServiceException newAmazonServiceException(String str, HttpResponse httpResponse, Exception exc) {
AmazonServiceException amazonServiceException = new AmazonServiceException(str, exc);
int statusCode = httpResponse.getStatusCode();
amazonServiceException.setErrorCode(statusCode + " " + httpResponse.getStatusText());
amazonServiceException.setErrorType(AmazonServiceException.ErrorType.Unknown);
amazonServiceException.setStatusCode(statusCode);
return amazonServiceException;
}
}

View File

@@ -0,0 +1,52 @@
package com.amazonaws.http;
import com.amazonaws.AmazonWebServiceClient;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.Signer;
import com.amazonaws.util.AWSRequestMetrics;
import com.amazonaws.util.AWSRequestMetricsFullSupport;
import java.net.URI;
import java.util.List;
/* loaded from: classes.dex */
public class ExecutionContext {
public final AmazonWebServiceClient awsClient;
public final AWSRequestMetrics awsRequestMetrics;
public String contextUserAgent;
public AWSCredentials credentials;
public final List requestHandler2s;
public AWSRequestMetrics getAwsRequestMetrics() {
return this.awsRequestMetrics;
}
public String getContextUserAgent() {
return this.contextUserAgent;
}
public AWSCredentials getCredentials() {
return this.credentials;
}
public List getRequestHandler2s() {
return this.requestHandler2s;
}
public void setCredentials(AWSCredentials aWSCredentials) {
this.credentials = aWSCredentials;
}
public ExecutionContext(List list, boolean z, AmazonWebServiceClient amazonWebServiceClient) {
this.requestHandler2s = list;
this.awsRequestMetrics = z ? new AWSRequestMetricsFullSupport() : new AWSRequestMetrics();
this.awsClient = amazonWebServiceClient;
}
public Signer getSignerByURI(URI uri) {
AmazonWebServiceClient amazonWebServiceClient = this.awsClient;
if (amazonWebServiceClient == null) {
return null;
}
return amazonWebServiceClient.getSignerByURI(uri);
}
}

View File

@@ -0,0 +1,8 @@
package com.amazonaws.http;
/* loaded from: classes.dex */
public interface HttpClient {
HttpResponse execute(HttpRequest httpRequest);
void shutdown();
}

View File

@@ -0,0 +1,11 @@
package com.amazonaws.http;
/* loaded from: classes.dex */
public enum HttpMethodName {
GET,
POST,
PUT,
DELETE,
HEAD,
PATCH
}

View File

@@ -0,0 +1,63 @@
package com.amazonaws.http;
import com.amazonaws.util.StringUtils;
import java.io.InputStream;
import java.net.URI;
import java.util.Collections;
import java.util.Map;
import org.apache.http.protocol.HTTP;
/* loaded from: classes.dex */
public class HttpRequest {
public final InputStream content;
public final Map headers;
public boolean isStreaming;
public final String method;
public URI uri;
public InputStream getContent() {
return this.content;
}
public Map getHeaders() {
return this.headers;
}
public String getMethod() {
return this.method;
}
public URI getUri() {
return this.uri;
}
public boolean isStreaming() {
return this.isStreaming;
}
public void setStreaming(boolean z) {
this.isStreaming = z;
}
public HttpRequest(String str, URI uri, Map map, InputStream inputStream) {
Map unmodifiableMap;
this.method = StringUtils.upperCase(str);
this.uri = uri;
if (map == null) {
unmodifiableMap = Collections.EMPTY_MAP;
} else {
unmodifiableMap = Collections.unmodifiableMap(map);
}
this.headers = unmodifiableMap;
this.content = inputStream;
}
public long getContentLength() {
String str;
Map map = this.headers;
if (map == null || (str = (String) map.get(HTTP.CONTENT_LEN)) == null || str.isEmpty()) {
return 0L;
}
return Long.valueOf(str).longValue();
}
}

View File

@@ -0,0 +1,85 @@
package com.amazonaws.http;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.Request;
import com.amazonaws.util.HttpUtils;
import com.amazonaws.util.StringUtils;
import com.facebook.internal.security.CertificateUtil;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.protocol.HTTP;
/* loaded from: classes.dex */
public class HttpRequestFactory {
public HttpRequest createHttpRequest(Request request, ClientConfiguration clientConfiguration, ExecutionContext executionContext) {
String appendUri;
URI endpoint = request.getEndpoint();
boolean z = true;
if (request.getEncodedUriResourcePath() != null) {
appendUri = HttpUtils.appendUriEncoded(endpoint.toString(), request.getEncodedUriResourcePath());
} else {
appendUri = HttpUtils.appendUri(endpoint.toString(), request.getResourcePath(), true);
}
String encodeParameters = HttpUtils.encodeParameters(request);
HttpMethodName httpMethod = request.getHttpMethod();
boolean z2 = request.getContent() != null;
HttpMethodName httpMethodName = HttpMethodName.POST;
if (httpMethod == httpMethodName && !z2) {
z = false;
}
if (encodeParameters != null && z) {
appendUri = appendUri + "?" + encodeParameters;
}
HashMap hashMap = new HashMap();
configureHeaders(hashMap, request, executionContext, clientConfiguration);
InputStream content = request.getContent();
HttpMethodName httpMethodName2 = HttpMethodName.PATCH;
if (httpMethod == httpMethodName2) {
hashMap.put("X-HTTP-Method-Override", httpMethodName2.toString());
httpMethod = httpMethodName;
}
if (httpMethod == httpMethodName && request.getContent() == null && encodeParameters != null) {
byte[] bytes = encodeParameters.getBytes(StringUtils.UTF8);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
hashMap.put(HTTP.CONTENT_LEN, String.valueOf(bytes.length));
content = byteArrayInputStream;
}
if (clientConfiguration.isEnableGzip() && hashMap.get("Accept-Encoding") == null) {
hashMap.put("Accept-Encoding", "gzip");
} else {
hashMap.put("Accept-Encoding", HTTP.IDENTITY_CODING);
}
HttpRequest httpRequest = new HttpRequest(httpMethod.toString(), URI.create(appendUri), hashMap, content);
httpRequest.setStreaming(request.isStreaming());
return httpRequest;
}
public final void configureHeaders(Map map, Request request, ExecutionContext executionContext, ClientConfiguration clientConfiguration) {
URI endpoint = request.getEndpoint();
String host = endpoint.getHost();
if (HttpUtils.isUsingNonDefaultPort(endpoint)) {
host = host + CertificateUtil.DELIMITER + endpoint.getPort();
}
map.put(HTTP.TARGET_HOST, host);
for (Map.Entry entry : request.getHeaders().entrySet()) {
map.put(entry.getKey(), entry.getValue());
}
if (map.get("Content-Type") == null || ((String) map.get("Content-Type")).isEmpty()) {
map.put("Content-Type", "application/x-www-form-urlencoded; charset=" + StringUtils.lowerCase("UTF-8"));
}
if (executionContext == null || executionContext.getContextUserAgent() == null) {
return;
}
map.put("User-Agent", createUserAgentString(clientConfiguration, executionContext.getContextUserAgent()));
}
public final String createUserAgentString(ClientConfiguration clientConfiguration, String str) {
if (clientConfiguration.getUserAgent().contains(str)) {
return clientConfiguration.getUserAgent();
}
return clientConfiguration.getUserAgent() + " " + str;
}
}

View File

@@ -0,0 +1,91 @@
package com.amazonaws.http;
import java.io.InputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.GZIPInputStream;
import org.apache.http.protocol.HTTP;
/* loaded from: classes.dex */
public class HttpResponse {
public InputStream content;
public final Map headers;
public final InputStream rawContent;
public final int statusCode;
public final String statusText;
public Map getHeaders() {
return this.headers;
}
public InputStream getRawContent() {
return this.rawContent;
}
public int getStatusCode() {
return this.statusCode;
}
public String getStatusText() {
return this.statusText;
}
public HttpResponse(String str, int i, Map map, InputStream inputStream) {
this.statusText = str;
this.statusCode = i;
this.headers = map;
this.rawContent = inputStream;
}
public InputStream getContent() {
if (this.content == null) {
synchronized (this) {
try {
if (this.rawContent == null || !"gzip".equals(this.headers.get(HTTP.CONTENT_ENCODING))) {
this.content = this.rawContent;
} else {
this.content = new GZIPInputStream(this.rawContent);
}
} finally {
}
}
}
return this.content;
}
public static Builder builder() {
return new Builder();
}
public static class Builder {
public InputStream content;
public final Map headers = new HashMap();
public int statusCode;
public String statusText;
public Builder content(InputStream inputStream) {
this.content = inputStream;
return this;
}
public Builder statusCode(int i) {
this.statusCode = i;
return this;
}
public Builder statusText(String str) {
this.statusText = str;
return this;
}
public Builder header(String str, String str2) {
this.headers.put(str, str2);
return this;
}
public HttpResponse build() {
return new HttpResponse(this.statusText, this.statusCode, Collections.unmodifiableMap(this.headers), this.content);
}
}
}

View File

@@ -0,0 +1,8 @@
package com.amazonaws.http;
/* loaded from: classes.dex */
public interface HttpResponseHandler<T> {
Object handle(HttpResponse httpResponse);
boolean needsConnectionLeftOpen();
}

View File

@@ -0,0 +1,110 @@
package com.amazonaws.http;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.transform.JsonErrorUnmarshaller;
import com.amazonaws.util.StringUtils;
import com.amazonaws.util.json.JsonUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
public class JsonErrorResponseHandler implements HttpResponseHandler<AmazonServiceException> {
public final List unmarshallerList;
@Override // com.amazonaws.http.HttpResponseHandler
public boolean needsConnectionLeftOpen() {
return false;
}
public JsonErrorResponseHandler(List list) {
this.unmarshallerList = list;
}
@Override // com.amazonaws.http.HttpResponseHandler
public AmazonServiceException handle(HttpResponse httpResponse) {
try {
JsonErrorResponse fromResponse = JsonErrorResponse.fromResponse(httpResponse);
AmazonServiceException runErrorUnmarshallers = runErrorUnmarshallers(fromResponse);
if (runErrorUnmarshallers == null) {
return null;
}
runErrorUnmarshallers.setStatusCode(httpResponse.getStatusCode());
if (httpResponse.getStatusCode() < 500) {
runErrorUnmarshallers.setErrorType(AmazonServiceException.ErrorType.Client);
} else {
runErrorUnmarshallers.setErrorType(AmazonServiceException.ErrorType.Service);
}
runErrorUnmarshallers.setErrorCode(fromResponse.getErrorCode());
for (Map.Entry entry : httpResponse.getHeaders().entrySet()) {
if ("X-Amzn-RequestId".equalsIgnoreCase((String) entry.getKey())) {
runErrorUnmarshallers.setRequestId((String) entry.getValue());
}
}
return runErrorUnmarshallers;
} catch (IOException e) {
throw new AmazonClientException("Unable to parse error response", e);
}
}
public final AmazonServiceException runErrorUnmarshallers(JsonErrorResponse jsonErrorResponse) {
for (JsonErrorUnmarshaller jsonErrorUnmarshaller : this.unmarshallerList) {
if (jsonErrorUnmarshaller.match(jsonErrorResponse)) {
return jsonErrorUnmarshaller.unmarshall(jsonErrorResponse);
}
}
return null;
}
public static final class JsonErrorResponse {
public final String errorCode;
public final Map map;
public final String message = get("message");
public final int statusCode;
public String getErrorCode() {
return this.errorCode;
}
public String getMessage() {
return this.message;
}
public JsonErrorResponse(int i, String str, Map map) {
this.statusCode = i;
this.errorCode = str;
this.map = map;
}
public String get(String str) {
if (str == null || str.length() == 0) {
return null;
}
String str2 = StringUtils.lowerCase(str.substring(0, 1)) + str.substring(1);
String str3 = StringUtils.upperCase(str.substring(0, 1)) + str.substring(1);
if (this.map.containsKey(str3)) {
return (String) this.map.get(str3);
}
return this.map.containsKey(str2) ? (String) this.map.get(str2) : "";
}
public static JsonErrorResponse fromResponse(HttpResponse httpResponse) {
int statusCode = httpResponse.getStatusCode();
Map jsonToStringMapWithList = JsonUtils.jsonToStringMapWithList(new BufferedReader(new InputStreamReader(httpResponse.getContent(), StringUtils.UTF8)));
String str = (String) httpResponse.getHeaders().get("x-amzn-ErrorType");
if (str != null) {
int indexOf = str.indexOf(58);
if (indexOf != -1) {
str = str.substring(0, indexOf);
}
} else if (jsonToStringMapWithList.containsKey("__type")) {
String str2 = (String) jsonToStringMapWithList.get("__type");
str = str2.substring(str2.lastIndexOf("#") + 1);
}
return new JsonErrorResponse(statusCode, str, jsonToStringMapWithList);
}
}
}

View File

@@ -0,0 +1,96 @@
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;
}
}
}

View File

@@ -0,0 +1,73 @@
package com.amazonaws.http;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonWebServiceResponse;
import com.amazonaws.ResponseMetadata;
import com.amazonaws.logging.Log;
import com.amazonaws.logging.LogFactory;
import com.amazonaws.transform.StaxUnmarshallerContext;
import com.amazonaws.transform.Unmarshaller;
import com.amazonaws.transform.VoidStaxUnmarshaller;
import com.amazonaws.util.StringUtils;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Map;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
/* loaded from: classes.dex */
public class StaxResponseHandler<T> implements HttpResponseHandler<AmazonWebServiceResponse<T>> {
public static final XmlPullParserFactory XML_PULL_PARSER_FACTORY;
public static final Log log = LogFactory.getLog("com.amazonaws.request");
public Unmarshaller responseUnmarshaller;
@Override // com.amazonaws.http.HttpResponseHandler
public boolean needsConnectionLeftOpen() {
return false;
}
public void registerAdditionalMetadataExpressions(StaxUnmarshallerContext staxUnmarshallerContext) {
}
static {
try {
XML_PULL_PARSER_FACTORY = XmlPullParserFactory.newInstance();
} catch (XmlPullParserException e) {
throw new AmazonClientException("Couldn't initialize XmlPullParserFactory", e);
}
}
public StaxResponseHandler(Unmarshaller unmarshaller) {
this.responseUnmarshaller = unmarshaller;
if (unmarshaller == null) {
this.responseUnmarshaller = new VoidStaxUnmarshaller();
}
}
@Override // com.amazonaws.http.HttpResponseHandler
public AmazonWebServiceResponse handle(HttpResponse httpResponse) {
Log log2 = log;
log2.trace("Parsing service response XML");
InputStream content = httpResponse.getContent();
if (content == null) {
content = new ByteArrayInputStream("<eof/>".getBytes(StringUtils.UTF8));
}
XmlPullParser newPullParser = XML_PULL_PARSER_FACTORY.newPullParser();
newPullParser.setInput(content, null);
AmazonWebServiceResponse amazonWebServiceResponse = new AmazonWebServiceResponse();
StaxUnmarshallerContext staxUnmarshallerContext = new StaxUnmarshallerContext(newPullParser, httpResponse.getHeaders());
staxUnmarshallerContext.registerMetadataExpression("ResponseMetadata/RequestId", 2, "AWS_REQUEST_ID");
staxUnmarshallerContext.registerMetadataExpression("requestId", 2, "AWS_REQUEST_ID");
registerAdditionalMetadataExpressions(staxUnmarshallerContext);
amazonWebServiceResponse.setResult(this.responseUnmarshaller.unmarshall(staxUnmarshallerContext));
Map metadata = staxUnmarshallerContext.getMetadata();
Map headers = httpResponse.getHeaders();
if (headers != null && headers.get("x-amzn-RequestId") != null) {
metadata.put("AWS_REQUEST_ID", headers.get("x-amzn-RequestId"));
}
amazonWebServiceResponse.setResponseMetadata(new ResponseMetadata(metadata));
log2.trace("Done parsing service response");
return amazonWebServiceResponse;
}
}

View File

@@ -0,0 +1,23 @@
package com.amazonaws.http;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
/* loaded from: classes.dex */
public abstract class TLS12SocketFactory extends SSLSocketFactory {
public static final Object contextLock = new Object();
public static final String[] SUPPORTED_PROTOCOLS = {"TLSv1", "TLSv1.1", "TLSv1.2"};
public static SSLContext sslContext = null;
public static TLS12SocketFactory createTLS12SocketFactory(SSLContext sSLContext) {
return null;
}
public static void fixTLSPre21(HttpsURLConnection httpsURLConnection, TLS12SocketFactory tLS12SocketFactory) {
}
public static TLS12SocketFactory createTLS12SocketFactory() {
return createTLS12SocketFactory(null);
}
}

View File

@@ -0,0 +1,249 @@
package com.amazonaws.http;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.http.HttpResponse;
import com.amazonaws.logging.Log;
import com.amazonaws.logging.LogFactory;
import com.facebook.internal.security.CertificateUtil;
import com.google.firebase.perf.network.FirebasePerfUrlConnection;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
import java.security.GeneralSecurityException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.protocol.HTTP;
/* loaded from: classes.dex */
public class UrlHttpClient implements HttpClient {
public static final Log log = LogFactory.getLog(UrlHttpClient.class);
public final ClientConfiguration config;
public SSLContext customTrustSSLContext = null;
public TLS12SocketFactory customTrustTls12SocketFactory;
public final TLS12SocketFactory tls12SocketFactory;
@Override // com.amazonaws.http.HttpClient
public void shutdown() {
}
public UrlHttpClient(ClientConfiguration clientConfiguration) {
this.config = clientConfiguration;
TLS12SocketFactory.createTLS12SocketFactory();
}
@Override // com.amazonaws.http.HttpClient
public HttpResponse execute(HttpRequest httpRequest) {
HttpURLConnection httpURLConnection = (HttpURLConnection) ((URLConnection) FirebasePerfUrlConnection.instrument(httpRequest.getUri().toURL().openConnection()));
CurlBuilder curlBuilder = this.config.isCurlLogging() ? new CurlBuilder(httpRequest.getUri().toURL()) : null;
configureConnection(httpRequest, httpURLConnection);
applyHeadersAndMethod(httpRequest, httpURLConnection, curlBuilder);
writeContentToConnection(httpRequest, httpURLConnection, curlBuilder);
if (curlBuilder != null) {
if (curlBuilder.isValid()) {
printToLog(curlBuilder.build());
} else {
printToLog("Failed to create curl, content too long");
}
}
return createHttpResponse(httpRequest, httpURLConnection);
}
public HttpResponse createHttpResponse(HttpRequest httpRequest, HttpURLConnection httpURLConnection) {
String responseMessage = httpURLConnection.getResponseMessage();
int responseCode = httpURLConnection.getResponseCode();
InputStream errorStream = httpURLConnection.getErrorStream();
if (errorStream == null && !HttpHead.METHOD_NAME.equals(httpRequest.getMethod())) {
try {
errorStream = httpURLConnection.getInputStream();
} catch (IOException unused) {
}
}
HttpResponse.Builder content = HttpResponse.builder().statusCode(responseCode).statusText(responseMessage).content(errorStream);
for (Map.Entry<String, List<String>> entry : httpURLConnection.getHeaderFields().entrySet()) {
if (entry.getKey() != null) {
content.header(entry.getKey(), entry.getValue().get(0));
}
}
return content.build();
}
public void writeContentToConnection(HttpRequest httpRequest, HttpURLConnection httpURLConnection, CurlBuilder curlBuilder) {
ByteBuffer byteBuffer;
if (httpRequest.getContent() == null || httpRequest.getContentLength() < 0) {
return;
}
httpURLConnection.setDoOutput(true);
if (!httpRequest.isStreaming()) {
httpURLConnection.setFixedLengthStreamingMode((int) httpRequest.getContentLength());
}
OutputStream outputStream = httpURLConnection.getOutputStream();
if (curlBuilder != null) {
if (httpRequest.getContentLength() < 2147483647L) {
byteBuffer = ByteBuffer.allocate((int) httpRequest.getContentLength());
write(httpRequest.getContent(), outputStream, curlBuilder, byteBuffer);
if (curlBuilder != null && byteBuffer != null && byteBuffer.position() != 0) {
curlBuilder.setContent(new String(byteBuffer.array(), "UTF-8"));
}
outputStream.flush();
outputStream.close();
}
curlBuilder.setContentOverflow(true);
}
byteBuffer = null;
write(httpRequest.getContent(), outputStream, curlBuilder, byteBuffer);
if (curlBuilder != null) {
curlBuilder.setContent(new String(byteBuffer.array(), "UTF-8"));
}
outputStream.flush();
outputStream.close();
}
public HttpURLConnection applyHeadersAndMethod(HttpRequest httpRequest, HttpURLConnection httpURLConnection, CurlBuilder curlBuilder) {
if (httpRequest.getHeaders() != null && !httpRequest.getHeaders().isEmpty()) {
if (curlBuilder != null) {
curlBuilder.setHeaders(httpRequest.getHeaders());
}
for (Map.Entry entry : httpRequest.getHeaders().entrySet()) {
String str = (String) entry.getKey();
if (!str.equals(HTTP.CONTENT_LEN) && !str.equals(HTTP.TARGET_HOST)) {
httpURLConnection.setRequestProperty(str, (String) entry.getValue());
}
}
}
String method = httpRequest.getMethod();
httpURLConnection.setRequestMethod(method);
if (curlBuilder != null) {
curlBuilder.setMethod(method);
}
return httpURLConnection;
}
public void printToLog(String str) {
log.debug(str);
}
public final void write(InputStream inputStream, OutputStream outputStream, CurlBuilder curlBuilder, ByteBuffer byteBuffer) {
byte[] bArr = new byte[8192];
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
return;
}
if (byteBuffer != null) {
try {
byteBuffer.put(bArr, 0, read);
} catch (BufferOverflowException unused) {
curlBuilder.setContentOverflow(true);
}
}
outputStream.write(bArr, 0, read);
}
}
public void configureConnection(HttpRequest httpRequest, HttpURLConnection httpURLConnection) {
httpURLConnection.setConnectTimeout(this.config.getConnectionTimeout());
httpURLConnection.setReadTimeout(this.config.getSocketTimeout());
httpURLConnection.setInstanceFollowRedirects(false);
httpURLConnection.setUseCaches(false);
if (httpRequest.isStreaming()) {
httpURLConnection.setChunkedStreamingMode(0);
}
if (httpURLConnection instanceof HttpsURLConnection) {
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) httpURLConnection;
if (this.config.getTrustManager() != null) {
enableCustomTrustManager(httpsURLConnection);
}
}
}
public final void enableCustomTrustManager(HttpsURLConnection httpsURLConnection) {
if (this.customTrustSSLContext == null) {
TrustManager[] trustManagerArr = {this.config.getTrustManager()};
try {
SSLContext sSLContext = SSLContext.getInstance("TLS");
this.customTrustSSLContext = sSLContext;
sSLContext.init(null, trustManagerArr, null);
TLS12SocketFactory.createTLS12SocketFactory(this.customTrustSSLContext);
} catch (GeneralSecurityException e) {
throw new RuntimeException(e);
}
}
httpsURLConnection.setSSLSocketFactory(this.customTrustSSLContext.getSocketFactory());
}
public final class CurlBuilder {
public final URL url;
public String method = null;
public final HashMap headers = new HashMap();
public String content = null;
public boolean contentOverflow = false;
public boolean isValid() {
return !this.contentOverflow;
}
public CurlBuilder setContent(String str) {
this.content = str;
return this;
}
public CurlBuilder setContentOverflow(boolean z) {
this.contentOverflow = z;
return this;
}
public CurlBuilder setMethod(String str) {
this.method = str;
return this;
}
public CurlBuilder(URL url) {
if (url == null) {
throw new IllegalArgumentException("Must have a valid url");
}
this.url = url;
}
public CurlBuilder setHeaders(Map map) {
this.headers.clear();
this.headers.putAll(map);
return this;
}
public String build() {
if (!isValid()) {
throw new IllegalStateException("Invalid state, cannot create curl command");
}
StringBuilder sb = new StringBuilder("curl");
if (this.method != null) {
sb.append(" -X ");
sb.append(this.method);
}
for (Map.Entry entry : this.headers.entrySet()) {
sb.append(" -H \"");
sb.append((String) entry.getKey());
sb.append(CertificateUtil.DELIMITER);
sb.append((String) entry.getValue());
sb.append("\"");
}
if (this.content != null) {
sb.append(" -d '");
sb.append(this.content);
sb.append("'");
}
sb.append(" ");
sb.append(this.url.toString());
return sb.toString();
}
}
}