소스 검색

[#7258][Web]: Check 'Connection: close' header.

When receiving a 407 in CreateTunnel(), check whether the server
asks to close the connection.

Thanks again to Christian Gan for this patch.
Martin Baulig 13 년 전
부모
커밋
c399f1024b
1개의 변경된 파일8개의 추가작업 그리고 0개의 파일을 삭제
  1. 8 0
      mcs/class/System/System.Net/WebConnection.cs

+ 8 - 0
mcs/class/System/System.Net/WebConnection.cs

@@ -320,6 +320,14 @@ namespace System.Net
 			WebHeaderCollection result = ReadHeaders (stream, out buffer, out status);
 			if ((!have_auth || connect_ntlm_auth_state == NtlmAuthState.Challenge) &&
 			    result != null && status == 407) { // Needs proxy auth
+				var connectionHeader = result ["Connection"];
+				if (socket != null && !string.IsNullOrEmpty (connectionHeader) &&
+				    connectionHeader.ToLower() == "close") {
+					// The server is requesting that this connection be closed
+					socket.Close();
+					socket = null;
+				}
+
 				Data.StatusCode = status;
 				Data.Challenge = result.GetValues_internal ("Proxy-Authenticate", false);
 				return false;