Merge pull request #396 from sacgod/dev
Fix missing dispose of CTS during Request timeout handling
This commit is contained in:
commit
1b072fce15
@ -117,11 +117,12 @@ namespace Flurl.Http
|
||||
request.RequestUri = Url.ToUri(); // in case it was modifed in the handler above
|
||||
|
||||
var cancellationTokenWithTimeout = cancellationToken;
|
||||
CancellationTokenSource timeoutTokenSource = null;
|
||||
|
||||
if (Settings.Timeout.HasValue) {
|
||||
var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
|
||||
cts.CancelAfter(Settings.Timeout.Value);
|
||||
cancellationTokenWithTimeout = cts.Token;
|
||||
timeoutTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
|
||||
timeoutTokenSource.CancelAfter(Settings.Timeout.Value);
|
||||
cancellationTokenWithTimeout = timeoutTokenSource.Token;
|
||||
}
|
||||
|
||||
call.StartedUtc = DateTime.UtcNow;
|
||||
@ -146,6 +147,8 @@ namespace Flurl.Http
|
||||
}
|
||||
finally {
|
||||
request.Dispose();
|
||||
timeoutTokenSource?.Dispose();
|
||||
|
||||
if (Settings.CookiesEnabled)
|
||||
ReadResponseCookies(call.Response);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user