@@ -32,7 +32,6 @@ extension AsyncRequestBag {
3232 case queued( UnsafeContinuation < AsyncResponse , Error > , HTTPRequestScheduler )
3333 case executing( ExecutionContext , RequestStreamState , ResponseStreamState )
3434 case finished( error: Error ? , AsyncResponse . Body . IteratorStream . ID ? )
35- case modifying
3635 }
3736
3837 fileprivate enum RequestStreamState {
@@ -159,9 +158,6 @@ extension AsyncRequestBag {
159158 case . finished( error: _, _) :
160159 return . none
161160
162- case . modifying:
163- preconditionFailure ( " Invalid state " )
164-
165161 case . executing( let context, _, . finished( let streamID, let continuation) ) :
166162 self . state = . finished( error: error, streamID)
167163 return . failResponseStream( continuation, error, context. executor)
@@ -185,8 +181,7 @@ extension AsyncRequestBag {
185181 case . initialized,
186182 . executing,
187183 . finished( error: . none, _) ,
188- . finished( error: . some, . some) ,
189- . modifying:
184+ . finished( error: . some, . some) :
190185 preconditionFailure ( " Invalid state: \( self . state) " )
191186 }
192187 }
@@ -225,9 +220,6 @@ extension AsyncRequestBag {
225220
226221 case . finished:
227222 return . none
228-
229- case . modifying:
230- preconditionFailure ( " Invalid state " )
231223 }
232224 }
233225
@@ -248,9 +240,6 @@ extension AsyncRequestBag {
248240 // the channels writability changed to writable after we have forwarded all the
249241 // request bytes. Can be ignored.
250242 break
251-
252- case . modifying:
253- preconditionFailure ( " Invalid state " )
254243 }
255244 }
256245
@@ -276,9 +265,6 @@ extension AsyncRequestBag {
276265
277266 case . finished:
278267 return . ignore
279-
280- case . modifying:
281- preconditionFailure ( " Invalid state " )
282268 }
283269 }
284270
@@ -317,9 +303,6 @@ extension AsyncRequestBag {
317303
318304 case . finished:
319305 return . none
320-
321- case . modifying:
322- preconditionFailure ( " Invalid state " )
323306 }
324307 }
325308
@@ -344,9 +327,6 @@ extension AsyncRequestBag {
344327
345328 case . finished:
346329 return . none
347-
348- case . modifying:
349- preconditionFailure ( " Invalid state " )
350330 }
351331 }
352332
@@ -377,9 +357,6 @@ extension AsyncRequestBag {
377357 case . executing( _, _, . finished) ,
378358 . finished( error: . none, _) :
379359 preconditionFailure ( " How can the request be finished without error, before receiving response head? " )
380-
381- case . modifying:
382- preconditionFailure ( " Invalid state " )
383360 }
384361 }
385362
@@ -400,7 +377,6 @@ extension AsyncRequestBag {
400377 preconditionFailure ( " If we have received an error or eof before, why did we get another body part? Next: \( next) " )
401378 }
402379
403- self . state = . modifying
404380 if currentBuffer. isEmpty {
405381 currentBuffer = buffer
406382 } else {
@@ -414,7 +390,6 @@ extension AsyncRequestBag {
414390 preconditionFailure ( " If we have received an error or eof before, why did we get another body part? Next: \( next) " )
415391 }
416392
417- self . state = . modifying
418393 if currentBuffer. isEmpty {
419394 currentBuffer = buffer
420395 } else {
@@ -434,8 +409,6 @@ extension AsyncRequestBag {
434409 case . executing( _, _, . finished) ,
435410 . finished( error: . none, _) :
436411 preconditionFailure ( " How can the request be finished without error, before receiving response head? " )
437- case . modifying:
438- preconditionFailure ( " Invalid state " )
439412 }
440413 }
441414
@@ -466,7 +439,6 @@ extension AsyncRequestBag {
466439 self . state = . executing( context, requestState, . waitingForRemote( streamID, continuation) )
467440 return . askExecutorForMore( context. executor)
468441 } else {
469- self . state = . modifying
470442 let toReturn = buffer. removeFirst ( )
471443 self . state = . executing( context, requestState, . buffering( streamID, buffer, next: . askExecutorForMore) )
472444 return . succeedContinuation( continuation, toReturn)
@@ -482,7 +454,6 @@ extension AsyncRequestBag {
482454
483455 case . executing( let context, let requestState, . waitingForStream( var buffer, next: . eof) ) :
484456 assert ( !buffer. isEmpty)
485- self . state = . modifying
486457 let toReturn = buffer. removeFirst ( )
487458 self . state = . executing( context, requestState, . buffering( streamID, buffer, next: . eof) )
488459 return . succeedContinuation( continuation, toReturn)
@@ -492,7 +463,6 @@ extension AsyncRequestBag {
492463 self . state = . executing( context, requestState, . waitingForRemote( streamID, continuation) )
493464 return . askExecutorForMore( context. executor)
494465 } else {
495- self . state = . modifying
496466 let toReturn = buffer. removeFirst ( )
497467 self . state = . executing( context, requestState, . buffering( streamID, buffer, next: . askExecutorForMore) )
498468 return . succeedContinuation( continuation, toReturn)
@@ -514,7 +484,6 @@ extension AsyncRequestBag {
514484
515485 case . executing( let context, let requestState, . buffering( let streamID, var buffer, next: . eof) ) :
516486 assert ( !buffer. isEmpty)
517- self . state = . modifying
518487 let toReturn = buffer. removeFirst ( )
519488 self . state = . executing( context, requestState, . buffering( streamID, buffer, next: . eof) )
520489 return . succeedContinuation( continuation, toReturn)
@@ -535,8 +504,6 @@ extension AsyncRequestBag {
535504 return . failContinuation( continuation, TriedToRegisteredASecondConsumer ( ) )
536505 }
537506 return . succeedContinuation( continuation, nil )
538- case . modifying:
539- preconditionFailure ( " Invalid state " )
540507 }
541508 }
542509
@@ -556,15 +523,13 @@ extension AsyncRequestBag {
556523
557524 case . executing( let context, let requestState, . waitingForStream( var buffer, next: . askExecutorForMore) ) :
558525 if let newChunks = newChunks, !newChunks. isEmpty {
559- self . state = . modifying
560526 buffer. append ( contentsOf: newChunks)
561527 }
562528 self . state = . executing( context, requestState, . waitingForStream( buffer, next: . eof) )
563529 return . none
564530
565531 case . executing( let context, let requestState, . waitingForRemote( let streamID, let continuation) ) :
566532 if var newChunks = newChunks, !newChunks. isEmpty {
567- self . state = . modifying
568533 let first = newChunks. removeFirst ( )
569534 self . state = . executing( context, requestState, . buffering( streamID, newChunks, next: . eof) )
570535 return . succeedContinuation( continuation, first)
@@ -575,7 +540,6 @@ extension AsyncRequestBag {
575540
576541 case . executing( let context, let requestState, . buffering( let streamID, var buffer, next: . askExecutorForMore) ) :
577542 if let newChunks = newChunks, !newChunks. isEmpty {
578- self . state = . modifying
579543 buffer. append ( contentsOf: newChunks)
580544 }
581545 self . state = . executing( context, requestState, . buffering( streamID, buffer, next: . eof) )
@@ -586,8 +550,6 @@ extension AsyncRequestBag {
586550
587551 case . finished( error: . none, _) :
588552 preconditionFailure ( " How can the request be finished without error, before receiving response head? " )
589- case . modifying:
590- preconditionFailure ( " Invalid state " )
591553
592554 case . executing( _, _, . waitingForStream( _, next: . error) ) ,
593555 . executing( _, _, . waitingForStream( _, next: . eof) ) ,
0 commit comments