@@ -42,7 +42,7 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler {
42
42
if let idleReadTimeout = newRequest. requestOptions. idleReadTimeout {
43
43
self . idleReadTimeoutStateMachine = . init( timeAmount: idleReadTimeout)
44
44
}
45
-
45
+
46
46
if let idleWriteTimeout = newRequest. requestOptions. idleWriteTimeout {
47
47
self . idleWriteTimeoutStateMachine = . init(
48
48
timeAmount: idleWriteTimeout,
@@ -64,7 +64,7 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler {
64
64
/// We therefore give each timer an ID and increase the ID every time we reset or cancel it.
65
65
/// We check in the task if the timer ID has changed in the meantime and do not execute any action if has changed.
66
66
private var currentIdleReadTimeoutTimerID : Int = 0
67
-
67
+
68
68
private var idleWriteTimeoutStateMachine : IdleWriteStateMachine ?
69
69
private var idleWriteTimeoutTimer : Scheduled < Void > ?
70
70
@@ -121,7 +121,7 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler {
121
121
self . logger. trace ( " Channel writability changed " , metadata: [
122
122
" ahc-channel-writable " : " \( context. channel. isWritable) " ,
123
123
] )
124
-
124
+
125
125
if let timeoutAction = self . idleWriteTimeoutStateMachine? . channelWritabilityChanged ( context: context) {
126
126
self . runTimeoutAction ( timeoutAction, context: context)
127
127
}
@@ -170,11 +170,11 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler {
170
170
self . request = req
171
171
172
172
self . logger. debug ( " Request was scheduled on connection " )
173
-
173
+
174
174
if let timeoutAction = self . idleWriteTimeoutStateMachine? . write ( ) {
175
175
self . runTimeoutAction ( timeoutAction, context: context)
176
176
}
177
-
177
+
178
178
req. willExecuteRequest ( self )
179
179
180
180
let action = self . state. runNewRequest (
@@ -224,7 +224,7 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler {
224
224
if let readTimeoutAction = self . idleReadTimeoutStateMachine? . requestEndSent ( ) {
225
225
self . runTimeoutAction ( readTimeoutAction, context: context)
226
226
}
227
-
227
+
228
228
if let writeTimeoutAction = self . idleWriteTimeoutStateMachine? . requestEndSent ( ) {
229
229
self . runTimeoutAction ( writeTimeoutAction, context: context)
230
230
}
@@ -238,7 +238,7 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler {
238
238
if let readTimeoutAction = self . idleReadTimeoutStateMachine? . requestEndSent ( ) {
239
239
self . runTimeoutAction ( readTimeoutAction, context: context)
240
240
}
241
-
241
+
242
242
if let writeTimeoutAction = self . idleWriteTimeoutStateMachine? . requestEndSent ( ) {
243
243
self . runTimeoutAction ( writeTimeoutAction, context: context)
244
244
}
@@ -412,7 +412,7 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler {
412
412
break
413
413
}
414
414
}
415
-
415
+
416
416
private func runTimeoutAction( _ action: IdleWriteStateMachine . Action , context: ChannelHandlerContext ) {
417
417
switch action {
418
418
case . startIdleWriteTimeoutTimer( let timeAmount) :
@@ -459,7 +459,7 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler {
459
459
promise? . fail ( HTTPClientError . requestStreamCancelled)
460
460
return
461
461
}
462
-
462
+
463
463
if let timeoutAction = self . idleWriteTimeoutStateMachine? . write ( ) {
464
464
self . runTimeoutAction ( timeoutAction, context: context)
465
465
}
@@ -498,7 +498,7 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler {
498
498
}
499
499
500
500
self . logger. trace ( " Request was cancelled " )
501
-
501
+
502
502
if let timeoutAction = self . idleWriteTimeoutStateMachine? . cancelRequest ( ) {
503
503
self . runTimeoutAction ( timeoutAction, context: context)
504
504
}
@@ -641,7 +641,7 @@ struct IdleWriteStateMachine {
641
641
self . state = . waitingForWritabilityEnabled
642
642
}
643
643
}
644
-
644
+
645
645
mutating func cancelRequest( ) -> Action {
646
646
switch self . state {
647
647
case . waitingForRequestEnd, . waitingForWritabilityEnabled:
@@ -662,7 +662,7 @@ struct IdleWriteStateMachine {
662
662
preconditionFailure ( " If the request end has been sent, we can't write more data. " )
663
663
}
664
664
}
665
-
665
+
666
666
mutating func requestEndSent( ) -> Action {
667
667
switch self . state {
668
668
case . waitingForRequestEnd:
@@ -674,7 +674,7 @@ struct IdleWriteStateMachine {
674
674
return . none
675
675
}
676
676
}
677
-
677
+
678
678
mutating func channelWritabilityChanged( context: ChannelHandlerContext ) -> Action {
679
679
if context. channel. isWritable {
680
680
switch self . state {
0 commit comments