You've already forked linux-packaging-mono
Imported Upstream version 6.0.0.300
Former-commit-id: 5d008a9f41819eeae8c2feef3b41fc6cbf03e9fb
This commit is contained in:
parent
a63e3f0156
commit
860af8198e
@@ -188,6 +188,12 @@ namespace System.Net.Http
|
||||
|
||||
public IDictionary<string, object> Properties => _delegatingHandler.Properties;
|
||||
|
||||
// Only used in MonoWebRequestHandler and ignored by the other handlers.
|
||||
internal void SetWebRequestTimeout (TimeSpan timeout)
|
||||
{
|
||||
_delegatingHandler.SetWebRequestTimeout (timeout);
|
||||
}
|
||||
|
||||
protected internal override Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken) =>
|
||||
_delegatingHandler.SendAsync (request, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -78,5 +78,8 @@ namespace System.Net.Http
|
||||
}
|
||||
|
||||
Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken);
|
||||
|
||||
// Only used by MonoWebRequestHandler and ignored by the other handlers.
|
||||
void SetWebRequestTimeout (TimeSpan timeout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace System.Net.Http
|
||||
bool unsafeAuthenticatedConnectionSharing;
|
||||
bool sentRequest;
|
||||
string connectionGroupName;
|
||||
TimeSpan? timeout;
|
||||
bool disposed;
|
||||
|
||||
internal MonoWebRequestHandler ()
|
||||
@@ -368,6 +369,9 @@ namespace System.Net.Http
|
||||
|
||||
wr.ServicePoint.Expect100Continue = request.Headers.ExpectContinue == true;
|
||||
|
||||
if (timeout != null)
|
||||
wr.Timeout = (int)timeout.Value.TotalMilliseconds;
|
||||
|
||||
// Add request headers
|
||||
var headers = wr.Headers;
|
||||
foreach (var header in request.Headers) {
|
||||
@@ -533,5 +537,10 @@ namespace System.Net.Http
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
void IMonoHttpClientHandler.SetWebRequestTimeout (TimeSpan timeout)
|
||||
{
|
||||
this.timeout = timeout;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,6 +269,9 @@ namespace System.Net.Http
|
||||
async Task<HttpResponseMessage> SendAsyncWorker (HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
|
||||
{
|
||||
using (var lcts = CancellationTokenSource.CreateLinkedTokenSource (cts.Token, cancellationToken)) {
|
||||
// Hack to pass the timeout to the HttpWebRequest that's created by MonoWebRequestHandler; all other handlers ignore this.
|
||||
if (handler is HttpClientHandler clientHandler)
|
||||
clientHandler.SetWebRequestTimeout (timeout);
|
||||
lcts.CancelAfter (timeout);
|
||||
|
||||
var task = base.SendAsync (request, lcts.Token);
|
||||
|
||||
@@ -169,5 +169,8 @@ namespace System.Net.Http
|
||||
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
}
|
||||
|
||||
// Only used in MonoWebRequestHandler and ignored by the other handlers.
|
||||
internal void SetWebRequestTimeout (TimeSpan timeout) => throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace System.Net.Http
|
||||
{
|
||||
public class HttpMessageInvoker : IDisposable
|
||||
{
|
||||
HttpMessageHandler handler;
|
||||
protected private HttpMessageHandler handler;
|
||||
readonly bool disposeHandler;
|
||||
|
||||
public HttpMessageInvoker (HttpMessageHandler handler)
|
||||
|
||||
@@ -40,6 +40,11 @@ namespace System.Net.Http
|
||||
}
|
||||
}
|
||||
|
||||
// This is only used by MonoWebRequestHandler.
|
||||
void IMonoHttpClientHandler.SetWebRequestTimeout (TimeSpan timeout)
|
||||
{
|
||||
}
|
||||
|
||||
Task<HttpResponseMessage> IMonoHttpClientHandler.SendAsync (HttpRequestMessage request, CancellationToken cancellationToken) => SendAsync (request, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user