Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@ -257,14 +257,16 @@ namespace System.Net
connect_request.Credentials = creds;
}
for (int i = 0; i < challenge.Length; i++) {
var auth = AuthenticationManager.Authenticate (challenge [i], connect_request, creds);
if (auth == null)
continue;
ntlm = (auth.ModuleAuthenticationType == "NTLM");
sb.Append ("\r\nProxy-Authorization: ");
sb.Append (auth.Message);
break;
if (creds != null) {
for (int i = 0; i < challenge.Length; i++) {
var auth = AuthenticationManager.Authenticate (challenge [i], connect_request, creds);
if (auth == null)
continue;
ntlm = (auth.ModuleAuthenticationType == "NTLM");
sb.Append ("\r\nProxy-Authorization: ");
sb.Append (auth.Message);
break;
}
}
}
@ -292,11 +294,14 @@ namespace System.Net
}
Data.StatusCode = status;
Data.Challenge = result.GetValues ("Proxy-Authentic");
Data.Challenge = result.GetValues ("Proxy-Authenticate");
Data.Headers = result;
return false;
} else if (status != 200) {
string msg = String.Format ("The remote server returned a {0} status code.", status);
HandleError (WebExceptionStatus.SecureChannelFailure, null, msg);
}
if (status != 200) {
Data.StatusCode = status;
Data.Headers = result;
return false;
}
@ -368,6 +373,9 @@ namespace System.Net
}
status = (int)UInt32.Parse (parts [1]);
if (parts.Length >= 3)
Data.StatusDescription = String.Join (" ", parts, 2, parts.Length - 2);
gotStatus = true;
}
}
@ -670,7 +678,7 @@ namespace System.Net
var value = s.Substring (pos_s + 1).Trim ();
var h = data.Headers;
if (h.AllowMultiValues (header)) {
if (WebHeaderCollection.AllowMultiValues (header)) {
h.AddInternal (header, value);
} else {
h.SetInternal (header, value);
@ -736,6 +744,15 @@ namespace System.Net
goto retry;
Exception cnc_exc = connect_exception;
if (cnc_exc == null && (Data.StatusCode == 401 || Data.StatusCode == 407)) {
st = WebExceptionStatus.ProtocolError;
if (Data.Headers == null)
Data.Headers = new WebHeaderCollection ();
var webResponse = new HttpWebResponse (sPoint.Address, "CONNECT", Data, null);
cnc_exc = new WebException (Data.StatusCode == 407 ? "(407) Proxy Authentication Required" : "(401) Unauthorized", null, st, webResponse);
}
connect_exception = null;
request.SetWriteStreamError (st, cnc_exc);
Close (true);
@ -896,6 +913,8 @@ namespace System.Net
{
Stream s = null;
lock (this) {
if (request.Aborted)
throw new WebException ("Request aborted", WebExceptionStatus.RequestCanceled);
if (Data.request != request)
throw new ObjectDisposedException (typeof (NetworkStream).FullName);
if (nstream == null)