@@ -142,11 +142,7 @@ private async Task ExecuteAsync(HttpContext context, ConnectionDelegate connecti
142
142
connection . SupportedFormats = TransferFormat . Text ;
143
143
144
144
// We only need to provide the Input channel since writing to the application is handled through /send.
145
- < << << << HEAD
146
145
var sse = new ServerSentEventsServerTransport ( connection . Application . Input , connection . ConnectionId , connection , _loggerFactory ) ;
147
- = == == ==
148
- var sse = new ServerSentEventsTransport ( connection . Application . Input , connection . ConnectionId , connection , _loggerFactory ) ;
149
- > >>> >>> release / 2.1
150
146
151
147
await DoPersistentConnection ( connectionDelegate , sse , context , connection ) ;
152
148
}
@@ -195,83 +191,9 @@ private async Task ExecuteAsync(HttpContext context, ConnectionDelegate connecti
195
191
196
192
if ( ! await connection . CancelPreviousPoll ( context ) )
197
193
{
198
- < << << << HEAD
199
194
// Connection closed. It's already set the response status code.
200
195
return ;
201
196
}
202
- = == == ==
203
- if ( connection . Status == HttpConnectionStatus . Disposed )
204
- {
205
- Log . ConnectionDisposed ( _logger , connection . ConnectionId ) ;
206
-
207
- // The connection was disposed
208
- context . Response . StatusCode = StatusCodes . Status404NotFound ;
209
- context . Response . ContentType = "text/plain" ;
210
- return ;
211
- }
212
-
213
- if ( connection . Status == HttpConnectionStatus . Active )
214
- {
215
- var existing = connection . GetHttpContext ( ) ;
216
- Log . ConnectionAlreadyActive ( _logger , connection . ConnectionId , existing . TraceIdentifier ) ;
217
- }
218
-
219
- using ( connection . Cancellation )
220
- {
221
- // Cancel the previous request
222
- connection . Cancellation ? . Cancel ( ) ;
223
-
224
- try
225
- {
226
- // Wait for the previous request to drain
227
- await connection . PreviousPollTask ;
228
- }
229
- catch ( OperationCanceledException )
230
- {
231
- // Previous poll canceled due to connection closing, close this poll too
232
- context . Response . ContentType = "text/plain" ;
233
- context . Response . StatusCode = StatusCodes . Status204NoContent ;
234
- return ;
235
- }
236
-
237
- connection . PreviousPollTask = currentRequestTcs . Task ;
238
- }
239
-
240
- // Mark the connection as active
241
- connection . Status = HttpConnectionStatus . Active ;
242
-
243
- // Raise OnConnected for new connections only since polls happen all the time
244
- if ( connection . ApplicationTask == null )
245
- {
246
- Log . EstablishedConnection ( _logger ) ;
247
-
248
- connection . ApplicationTask = ExecuteApplication ( connectionDelegate , connection ) ;
249
-
250
- context . Response . ContentType = "application/octet-stream" ;
251
-
252
- // This request has no content
253
- context . Response . ContentLength = 0 ;
254
-
255
- // On the first poll, we flush the response immediately to mark the poll as "initialized" so future
256
- // requests can be made safely
257
- connection . TransportTask = context . Response . Body . FlushAsync ( ) ;
258
- }
259
- else
260
- {
261
- Log . ResumingConnection ( _logger ) ;
262
-
263
- // REVIEW: Performance of this isn't great as this does a bunch of per request allocations
264
- connection . Cancellation = new CancellationTokenSource ( ) ;
265
-
266
- var timeoutSource = new CancellationTokenSource ( ) ;
267
- var tokenSource = CancellationTokenSource . CreateLinkedTokenSource ( connection . Cancellation . Token , context . RequestAborted , timeoutSource . Token ) ;
268
-
269
- // Dispose these tokens when the request is over
270
- context . Response . RegisterForDispose ( timeoutSource ) ;
271
- context . Response . RegisterForDispose ( tokenSource ) ;
272
-
273
- var longPolling = new LongPollingTransport ( timeoutSource . Token , connection . Application . Input , _loggerFactory , connection ) ;
274
- > >>> >>> release / 2.1
275
197
276
198
// Create a new Tcs every poll to keep track of the poll finishing, so we can properly wait on previous polls
277
199
var currentRequestTcs = new TaskCompletionSource < object > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
@@ -314,23 +236,7 @@ private async Task ExecuteAsync(HttpContext context, ConnectionDelegate connecti
314
236
connection . MarkInactive ( ) ;
315
237
}
316
238
}
317
- < << << << HEAD
318
239
else if ( resultTask . IsFaulted || resultTask . IsCanceled )
319
- = == == ==
320
- else if ( connection . TransportTask . IsFaulted || connection . TransportTask . IsCanceled )
321
- {
322
- // Cancel current request to release any waiting poll and let dispose aquire the lock
323
- currentRequestTcs . TrySetCanceled ( ) ;
324
-
325
- // We should be able to safely dispose because there's no more data being written
326
- // We don't need to wait for close here since we've already waited for both sides
327
- await _manager . DisposeAndRemoveAsync ( connection , closeGracefully : false ) ;
328
-
329
- // Don't poll again if we've removed the connection completely
330
- pollAgain = false ;
331
- }
332
- else if ( context . Response . StatusCode == StatusCodes . Status204NoContent )
333
- > >>> >>> release / 2.1
334
240
{
335
241
// Cancel current request to release any waiting poll and let dispose acquire the lock
336
242
currentRequestTcs . TrySetCanceled ( ) ;
@@ -538,7 +444,6 @@ private async Task ProcessSend(HttpContext context, HttpConnectionDispatcherOpti
538
444
// Other code isn't guaranteed to be able to acquire the lock before another write
539
445
// even if CancelPendingFlush is called, and the other write could hang if there is backpressure
540
446
connection . Application . Output . Complete ( ) ;
541
- < << << << HEAD
542
447
return ;
543
448
}
544
449
catch ( IOException ex )
@@ -548,8 +453,6 @@ private async Task ProcessSend(HttpContext context, HttpConnectionDispatcherOpti
548
453
549
454
context . Response . StatusCode = StatusCodes . Status400BadRequest ;
550
455
context . Response . ContentType = "text/plain" ;
551
- = == == ==
552
- >>> > >>> release / 2.1
553
456
return ;
554
457
}
555
458
0 commit comments