Imported Upstream version 5.14.0.148

Former-commit-id: ccfce85f9487e4135d045a812192413d573f33be
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-06-28 08:19:18 +00:00
parent 7aa1346787
commit 01c08d50e8
40 changed files with 76 additions and 61 deletions

View File

@ -1 +1 @@
713caa60a19e1ee461b6a5c649af0cc5b13ed0d8 e789bf066e17b66380a6d80f845e05195c813c63

View File

@ -1 +1 @@
55898c9df985bda0d229f0e58ed686a170b20ebd af067b29dfbfeb81540f1127a7bd9613dd7b0bfa

View File

@ -34,7 +34,7 @@ static class Consts
// Use these assembly version constants to make code more maintainable. // Use these assembly version constants to make code more maintainable.
// //
public const string MonoVersion = "5.14.0.147"; public const string MonoVersion = "5.14.0.148";
public const string MonoCompany = "Mono development team"; public const string MonoCompany = "Mono development team";
public const string MonoProduct = "Mono Common Language Infrastructure"; public const string MonoProduct = "Mono Common Language Infrastructure";
public const string MonoCopyright = "(c) Various Mono authors"; public const string MonoCopyright = "(c) Various Mono authors";

View File

@ -769,7 +769,7 @@ namespace MonoTests.System.Net.Http
client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Wait (); client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Wait ();
Assert.Fail ("#1"); Assert.Fail ("#1");
} catch (AggregateException e) { } catch (AggregateException e) {
Assert.AreEqual (typeof (ProtocolViolationException), e.InnerException.GetType (), "#2"); Assert.AreEqual (typeof (InvalidOperationException), e.InnerException.GetType (), "#2");
} }
Assert.IsNull (failed, "#102"); Assert.IsNull (failed, "#102");
} finally { } finally {

View File

@ -434,7 +434,6 @@ namespace System.Net
} }
public string Host { public string Host {
get { get {
Uri uri = hostUri ?? Address; Uri uri = hostUri ?? Address;
return (hostUri == null || !hostHasPort) && Address.IsDefaultPort ? return (hostUri == null || !hostHasPort) && Address.IsDefaultPort ?
@ -858,22 +857,21 @@ namespace System.Net
if (Aborted) if (Aborted)
throw CreateRequestAbortedException (); throw CreateRequestAbortedException ();
bool send = !(method == "GET" || method == "CONNECT" || method == "HEAD" || bool send = !(method == "GET" || method == "CONNECT" || method == "HEAD" || method == "TRACE");
method == "TRACE");
if (method == null || !send) if (method == null || !send)
throw new ProtocolViolationException ("Cannot send data when method is: " + method); throw new ProtocolViolationException (SR.net_nouploadonget);
if (contentLength == -1 && !sendChunked && !allowBuffering && KeepAlive) if (contentLength == -1 && !sendChunked && !allowBuffering && KeepAlive)
throw new ProtocolViolationException ("Content-Length not set"); throw new ProtocolViolationException ("Content-Length not set");
string transferEncoding = TransferEncoding; string transferEncoding = TransferEncoding;
if (!sendChunked && transferEncoding != null && transferEncoding.Trim () != "") if (!sendChunked && transferEncoding != null && transferEncoding.Trim () != "")
throw new ProtocolViolationException ("SendChunked should be true."); throw new InvalidOperationException (SR.net_needchunked);
WebOperation operation; WebOperation operation;
lock (locker) { lock (locker) {
if (getResponseCalled) if (getResponseCalled)
throw new InvalidOperationException ("The operation cannot be performed once the request has been submitted."); throw new InvalidOperationException (SR.net_reqsubmitted);
operation = currentOperation; operation = currentOperation;
if (operation == null) { if (operation == null) {
@ -900,7 +898,7 @@ namespace System.Net
try { try {
return TaskToApm.End<Stream> (asyncResult); return TaskToApm.End<Stream> (asyncResult);
} catch (Exception e) { } catch (Exception e) {
throw FlattenException (e); throw GetWebException (e);
} }
} }
@ -909,7 +907,7 @@ namespace System.Net
try { try {
return GetRequestStreamAsync ().Result; return GetRequestStreamAsync ().Result;
} catch (Exception e) { } catch (Exception e) {
throw FlattenException (e); throw GetWebException (e);
} }
} }
@ -925,17 +923,18 @@ namespace System.Net
} }
internal static Task<T> RunWithTimeout<T> ( internal static Task<T> RunWithTimeout<T> (
Func<CancellationToken, Task<T>> func, int timeout, Action abort) Func<CancellationToken, Task<T>> func, int timeout, Action abort,
Func<bool> aborted, CancellationToken cancellationToken)
{ {
var cts = CancellationTokenSource.CreateLinkedTokenSource (cancellationToken);
// Call `func` here to propagate any potential exception that it // Call `func` here to propagate any potential exception that it
// might throw to our caller rather than returning a faulted task. // might throw to our caller rather than returning a faulted task.
var cts = new CancellationTokenSource ();
var workerTask = func (cts.Token); var workerTask = func (cts.Token);
return RunWithTimeoutWorker (workerTask, timeout, abort, cts); return RunWithTimeoutWorker (workerTask, timeout, abort, aborted, cts);
} }
static async Task<T> RunWithTimeoutWorker<T> ( static async Task<T> RunWithTimeoutWorker<T> (
Task<T> workerTask, int timeout, Action abort, Task<T> workerTask, int timeout, Action abort, Func<bool> aborted,
CancellationTokenSource cts) CancellationTokenSource cts)
{ {
try { try {
@ -949,7 +948,7 @@ namespace System.Net
} }
throw new WebException (SR.net_timeout, WebExceptionStatus.Timeout); throw new WebException (SR.net_timeout, WebExceptionStatus.Timeout);
} catch (Exception ex) { } catch (Exception ex) {
throw FlattenException (ex); throw GetWebException (ex, aborted ());
} finally { } finally {
cts.Dispose (); cts.Dispose ();
} }
@ -957,7 +956,11 @@ namespace System.Net
Task<T> RunWithTimeout<T> (Func<CancellationToken, Task<T>> func) Task<T> RunWithTimeout<T> (Func<CancellationToken, Task<T>> func)
{ {
return RunWithTimeout (func, timeout, Abort); // Call `func` here to propagate any potential exception that it
// might throw to our caller rather than returning a faulted task.
var cts = new CancellationTokenSource ();
var workerTask = func (cts.Token);
return RunWithTimeoutWorker (workerTask, timeout, Abort, () => Aborted, cts);
} }
async Task<HttpWebResponse> MyGetResponseAsync (CancellationToken cancellationToken) async Task<HttpWebResponse> MyGetResponseAsync (CancellationToken cancellationToken)
@ -965,13 +968,6 @@ namespace System.Net
if (Aborted) if (Aborted)
throw CreateRequestAbortedException (); throw CreateRequestAbortedException ();
if (method == null)
throw new ProtocolViolationException ("Method is null.");
string transferEncoding = TransferEncoding;
if (!sendChunked && transferEncoding != null && transferEncoding.Trim () != "")
throw new ProtocolViolationException ("SendChunked should be true.");
var completion = new WebCompletionSource (); var completion = new WebCompletionSource ();
WebOperation operation; WebOperation operation;
lock (locker) { lock (locker) {
@ -1145,13 +1141,18 @@ namespace System.Net
} }
WebException GetWebException (Exception e) WebException GetWebException (Exception e)
{
return GetWebException (e, Aborted);
}
static WebException GetWebException (Exception e, bool aborted)
{ {
e = FlattenException (e); e = FlattenException (e);
if (e is WebException wexc) { if (e is WebException wexc) {
if (!Aborted || wexc.Status == WebExceptionStatus.RequestCanceled || wexc.Status == WebExceptionStatus.Timeout) if (!aborted || wexc.Status == WebExceptionStatus.RequestCanceled || wexc.Status == WebExceptionStatus.Timeout)
return wexc; return wexc;
} }
if (Aborted || e is OperationCanceledException || e is ObjectDisposedException) if (aborted || e is OperationCanceledException || e is ObjectDisposedException)
return CreateRequestAbortedException (); return CreateRequestAbortedException ();
return new WebException (e.Message, e, WebExceptionStatus.UnknownError, null); return new WebException (e.Message, e, WebExceptionStatus.UnknownError, null);
} }
@ -1166,6 +1167,20 @@ namespace System.Net
if (Aborted) if (Aborted)
throw CreateRequestAbortedException (); throw CreateRequestAbortedException ();
string transferEncoding = TransferEncoding;
if (!sendChunked && transferEncoding != null && transferEncoding.Trim () != "") {
/*
* The only way we could get here without already catching this in the
* `TransferEncoding` property settor is via HttpClient, which does not
* do strict checking on all headers.
*
* We can remove this check again after switching to the CoreFX version
* of HttpClient.
*
*/
throw new InvalidOperationException (SR.net_needchunked);
}
return TaskToApm.Begin (RunWithTimeout (MyGetResponseAsync), callback, state); return TaskToApm.Begin (RunWithTimeout (MyGetResponseAsync), callback, state);
} }
@ -1177,7 +1192,7 @@ namespace System.Net
try { try {
return TaskToApm.End<HttpWebResponse> (asyncResult); return TaskToApm.End<HttpWebResponse> (asyncResult);
} catch (Exception e) { } catch (Exception e) {
throw FlattenException (e); throw GetWebException (e);
} }
} }
@ -1195,7 +1210,7 @@ namespace System.Net
try { try {
return GetResponseAsync ().Result; return GetResponseAsync ().Result;
} catch (Exception e) { } catch (Exception e) {
throw FlattenException (e); throw GetWebException (e);
} }
} }

View File

@ -149,7 +149,7 @@ namespace System.Net
ReadTimeout, () => { ReadTimeout, () => {
Operation.Abort (); Operation.Abort ();
InnerStream.Dispose (); InnerStream.Dispose ();
}).ConfigureAwait (false); }, () => Operation.Aborted, cancellationToken).ConfigureAwait (false);
} catch (Exception e) { } catch (Exception e) {
throwMe = GetReadException (WebExceptionStatus.ReceiveFailure, e, "ReadAsync"); throwMe = GetReadException (WebExceptionStatus.ReceiveFailure, e, "ReadAsync");
} }

View File

@ -1 +1 @@
befc828e193756128a4b0755432ce5d10d2cc1e4 b81e5105b4a226b866e9d4b525c04d6024ed558b

View File

@ -1 +1 @@
5c0ce009774f46b70774aaa482b92dc2e5314b5c d562da103406d82c4e5700336bbb136672c0b595

View File

@ -1 +1 @@
0877f763271af8603501edfa1e24eaf3e318198e 8e12b0c40d4b90a82ade721f380a924720127548

View File

@ -1 +1 @@
09995e4e66ac0a22fe41587750417656bfce0821 1f42617e7b8e00a04125fc85967729855b0bbd3c

View File

@ -1 +1 @@
5e3eda678d1f01b2aa295f260a86a9621a1396b3 fda09093e5973afedf30878b4b04bcdb9ce7302f

View File

@ -1 +1 @@
c218c037bb6d75c7b3868cc3ce7ef93c29ef1b3d 0d4c53cdf0f5e83e2808231a255da37be341cbca

View File

@ -1 +1 @@
4eaf1e484ad4d32e688d1fd92002bc14e8d9b408 6cd85b1ade15d3d15c5d45f15729344bfc58f191

View File

@ -1 +1 @@
8d8905f64181bf039084412317cab6664dd1577f 9aca22f64e9b0800a2247930d7d53ddb4570059f

View File

@ -1 +1 @@
befc828e193756128a4b0755432ce5d10d2cc1e4 b81e5105b4a226b866e9d4b525c04d6024ed558b

View File

@ -1 +1 @@
5c0ce009774f46b70774aaa482b92dc2e5314b5c d562da103406d82c4e5700336bbb136672c0b595

View File

@ -1 +1 @@
0877f763271af8603501edfa1e24eaf3e318198e 8e12b0c40d4b90a82ade721f380a924720127548

View File

@ -1 +1 @@
09995e4e66ac0a22fe41587750417656bfce0821 1f42617e7b8e00a04125fc85967729855b0bbd3c

View File

@ -1 +1 @@
5e3eda678d1f01b2aa295f260a86a9621a1396b3 fda09093e5973afedf30878b4b04bcdb9ce7302f

View File

@ -1 +1 @@
c218c037bb6d75c7b3868cc3ce7ef93c29ef1b3d 0d4c53cdf0f5e83e2808231a255da37be341cbca

Some files were not shown because too many files have changed in this diff Show More