changeset 16:fba35b87da32

HTTP: Fix bug in tar file handling (incorrect data length)
author Ivo Smits <Ivo@UCIS.nl>
date Sat, 30 Mar 2013 16:41:14 +0100
parents 7c1808f28e05
children 5d9a7186c9f7
files Net/HTTP.cs
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Net/HTTP.cs	Fri Mar 15 00:02:58 2013 +0100
+++ b/Net/HTTP.cs	Sat Mar 30 16:41:14 2013 +0100
@@ -420,9 +420,9 @@
 						if (ctype != null) context.SendHeader("Content-Type", ctype);
 						Stream response = context.GetResponseStream();
 						int left = fsizei;
+						byte[] buffer = new byte[Math.Min(left, 1024 * 10)];
 						while (left > 0) {
-							byte[] buffer = new byte[1024 * 10];
-							int len = fs.Read(buffer, 0, buffer.Length);
+							int len = fs.Read(buffer, 0, Math.Min(left, buffer.Length));
 							if (len <= 0) break;
 							left -= len;
 							response.Write(buffer, 0, len);