Skip to content

Commit a8dad44

Browse files
committed
RequestHandler: fix cancellation
1 parent 60d444c commit a8dad44

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Client/Infrastructure/RequestHandler.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Buffers.Text;
32
using System.Collections.Generic;
43
using System.Net;
54
using System.Net.Http;
@@ -127,7 +126,9 @@ public async IAsyncEnumerable<object> GetEvents(
127126
var responseStream = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false);
128127
await using var responseStreamScope = responseStream.ConfigureAwait(false);
129128

130-
await foreach (var lineData in _readerFactory.CreateReader(responseStream).ConfigureAwait(false))
129+
await foreach (var lineData in _readerFactory.CreateReader(responseStream)
130+
.WithCancellation(cancellationToken)
131+
.ConfigureAwait(false))
131132
{
132133
// Note: this does not support multi-line events, see spec:
133134
// https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation

0 commit comments

Comments
 (0)