mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-29 09:13:24 +01:00
63 lines
2.3 KiB
Java
63 lines
2.3 KiB
Java
package org.apache.http.entity;
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import org.apache.http.HttpEntity;
|
|
import org.apache.http.util.Args;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes11.dex */
|
|
public class BufferedHttpEntity extends HttpEntityWrapper {
|
|
private final byte[] buffer;
|
|
|
|
public BufferedHttpEntity(HttpEntity httpEntity) throws IOException {
|
|
super(httpEntity);
|
|
if (httpEntity.isRepeatable() && httpEntity.getContentLength() >= 0) {
|
|
this.buffer = null;
|
|
return;
|
|
}
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
httpEntity.writeTo(byteArrayOutputStream);
|
|
byteArrayOutputStream.flush();
|
|
this.buffer = byteArrayOutputStream.toByteArray();
|
|
}
|
|
|
|
@Override // org.apache.http.entity.HttpEntityWrapper, org.apache.http.HttpEntity
|
|
public InputStream getContent() throws IOException {
|
|
return this.buffer != null ? new ByteArrayInputStream(this.buffer) : super.getContent();
|
|
}
|
|
|
|
@Override // org.apache.http.entity.HttpEntityWrapper, org.apache.http.HttpEntity
|
|
public long getContentLength() {
|
|
return this.buffer != null ? r0.length : super.getContentLength();
|
|
}
|
|
|
|
@Override // org.apache.http.entity.HttpEntityWrapper, org.apache.http.HttpEntity
|
|
public boolean isChunked() {
|
|
return this.buffer == null && super.isChunked();
|
|
}
|
|
|
|
@Override // org.apache.http.entity.HttpEntityWrapper, org.apache.http.HttpEntity
|
|
public boolean isRepeatable() {
|
|
return true;
|
|
}
|
|
|
|
@Override // org.apache.http.entity.HttpEntityWrapper, org.apache.http.HttpEntity
|
|
public boolean isStreaming() {
|
|
return this.buffer == null && super.isStreaming();
|
|
}
|
|
|
|
@Override // org.apache.http.entity.HttpEntityWrapper, org.apache.http.HttpEntity
|
|
public void writeTo(OutputStream outputStream) throws IOException {
|
|
Args.notNull(outputStream, "Output stream");
|
|
byte[] bArr = this.buffer;
|
|
if (bArr != null) {
|
|
outputStream.write(bArr);
|
|
} else {
|
|
super.writeTo(outputStream);
|
|
}
|
|
}
|
|
}
|