package com.google.android.gms.internal.ads; import android.text.TextUtils; import androidx.annotation.Nullable; import com.ironsource.v8; import java.util.regex.Matcher; import java.util.regex.Pattern; /* loaded from: classes3.dex */ public final class zzgu { private static final Pattern zza = Pattern.compile("bytes (\\d+)-(\\d+)/(?:\\d+|\\*)"); private static final Pattern zzb = Pattern.compile("bytes (?:(?:\\d+-\\d+)|\\*)/(\\d+)"); public static long zza(@Nullable String str, @Nullable String str2) { long j = -1; if (!TextUtils.isEmpty(str)) { try { j = Long.parseLong(str); } catch (NumberFormatException unused) { zzdo.zzc("HttpUtil", "Unexpected Content-Length [" + str + v8.i.e); } } if (TextUtils.isEmpty(str2)) { return j; } Matcher matcher = zza.matcher(str2); if (!matcher.matches()) { return j; } try { String group = matcher.group(2); group.getClass(); long parseLong = Long.parseLong(group); String group2 = matcher.group(1); group2.getClass(); long parseLong2 = (parseLong - Long.parseLong(group2)) + 1; if (j < 0) { return parseLong2; } if (j == parseLong2) { return j; } zzdo.zzf("HttpUtil", "Inconsistent headers [" + str + "] [" + str2 + v8.i.e); return Math.max(j, parseLong2); } catch (NumberFormatException unused2) { zzdo.zzc("HttpUtil", "Unexpected Content-Range [" + str2 + v8.i.e); return j; } } public static long zzb(@Nullable String str) { if (TextUtils.isEmpty(str)) { return -1L; } Matcher matcher = zzb.matcher(str); if (!matcher.matches()) { return -1L; } String group = matcher.group(1); group.getClass(); return Long.parseLong(group); } }