StringBody: just write the bytes to the output stream

This commit is contained in:
John Gallagher 2022-03-15 16:38:52 -04:00 committed by Oleg Kalnichevski
parent 6a487ba686
commit 5f9bc347ee
1 changed files with 1 additions and 8 deletions

View File

@ -29,7 +29,6 @@ package org.apache.hc.client5.http.entity.mime;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
@ -70,13 +69,7 @@ public class StringBody extends AbstractContentBody {
@Override
public void writeTo(final OutputStream out) throws IOException {
Args.notNull(out, "Output stream");
final InputStream in = new ByteArrayInputStream(this.content);
final byte[] tmp = new byte[4096];
int l;
while ((l = in.read(tmp)) != -1) {
out.write(tmp, 0, l);
}
out.flush();
out.write(this.content);
}
@Override