@@ -42,7 +42,7 @@ struct HTTPRequestStateMachine {
42
42
fileprivate enum RequestState {
43
43
/// A sub state for sending a request body. Stores whether a producer should produce more
44
44
/// bytes or should pause.
45
- enum ProducerControlState : Equatable {
45
+ enum ProducerControlState : String {
46
46
/// The request body producer should produce more body bytes. The channel is writable.
47
47
case producing
48
48
/// The request body producer should pause producing more bytes. The channel is not writable.
@@ -200,7 +200,9 @@ struct HTTPRequestStateMachine {
200
200
// more data...
201
201
return . read
202
202
case . running( _, . receivingBody( _, . downstreamIsConsuming( readPending: true ) ) ) :
203
- preconditionFailure ( " It should not be possible to receive two reads after each other, if the first one hasn't been forwarded. " )
203
+ // We have caught another `read` event already. We don't need to change the state and
204
+ // we should continue to wait for the consumer to call `forwardMoreBodyParts`
205
+ return . wait
204
206
case . running( let requestState, . receivingBody( let responseHead, . downstreamIsConsuming( readPending: false ) ) ) :
205
207
self . state = . running( requestState, . receivingBody( responseHead, . downstreamIsConsuming( readPending: true ) ) )
206
208
return . wait
@@ -561,17 +563,6 @@ extension HTTPRequestStateMachine.RequestState: CustomStringConvertible {
561
563
}
562
564
}
563
565
564
- extension HTTPRequestStateMachine . RequestState . ProducerControlState : CustomStringConvertible {
565
- var description : String {
566
- switch self {
567
- case . paused:
568
- return " .paused "
569
- case . producing:
570
- return " .producing "
571
- }
572
- }
573
- }
574
-
575
566
extension HTTPRequestStateMachine . ResponseState : CustomStringConvertible {
576
567
var description : String {
577
568
switch self {
0 commit comments