211 lines
5.1 KiB
Java
211 lines
5.1 KiB
Java
package com.alibaba.sdk.android.oss.internal;
|
|
|
|
import android.net.Uri;
|
|
import android.text.TextUtils;
|
|
import com.alibaba.sdk.android.oss.common.HttpMethod;
|
|
import com.alibaba.sdk.android.oss.common.OSSLog;
|
|
import com.alibaba.sdk.android.oss.common.auth.OSSCredentialProvider;
|
|
import com.alibaba.sdk.android.oss.common.utils.HttpUtil;
|
|
import com.alibaba.sdk.android.oss.common.utils.HttpdnsMini;
|
|
import com.alibaba.sdk.android.oss.common.utils.OSSUtils;
|
|
import java.net.URI;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class RequestMessage extends HttpMessage {
|
|
private URI e;
|
|
private String f;
|
|
private String g;
|
|
private HttpMethod h;
|
|
private boolean k;
|
|
private OSSCredentialProvider l;
|
|
private String p;
|
|
private String r;
|
|
private byte[] s;
|
|
private Uri t;
|
|
private boolean i = true;
|
|
private Map<String, String> j = new LinkedHashMap();
|
|
private boolean m = false;
|
|
private boolean n = false;
|
|
private boolean o = false;
|
|
private boolean q = false;
|
|
|
|
public void f(boolean z) {
|
|
this.n = z;
|
|
}
|
|
|
|
public String g() {
|
|
return this.f;
|
|
}
|
|
|
|
public OSSCredentialProvider h() {
|
|
return this.l;
|
|
}
|
|
|
|
public String i() {
|
|
return this.p;
|
|
}
|
|
|
|
public HttpMethod j() {
|
|
return this.h;
|
|
}
|
|
|
|
public String k() {
|
|
return this.g;
|
|
}
|
|
|
|
public Map<String, String> l() {
|
|
return this.j;
|
|
}
|
|
|
|
public byte[] m() {
|
|
return this.s;
|
|
}
|
|
|
|
public String n() {
|
|
return this.r;
|
|
}
|
|
|
|
public Uri o() {
|
|
return this.t;
|
|
}
|
|
|
|
public boolean p() {
|
|
return this.i;
|
|
}
|
|
|
|
public boolean q() {
|
|
return this.k;
|
|
}
|
|
|
|
public boolean r() {
|
|
return this.m;
|
|
}
|
|
|
|
public void b(String str) {
|
|
this.p = str;
|
|
}
|
|
|
|
public void c(boolean z) {
|
|
this.m = z;
|
|
}
|
|
|
|
public void d(String str) {
|
|
this.r = str;
|
|
}
|
|
|
|
public void e(boolean z) {
|
|
this.q = z;
|
|
}
|
|
|
|
public String f() throws Exception {
|
|
boolean z = false;
|
|
OSSUtils.a(this.e != null, "Endpoint haven't been set!");
|
|
String scheme = this.e.getScheme();
|
|
String host = this.e.getHost();
|
|
String path = this.e.getPath();
|
|
int port = this.e.getPort();
|
|
String str = null;
|
|
String valueOf = port != -1 ? String.valueOf(port) : null;
|
|
if (TextUtils.isEmpty(host)) {
|
|
OSSLog.a("endpoint url : " + this.e.toString());
|
|
}
|
|
OSSLog.a(" scheme : " + scheme);
|
|
OSSLog.a(" originHost : " + host);
|
|
OSSLog.a(" port : " + valueOf);
|
|
String str2 = scheme + "://" + host;
|
|
if (!TextUtils.isEmpty(valueOf)) {
|
|
str2 = str2 + ":" + valueOf;
|
|
}
|
|
if (!TextUtils.isEmpty(this.f)) {
|
|
if (OSSUtils.d(host)) {
|
|
String str3 = this.f + "." + host;
|
|
if (r()) {
|
|
str = HttpdnsMini.a().a(str3);
|
|
} else {
|
|
OSSLog.a("[buildCannonicalURL], disable httpdns");
|
|
}
|
|
a("Host", str3);
|
|
str2 = TextUtils.isEmpty(str) ? scheme + "://" + str3 : scheme + "://" + str;
|
|
} else if (this.q) {
|
|
if (!this.n) {
|
|
str2 = scheme + "://" + this.f + "." + host;
|
|
}
|
|
z = true;
|
|
} else if (OSSUtils.e(host)) {
|
|
if (!OSSUtils.c(this.p)) {
|
|
a("Host", i());
|
|
}
|
|
z = true;
|
|
}
|
|
}
|
|
if (this.o && path != null) {
|
|
str2 = str2 + path;
|
|
}
|
|
if (z) {
|
|
str2 = str2 + "/" + this.f;
|
|
}
|
|
if (!TextUtils.isEmpty(this.g)) {
|
|
str2 = str2 + "/" + HttpUtil.a(this.g, "utf-8");
|
|
}
|
|
String a = OSSUtils.a(this.j, "utf-8");
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("request---------------------\n");
|
|
sb.append("request url=" + str2 + "\n");
|
|
sb.append("request params=" + a + "\n");
|
|
for (String str4 : d().keySet()) {
|
|
sb.append("requestHeader [" + str4 + "]: ");
|
|
StringBuilder sb2 = new StringBuilder();
|
|
sb2.append(d().get(str4));
|
|
sb2.append("\n");
|
|
sb.append(sb2.toString());
|
|
}
|
|
OSSLog.a(sb.toString());
|
|
if (OSSUtils.c(a)) {
|
|
return str2;
|
|
}
|
|
return str2 + "?" + a;
|
|
}
|
|
|
|
public void b(boolean z) {
|
|
this.o = z;
|
|
}
|
|
|
|
public void c(String str) {
|
|
this.g = str;
|
|
}
|
|
|
|
public void d(boolean z) {
|
|
this.i = z;
|
|
}
|
|
|
|
public void a(HttpMethod httpMethod) {
|
|
this.h = httpMethod;
|
|
}
|
|
|
|
public void a(OSSCredentialProvider oSSCredentialProvider) {
|
|
this.l = oSSCredentialProvider;
|
|
}
|
|
|
|
public void a(URI uri) {
|
|
this.e = uri;
|
|
}
|
|
|
|
public void a(String str) {
|
|
this.f = str;
|
|
}
|
|
|
|
public void a(byte[] bArr) {
|
|
this.s = bArr;
|
|
}
|
|
|
|
public void a(Uri uri) {
|
|
this.t = uri;
|
|
}
|
|
|
|
public void a(boolean z) {
|
|
this.k = z;
|
|
}
|
|
}
|