Skip to content

Commit 650d14b

Browse files
committed
Code review
1 parent 3eff1de commit 650d14b

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

Sources/AsyncHTTPClient/ConnectionPool/HTTPRequestStateMachine.swift

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct HTTPRequestStateMachine {
4242
fileprivate enum RequestState {
4343
/// A sub state for sending a request body. Stores whether a producer should produce more
4444
/// bytes or should pause.
45-
enum ProducerControlState: Equatable {
45+
enum ProducerControlState: String {
4646
/// The request body producer should produce more body bytes. The channel is writable.
4747
case producing
4848
/// The request body producer should pause producing more bytes. The channel is not writable.
@@ -200,7 +200,9 @@ struct HTTPRequestStateMachine {
200200
// more data...
201201
return .read
202202
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
204206
case .running(let requestState, .receivingBody(let responseHead, .downstreamIsConsuming(readPending: false))):
205207
self.state = .running(requestState, .receivingBody(responseHead, .downstreamIsConsuming(readPending: true)))
206208
return .wait
@@ -561,17 +563,6 @@ extension HTTPRequestStateMachine.RequestState: CustomStringConvertible {
561563
}
562564
}
563565

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-
575566
extension HTTPRequestStateMachine.ResponseState: CustomStringConvertible {
576567
var description: String {
577568
switch self {

0 commit comments

Comments
 (0)