package com.alibaba.sdk.android.oss.internal; import android.text.TextUtils; import android.util.Xml; import com.alibaba.sdk.android.oss.ClientException; import com.alibaba.sdk.android.oss.ServiceException; import com.alibaba.sdk.android.oss.common.OSSLog; import com.alibaba.sdk.android.oss.model.PutObjectResult; import java.io.ByteArrayInputStream; import java.io.IOException; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; /* loaded from: classes.dex */ public final class ResponseParsers { public static final class PutObjectResponseParser extends AbstractResponseParser { @Override // com.alibaba.sdk.android.oss.internal.AbstractResponseParser public /* bridge */ /* synthetic */ PutObjectResult a(ResponseMessage responseMessage, PutObjectResult putObjectResult) throws Exception { PutObjectResult putObjectResult2 = putObjectResult; a2(responseMessage, putObjectResult2); return putObjectResult2; } /* renamed from: a, reason: avoid collision after fix types in other method */ public PutObjectResult a2(ResponseMessage responseMessage, PutObjectResult putObjectResult) throws IOException { putObjectResult.b(ResponseParsers.a(responseMessage.d().get("ETag"))); String string = responseMessage.g().body().string(); if (!TextUtils.isEmpty(string)) { putObjectResult.c(string); } return putObjectResult; } } public static String a(String str) { if (str == null) { return null; } String trim = str.trim(); if (trim.startsWith("\"")) { trim = trim.substring(1); } return trim.endsWith("\"") ? trim.substring(0, trim.length() - 1) : trim; } public static ServiceException a(ResponseMessage responseMessage, boolean z) throws ClientException { String str; String str2; String str3; String str4; String str5; String str6; int h = responseMessage.h(); String header = responseMessage.g().header("x-oss-request-id"); String str7 = null; if (z) { str4 = header; str6 = null; str3 = null; str = null; str5 = null; str2 = null; } else { try { String string = responseMessage.g().body().string(); OSSLog.a("errorMessage : \n " + string); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(string.getBytes()); XmlPullParser newPullParser = Xml.newPullParser(); newPullParser.setInput(byteArrayInputStream, "utf-8"); int eventType = newPullParser.getEventType(); String str8 = null; str = null; String str9 = null; str2 = null; while (eventType != 1) { if (eventType == 2) { if ("Code".equals(newPullParser.getName())) { str7 = newPullParser.nextText(); } else if ("Message".equals(newPullParser.getName())) { str8 = newPullParser.nextText(); } else if ("RequestId".equals(newPullParser.getName())) { header = newPullParser.nextText(); } else if ("HostId".equals(newPullParser.getName())) { str = newPullParser.nextText(); } else if ("PartNumber".equals(newPullParser.getName())) { str9 = newPullParser.nextText(); } else if ("PartEtag".equals(newPullParser.getName())) { str2 = newPullParser.nextText(); } } eventType = newPullParser.next(); if (eventType == 4) { eventType = newPullParser.next(); } } str3 = str7; str7 = str8; str4 = header; String str10 = str9; str5 = string; str6 = str10; } catch (IOException e) { throw new ClientException(e); } catch (XmlPullParserException e2) { throw new ClientException(e2); } } ServiceException serviceException = new ServiceException(h, str7, str3, str4, str, str5); if (!TextUtils.isEmpty(str2)) { serviceException.setPartEtag(str2); } if (!TextUtils.isEmpty(str6)) { serviceException.setPartNumber(str6); } return serviceException; } }