@@ -32,7 +32,6 @@ extension AsyncRequestBag {
32
32
case queued( UnsafeContinuation < AsyncResponse , Error > , HTTPRequestScheduler )
33
33
case executing( ExecutionContext , RequestStreamState , ResponseStreamState )
34
34
case finished( error: Error ? , AsyncResponse . Body . IteratorStream . ID ? )
35
- case modifying
36
35
}
37
36
38
37
fileprivate enum RequestStreamState {
@@ -159,9 +158,6 @@ extension AsyncRequestBag {
159
158
case . finished( error: _, _) :
160
159
return . none
161
160
162
- case . modifying:
163
- preconditionFailure ( " Invalid state " )
164
-
165
161
case . executing( let context, _, . finished( let streamID, let continuation) ) :
166
162
self . state = . finished( error: error, streamID)
167
163
return . failResponseStream( continuation, error, context. executor)
@@ -185,8 +181,7 @@ extension AsyncRequestBag {
185
181
case . initialized,
186
182
. executing,
187
183
. finished( error: . none, _) ,
188
- . finished( error: . some, . some) ,
189
- . modifying:
184
+ . finished( error: . some, . some) :
190
185
preconditionFailure ( " Invalid state: \( self . state) " )
191
186
}
192
187
}
@@ -225,9 +220,6 @@ extension AsyncRequestBag {
225
220
226
221
case . finished:
227
222
return . none
228
-
229
- case . modifying:
230
- preconditionFailure ( " Invalid state " )
231
223
}
232
224
}
233
225
@@ -248,9 +240,6 @@ extension AsyncRequestBag {
248
240
// the channels writability changed to writable after we have forwarded all the
249
241
// request bytes. Can be ignored.
250
242
break
251
-
252
- case . modifying:
253
- preconditionFailure ( " Invalid state " )
254
243
}
255
244
}
256
245
@@ -276,9 +265,6 @@ extension AsyncRequestBag {
276
265
277
266
case . finished:
278
267
return . ignore
279
-
280
- case . modifying:
281
- preconditionFailure ( " Invalid state " )
282
268
}
283
269
}
284
270
@@ -317,9 +303,6 @@ extension AsyncRequestBag {
317
303
318
304
case . finished:
319
305
return . none
320
-
321
- case . modifying:
322
- preconditionFailure ( " Invalid state " )
323
306
}
324
307
}
325
308
@@ -344,9 +327,6 @@ extension AsyncRequestBag {
344
327
345
328
case . finished:
346
329
return . none
347
-
348
- case . modifying:
349
- preconditionFailure ( " Invalid state " )
350
330
}
351
331
}
352
332
@@ -377,9 +357,6 @@ extension AsyncRequestBag {
377
357
case . executing( _, _, . finished) ,
378
358
. finished( error: . none, _) :
379
359
preconditionFailure ( " How can the request be finished without error, before receiving response head? " )
380
-
381
- case . modifying:
382
- preconditionFailure ( " Invalid state " )
383
360
}
384
361
}
385
362
@@ -400,7 +377,6 @@ extension AsyncRequestBag {
400
377
preconditionFailure ( " If we have received an error or eof before, why did we get another body part? Next: \( next) " )
401
378
}
402
379
403
- self . state = . modifying
404
380
if currentBuffer. isEmpty {
405
381
currentBuffer = buffer
406
382
} else {
@@ -414,7 +390,6 @@ extension AsyncRequestBag {
414
390
preconditionFailure ( " If we have received an error or eof before, why did we get another body part? Next: \( next) " )
415
391
}
416
392
417
- self . state = . modifying
418
393
if currentBuffer. isEmpty {
419
394
currentBuffer = buffer
420
395
} else {
@@ -434,8 +409,6 @@ extension AsyncRequestBag {
434
409
case . executing( _, _, . finished) ,
435
410
. finished( error: . none, _) :
436
411
preconditionFailure ( " How can the request be finished without error, before receiving response head? " )
437
- case . modifying:
438
- preconditionFailure ( " Invalid state " )
439
412
}
440
413
}
441
414
@@ -466,7 +439,6 @@ extension AsyncRequestBag {
466
439
self . state = . executing( context, requestState, . waitingForRemote( streamID, continuation) )
467
440
return . askExecutorForMore( context. executor)
468
441
} else {
469
- self . state = . modifying
470
442
let toReturn = buffer. removeFirst ( )
471
443
self . state = . executing( context, requestState, . buffering( streamID, buffer, next: . askExecutorForMore) )
472
444
return . succeedContinuation( continuation, toReturn)
@@ -482,7 +454,6 @@ extension AsyncRequestBag {
482
454
483
455
case . executing( let context, let requestState, . waitingForStream( var buffer, next: . eof) ) :
484
456
assert ( !buffer. isEmpty)
485
- self . state = . modifying
486
457
let toReturn = buffer. removeFirst ( )
487
458
self . state = . executing( context, requestState, . buffering( streamID, buffer, next: . eof) )
488
459
return . succeedContinuation( continuation, toReturn)
@@ -492,7 +463,6 @@ extension AsyncRequestBag {
492
463
self . state = . executing( context, requestState, . waitingForRemote( streamID, continuation) )
493
464
return . askExecutorForMore( context. executor)
494
465
} else {
495
- self . state = . modifying
496
466
let toReturn = buffer. removeFirst ( )
497
467
self . state = . executing( context, requestState, . buffering( streamID, buffer, next: . askExecutorForMore) )
498
468
return . succeedContinuation( continuation, toReturn)
@@ -514,7 +484,6 @@ extension AsyncRequestBag {
514
484
515
485
case . executing( let context, let requestState, . buffering( let streamID, var buffer, next: . eof) ) :
516
486
assert ( !buffer. isEmpty)
517
- self . state = . modifying
518
487
let toReturn = buffer. removeFirst ( )
519
488
self . state = . executing( context, requestState, . buffering( streamID, buffer, next: . eof) )
520
489
return . succeedContinuation( continuation, toReturn)
@@ -535,8 +504,6 @@ extension AsyncRequestBag {
535
504
return . failContinuation( continuation, TriedToRegisteredASecondConsumer ( ) )
536
505
}
537
506
return . succeedContinuation( continuation, nil )
538
- case . modifying:
539
- preconditionFailure ( " Invalid state " )
540
507
}
541
508
}
542
509
@@ -556,15 +523,13 @@ extension AsyncRequestBag {
556
523
557
524
case . executing( let context, let requestState, . waitingForStream( var buffer, next: . askExecutorForMore) ) :
558
525
if let newChunks = newChunks, !newChunks. isEmpty {
559
- self . state = . modifying
560
526
buffer. append ( contentsOf: newChunks)
561
527
}
562
528
self . state = . executing( context, requestState, . waitingForStream( buffer, next: . eof) )
563
529
return . none
564
530
565
531
case . executing( let context, let requestState, . waitingForRemote( let streamID, let continuation) ) :
566
532
if var newChunks = newChunks, !newChunks. isEmpty {
567
- self . state = . modifying
568
533
let first = newChunks. removeFirst ( )
569
534
self . state = . executing( context, requestState, . buffering( streamID, newChunks, next: . eof) )
570
535
return . succeedContinuation( continuation, first)
@@ -575,7 +540,6 @@ extension AsyncRequestBag {
575
540
576
541
case . executing( let context, let requestState, . buffering( let streamID, var buffer, next: . askExecutorForMore) ) :
577
542
if let newChunks = newChunks, !newChunks. isEmpty {
578
- self . state = . modifying
579
543
buffer. append ( contentsOf: newChunks)
580
544
}
581
545
self . state = . executing( context, requestState, . buffering( streamID, buffer, next: . eof) )
@@ -586,8 +550,6 @@ extension AsyncRequestBag {
586
550
587
551
case . finished( error: . none, _) :
588
552
preconditionFailure ( " How can the request be finished without error, before receiving response head? " )
589
- case . modifying:
590
- preconditionFailure ( " Invalid state " )
591
553
592
554
case . executing( _, _, . waitingForStream( _, next: . error) ) ,
593
555
. executing( _, _, . waitingForStream( _, next: . eof) ) ,
0 commit comments