瀏覽代碼

[Http]: Fix the loop in WebConnection.ReadHeaders().

We need to reset `gotStatus' each time we enter the outer loop or we
would attempt to interpret the status line as a header.
Martin Baulig 11 年之前
父節點
當前提交
5428bdfb71
共有 1 個文件被更改,包括 2 次插入3 次删除
  1. 2 3
      mcs/class/System/System.Net/WebConnection.cs

+ 2 - 3
mcs/class/System/System.Net/WebConnection.cs

@@ -356,8 +356,6 @@ namespace System.Net
 
 			byte [] buffer = new byte [1024];
 			MemoryStream ms = new MemoryStream ();
-			bool gotStatus = false;
-			WebHeaderCollection headers = null;
 
 			while (true) {
 				int n = stream.Read (buffer, 0, 1024);
@@ -369,7 +367,8 @@ namespace System.Net
 				ms.Write (buffer, 0, n);
 				int start = 0;
 				string str = null;
-				headers = new WebHeaderCollection ();
+				bool gotStatus = false;
+				WebHeaderCollection headers = new WebHeaderCollection ();
 				while (ReadLine (ms.GetBuffer (), ref start, (int) ms.Length, ref str)) {
 					if (str == null) {
 						int contentLen = 0;