Use buffered input stream in getURL

This commit is contained in:
hns 2002-10-27 18:54:26 +00:00
parent 2922208ccc
commit 01254c1a88

View file

@ -599,14 +599,14 @@ public final class HopExtension {
if (con instanceof HttpURLConnection) if (con instanceof HttpURLConnection)
resCode = ((HttpURLConnection) con).getResponseCode(); resCode = ((HttpURLConnection) con).getResponseCode();
ByteArrayOutputStream body = new ByteArrayOutputStream (); ByteArrayOutputStream body = new ByteArrayOutputStream ();
InputStream in = con.getInputStream ();
if (length != 0 && resCode != 304) { if (length != 0 && resCode != 304) {
InputStream in = new BufferedInputStream(con.getInputStream ());
byte[] b = new byte[1024]; byte[] b = new byte[1024];
int read; int read;
while ((read = in.read (b)) > -1) while ((read = in.read (b)) > -1)
body.write (b, 0, read); body.write (b, 0, read);
}
in.close (); in.close ();
}
MimePart mime = new MimePart (filename, body.toByteArray(), contentType); MimePart mime = new MimePart (filename, body.toByteArray(), contentType);
if (lastmod > 0) if (lastmod > 0)
mime.lastModified = new Date(lastmod); mime.lastModified = new Date(lastmod);