package com.meizu.cloud.pushsdk.c.c; import android.net.TrafficStats; import com.baidu.techain.ac.U; import com.meizu.cloud.pushsdk.c.a.a; import com.meizu.cloud.pushsdk.c.c.k; import com.meizu.cloud.pushsdk.c.g.c; import com.meizu.cloud.pushsdk.c.g.d; import com.meizu.cloud.pushsdk.c.g.g; import com.meizu.cloud.pushsdk.util.MinSdkChecker; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; public class e implements a { private static l a(final HttpURLConnection httpURLConnection) throws IOException { if (!httpURLConnection.getDoInput()) { return null; } final d a = g.a(g.a(a(httpURLConnection.getResponseCode()) ? httpURLConnection.getInputStream() : httpURLConnection.getErrorStream())); return new l() { /* class com.meizu.cloud.pushsdk.c.c.e.AnonymousClass1 */ @Override // com.meizu.cloud.pushsdk.c.c.l public final d a() { return a; } }; } private static void a(HttpURLConnection httpURLConnection, i iVar) throws IOException { int c = iVar.c(); if (c == 0) { httpURLConnection.setRequestMethod("GET"); } else if (c == 1) { httpURLConnection.setRequestMethod("POST"); b(httpURLConnection, iVar); } else if (c == 2) { httpURLConnection.setRequestMethod("PUT"); b(httpURLConnection, iVar); } else if (c == 3) { httpURLConnection.setRequestMethod("DELETE"); } else if (c == 4) { httpURLConnection.setRequestMethod("HEAD"); } else if (c == 5) { httpURLConnection.setRequestMethod("PATCH"); b(httpURLConnection, iVar); } else { throw new IllegalStateException("Unknown method type."); } } protected static boolean a(int i) { return i >= 200 && i < 300; } private HttpURLConnection b(i iVar) throws IOException { URL url = new URL(iVar.a().toString()); if (MinSdkChecker.isSupportNotificationChannel()) { TrafficStats.setThreadStatsTag(2006537699); } HttpURLConnection a = a(url); a.setConnectTimeout(U.MINUTE); a.setReadTimeout(U.MINUTE); a.setUseCaches(false); a.setDoInput(true); return a; } private static void b(HttpURLConnection httpURLConnection, i iVar) throws IOException { j e = iVar.e(); if (e != null) { httpURLConnection.setDoOutput(true); httpURLConnection.addRequestProperty("Content-Type", e.a().toString()); c a = g.a(g.a(httpURLConnection.getOutputStream())); e.a(a); a.close(); } } @Override // com.meizu.cloud.pushsdk.c.c.a public k a(i iVar) throws IOException { HttpURLConnection b = b(iVar); for (String str : iVar.d().b()) { String a = iVar.a(str); a.b("current header name " + str + " value " + a); b.addRequestProperty(str, a); } a(b, iVar); int responseCode = b.getResponseCode(); return new k.a().a(responseCode).a(iVar.d()).a(b.getResponseMessage()).a(iVar).a(a(b)).a(); } /* access modifiers changed from: protected */ public HttpURLConnection a(URL url) throws IOException { HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); httpURLConnection.setInstanceFollowRedirects(HttpURLConnection.getFollowRedirects()); return httpURLConnection; } }