mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-29 09:13:24 +01:00
64 lines
1.9 KiB
Java
64 lines
1.9 KiB
Java
package org.apache.http.entity;
|
|
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import org.apache.http.impl.io.EmptyInputStream;
|
|
import org.apache.http.util.Args;
|
|
import org.apache.http.util.Asserts;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes11.dex */
|
|
public class BasicHttpEntity extends AbstractHttpEntity {
|
|
private InputStream content;
|
|
private long length = -1;
|
|
|
|
@Override // org.apache.http.HttpEntity
|
|
public InputStream getContent() throws IllegalStateException {
|
|
Asserts.check(this.content != null, "Content has not been provided");
|
|
return this.content;
|
|
}
|
|
|
|
@Override // org.apache.http.HttpEntity
|
|
public long getContentLength() {
|
|
return this.length;
|
|
}
|
|
|
|
@Override // org.apache.http.HttpEntity
|
|
public boolean isRepeatable() {
|
|
return false;
|
|
}
|
|
|
|
@Override // org.apache.http.HttpEntity
|
|
public boolean isStreaming() {
|
|
InputStream inputStream = this.content;
|
|
return (inputStream == null || inputStream == EmptyInputStream.INSTANCE) ? false : true;
|
|
}
|
|
|
|
public void setContent(InputStream inputStream) {
|
|
this.content = inputStream;
|
|
}
|
|
|
|
public void setContentLength(long j) {
|
|
this.length = j;
|
|
}
|
|
|
|
@Override // org.apache.http.HttpEntity
|
|
public void writeTo(OutputStream outputStream) throws IOException {
|
|
Args.notNull(outputStream, "Output stream");
|
|
InputStream content = getContent();
|
|
try {
|
|
byte[] bArr = new byte[4096];
|
|
while (true) {
|
|
int read = content.read(bArr);
|
|
if (read == -1) {
|
|
return;
|
|
} else {
|
|
outputStream.write(bArr, 0, read);
|
|
}
|
|
}
|
|
} finally {
|
|
content.close();
|
|
}
|
|
}
|
|
}
|