Преглед на файлове

[System] Report an error instead of success when proxy authentication is required. Fixes #19594

Marek Safar преди 9 години
родител
ревизия
870cbdc8b9
променени са 1 файла, в които са добавени 5 реда и са изтрити 0 реда
  1. 5 0
      mcs/class/System/System.Net/WebConnection.cs

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

@@ -736,6 +736,11 @@ namespace System.Net
 					goto retry;
 
 				Exception cnc_exc = connect_exception;
+				if (cnc_exc == null && (Data.StatusCode == 401 || Data.StatusCode == 407)) {
+					st = WebExceptionStatus.ProtocolError;
+					cnc_exc = new WebException (Data.StatusCode == 407 ? "(407) Proxy Authentication Required" : "(401) Unauthorized" , st);
+				}
+			
 				connect_exception = null;
 				request.SetWriteStreamError (st, cnc_exc);
 				Close (true);