286 lines
12 KiB
Java
286 lines
12 KiB
Java
|
package okhttp3.internal.ws;
|
||
|
|
||
|
import java.io.IOException;
|
||
|
import o.C14953gcr;
|
||
|
import o.C14957gcv;
|
||
|
import o.gdZ;
|
||
|
import okhttp3.Headers;
|
||
|
import okhttp3.internal.Util;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public final class WebSocketExtensions {
|
||
|
public static final Companion Companion = new Companion(null);
|
||
|
private static final String HEADER_WEB_SOCKET_EXTENSION = "Sec-WebSocket-Extensions";
|
||
|
public final Integer clientMaxWindowBits;
|
||
|
public final boolean clientNoContextTakeover;
|
||
|
public final boolean perMessageDeflate;
|
||
|
public final Integer serverMaxWindowBits;
|
||
|
public final boolean serverNoContextTakeover;
|
||
|
public final boolean unknownValues;
|
||
|
|
||
|
public WebSocketExtensions(boolean z, Integer num, boolean z2, Integer num2, boolean z3, boolean z4) {
|
||
|
this.perMessageDeflate = z;
|
||
|
this.clientMaxWindowBits = num;
|
||
|
this.clientNoContextTakeover = z2;
|
||
|
this.serverMaxWindowBits = num2;
|
||
|
this.serverNoContextTakeover = z3;
|
||
|
this.unknownValues = z4;
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ WebSocketExtensions(boolean z, Integer num, boolean z2, Integer num2, boolean z3, boolean z4, int i, C14953gcr c14953gcr) {
|
||
|
this((i & 1) != 0 ? false : z, (i & 2) != 0 ? null : num, (i & 4) != 0 ? false : z2, (i & 8) == 0 ? num2 : null, (i & 16) != 0 ? false : z3, (i & 32) != 0 ? false : z4);
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public static final class Companion {
|
||
|
private Companion() {
|
||
|
}
|
||
|
|
||
|
public final WebSocketExtensions parse(Headers headers) throws IOException {
|
||
|
String str;
|
||
|
int i;
|
||
|
Headers headers2 = headers;
|
||
|
C14957gcv.e(headers2, "");
|
||
|
int size = headers.size();
|
||
|
int i2 = 0;
|
||
|
boolean z = false;
|
||
|
Integer num = null;
|
||
|
boolean z2 = false;
|
||
|
Integer num2 = null;
|
||
|
boolean z3 = false;
|
||
|
boolean z4 = false;
|
||
|
while (i2 < size) {
|
||
|
boolean z5 = true;
|
||
|
if (gdZ.a(headers2.name(i2), "Sec-WebSocket-Extensions", true)) {
|
||
|
String value = headers2.value(i2);
|
||
|
int i3 = 0;
|
||
|
while (i3 < value.length()) {
|
||
|
int delimiterOffset$default = Util.delimiterOffset$default(value, ',', i3, 0, 4, (Object) null);
|
||
|
int delimiterOffset = Util.delimiterOffset(value, ';', i3, delimiterOffset$default);
|
||
|
String trimSubstring = Util.trimSubstring(value, i3, delimiterOffset);
|
||
|
int i4 = delimiterOffset + (z5 ? 1 : 0);
|
||
|
if (gdZ.a(trimSubstring, "permessage-deflate", z5)) {
|
||
|
if (z) {
|
||
|
z4 = z5 ? 1 : 0;
|
||
|
}
|
||
|
while (true) {
|
||
|
i3 = i4;
|
||
|
while (i3 < delimiterOffset$default) {
|
||
|
int delimiterOffset2 = Util.delimiterOffset(value, ';', i3, delimiterOffset$default);
|
||
|
int delimiterOffset3 = Util.delimiterOffset(value, '=', i3, delimiterOffset2);
|
||
|
String trimSubstring2 = Util.trimSubstring(value, i3, delimiterOffset3);
|
||
|
if (delimiterOffset3 < delimiterOffset2) {
|
||
|
str = Util.trimSubstring(value, delimiterOffset3 + 1, delimiterOffset2);
|
||
|
C14957gcv.e(str, "");
|
||
|
C14957gcv.e(r3, "");
|
||
|
C14957gcv.e(str, "");
|
||
|
C14957gcv.e(r3, "");
|
||
|
C14957gcv.e(r3, "");
|
||
|
if (str.length() >= r3.length() + r3.length()) {
|
||
|
String str2 = str;
|
||
|
if (gdZ.e(str2, r3) && gdZ.d((CharSequence) str2, (CharSequence) r3)) {
|
||
|
str = str.substring(r3.length(), str.length() - r3.length());
|
||
|
C14957gcv.c((Object) str, "");
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
str = null;
|
||
|
}
|
||
|
i = delimiterOffset2 + 1;
|
||
|
if (gdZ.a(trimSubstring2, "client_max_window_bits", true)) {
|
||
|
if (num != null) {
|
||
|
z4 = true;
|
||
|
}
|
||
|
if (str == null) {
|
||
|
num = null;
|
||
|
} else {
|
||
|
C14957gcv.e(str, "");
|
||
|
num = gdZ.b(str);
|
||
|
}
|
||
|
if (num != null) {
|
||
|
break;
|
||
|
}
|
||
|
z5 = true;
|
||
|
} else if (gdZ.a(trimSubstring2, "client_no_context_takeover", true)) {
|
||
|
if (z2) {
|
||
|
z4 = true;
|
||
|
}
|
||
|
if (str != null) {
|
||
|
z4 = true;
|
||
|
}
|
||
|
i3 = i;
|
||
|
z2 = true;
|
||
|
z5 = true;
|
||
|
} else if (gdZ.a(trimSubstring2, "server_max_window_bits", true)) {
|
||
|
if (num2 != null) {
|
||
|
z4 = true;
|
||
|
}
|
||
|
if (str == null) {
|
||
|
num2 = null;
|
||
|
} else {
|
||
|
C14957gcv.e(str, "");
|
||
|
num2 = gdZ.b(str);
|
||
|
}
|
||
|
if (num2 != null) {
|
||
|
break;
|
||
|
}
|
||
|
z5 = true;
|
||
|
} else {
|
||
|
z5 = true;
|
||
|
z5 = true;
|
||
|
if (gdZ.a(trimSubstring2, "server_no_context_takeover", true)) {
|
||
|
if (z3) {
|
||
|
z4 = true;
|
||
|
}
|
||
|
if (str != null) {
|
||
|
z4 = true;
|
||
|
}
|
||
|
i3 = i;
|
||
|
z3 = true;
|
||
|
}
|
||
|
}
|
||
|
i3 = i;
|
||
|
z4 = z5 ? 1 : 0;
|
||
|
}
|
||
|
i4 = i;
|
||
|
z5 = true;
|
||
|
}
|
||
|
z = z5 ? 1 : 0;
|
||
|
} else {
|
||
|
i3 = i4;
|
||
|
z4 = z5 ? 1 : 0;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
i2++;
|
||
|
headers2 = headers;
|
||
|
}
|
||
|
return new WebSocketExtensions(z, num, z2, num2, z3, z4);
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ Companion(C14953gcr c14953gcr) {
|
||
|
this();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final String toString() {
|
||
|
StringBuilder sb = new StringBuilder("WebSocketExtensions(perMessageDeflate=");
|
||
|
sb.append(this.perMessageDeflate);
|
||
|
sb.append(", clientMaxWindowBits=");
|
||
|
sb.append(this.clientMaxWindowBits);
|
||
|
sb.append(", clientNoContextTakeover=");
|
||
|
sb.append(this.clientNoContextTakeover);
|
||
|
sb.append(", serverMaxWindowBits=");
|
||
|
sb.append(this.serverMaxWindowBits);
|
||
|
sb.append(", serverNoContextTakeover=");
|
||
|
sb.append(this.serverNoContextTakeover);
|
||
|
sb.append(", unknownValues=");
|
||
|
sb.append(this.unknownValues);
|
||
|
sb.append(')');
|
||
|
return sb.toString();
|
||
|
}
|
||
|
|
||
|
public final boolean noContextTakeover(boolean z) {
|
||
|
return z ? this.clientNoContextTakeover : this.serverNoContextTakeover;
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
/* JADX WARN: Type inference failed for: r0v1, types: [int] */
|
||
|
/* JADX WARN: Type inference failed for: r0v12 */
|
||
|
/* JADX WARN: Type inference failed for: r0v13 */
|
||
|
/* JADX WARN: Type inference failed for: r4v0, types: [boolean] */
|
||
|
/* JADX WARN: Type inference failed for: r5v1, types: [boolean] */
|
||
|
public final int hashCode() {
|
||
|
boolean z = this.perMessageDeflate;
|
||
|
?? r0 = z;
|
||
|
if (z) {
|
||
|
r0 = 1;
|
||
|
}
|
||
|
Integer num = this.clientMaxWindowBits;
|
||
|
int hashCode = num == null ? 0 : num.hashCode();
|
||
|
?? r4 = this.clientNoContextTakeover;
|
||
|
int i = r4;
|
||
|
if (r4 != 0) {
|
||
|
i = 1;
|
||
|
}
|
||
|
Integer num2 = this.serverMaxWindowBits;
|
||
|
int hashCode2 = num2 != null ? num2.hashCode() : 0;
|
||
|
?? r5 = this.serverNoContextTakeover;
|
||
|
int i2 = r5;
|
||
|
if (r5 != 0) {
|
||
|
i2 = 1;
|
||
|
}
|
||
|
boolean z2 = this.unknownValues;
|
||
|
return (((((((((r0 * 31) + hashCode) * 31) + i) * 31) + hashCode2) * 31) + i2) * 31) + (z2 ? 1 : z2 ? 1 : 0);
|
||
|
}
|
||
|
|
||
|
public final boolean equals(Object obj) {
|
||
|
if (this == obj) {
|
||
|
return true;
|
||
|
}
|
||
|
if (!(obj instanceof WebSocketExtensions)) {
|
||
|
return false;
|
||
|
}
|
||
|
WebSocketExtensions webSocketExtensions = (WebSocketExtensions) obj;
|
||
|
return this.perMessageDeflate == webSocketExtensions.perMessageDeflate && C14957gcv.b(this.clientMaxWindowBits, webSocketExtensions.clientMaxWindowBits) && this.clientNoContextTakeover == webSocketExtensions.clientNoContextTakeover && C14957gcv.b(this.serverMaxWindowBits, webSocketExtensions.serverMaxWindowBits) && this.serverNoContextTakeover == webSocketExtensions.serverNoContextTakeover && this.unknownValues == webSocketExtensions.unknownValues;
|
||
|
}
|
||
|
|
||
|
public final WebSocketExtensions copy(boolean z, Integer num, boolean z2, Integer num2, boolean z3, boolean z4) {
|
||
|
return new WebSocketExtensions(z, num, z2, num2, z3, z4);
|
||
|
}
|
||
|
|
||
|
public final boolean component6() {
|
||
|
return this.unknownValues;
|
||
|
}
|
||
|
|
||
|
public final boolean component5() {
|
||
|
return this.serverNoContextTakeover;
|
||
|
}
|
||
|
|
||
|
public final Integer component4() {
|
||
|
return this.serverMaxWindowBits;
|
||
|
}
|
||
|
|
||
|
public final boolean component3() {
|
||
|
return this.clientNoContextTakeover;
|
||
|
}
|
||
|
|
||
|
public final Integer component2() {
|
||
|
return this.clientMaxWindowBits;
|
||
|
}
|
||
|
|
||
|
public final boolean component1() {
|
||
|
return this.perMessageDeflate;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ WebSocketExtensions copy$default(WebSocketExtensions webSocketExtensions, boolean z, Integer num, boolean z2, Integer num2, boolean z3, boolean z4, int i, Object obj) {
|
||
|
if ((i & 1) != 0) {
|
||
|
z = webSocketExtensions.perMessageDeflate;
|
||
|
}
|
||
|
if ((i & 2) != 0) {
|
||
|
num = webSocketExtensions.clientMaxWindowBits;
|
||
|
}
|
||
|
Integer num3 = num;
|
||
|
if ((i & 4) != 0) {
|
||
|
z2 = webSocketExtensions.clientNoContextTakeover;
|
||
|
}
|
||
|
boolean z5 = z2;
|
||
|
if ((i & 8) != 0) {
|
||
|
num2 = webSocketExtensions.serverMaxWindowBits;
|
||
|
}
|
||
|
Integer num4 = num2;
|
||
|
if ((i & 16) != 0) {
|
||
|
z3 = webSocketExtensions.serverNoContextTakeover;
|
||
|
}
|
||
|
boolean z6 = z3;
|
||
|
if ((i & 32) != 0) {
|
||
|
z4 = webSocketExtensions.unknownValues;
|
||
|
}
|
||
|
return webSocketExtensions.copy(z, num3, z5, num4, z6, z4);
|
||
|
}
|
||
|
|
||
|
public WebSocketExtensions() {
|
||
|
this(false, null, false, null, false, false, 63, null);
|
||
|
}
|
||
|
}
|