@@ -38,7 +38,7 @@ final class HTTPBodyOutputStreamBridge: NSObject, StreamDelegate {
38
38
39
39
deinit {
40
40
debug ( " Output stream delegate deinit " )
41
- self . outputStream. delegate = nil
41
+ outputStream. delegate = nil
42
42
}
43
43
44
44
func performAction( _ action: State . Action ) {
@@ -48,7 +48,7 @@ final class HTTPBodyOutputStreamBridge: NSObject, StreamDelegate {
48
48
case . none: return
49
49
case . resumeProducer( let producerContinuation) :
50
50
producerContinuation. resume ( )
51
- performAction ( self . state. resumedProducer ( ) )
51
+ performAction ( state. resumedProducer ( ) )
52
52
case . writeBytes( let chunk) : writePendingBytes ( chunk)
53
53
case . cancelProducerAndCloseStream( let producerContinuation) :
54
54
producerContinuation. resume ( throwing: CancellationError ( ) )
@@ -75,31 +75,28 @@ final class HTTPBodyOutputStreamBridge: NSObject, StreamDelegate {
75
75
self . performAction ( self . state. wroteFinalChunk ( ) )
76
76
}
77
77
}
78
- self . performAction ( self . state. startedProducerTask ( task) )
78
+ performAction ( state. startedProducerTask ( task) )
79
79
}
80
80
81
81
private func writePendingBytes( _ bytesToWrite: Chunk ) {
82
82
dispatchPrecondition ( condition: . onQueue( Self . streamQueue) )
83
83
precondition ( !bytesToWrite. isEmpty, " \( #function) must be called with non-empty bytes " )
84
84
guard outputStream. streamStatus == . open else {
85
85
debug ( " Output stream closed unexpectedly. " )
86
- performAction ( self . state. wroteBytes ( numBytesWritten: 0 , streamStillHasSpaceAvailable: false ) )
86
+ performAction ( state. wroteBytes ( numBytesWritten: 0 , streamStillHasSpaceAvailable: false ) )
87
87
return
88
88
}
89
89
switch bytesToWrite. withUnsafeBytes ( { outputStream. write ( $0. baseAddress!, maxLength: bytesToWrite. count) } ) {
90
90
case 0 :
91
91
debug ( " Output stream delegate reached end of stream when writing. " )
92
- performAction ( self . state. endEncountered ( ) )
92
+ performAction ( state. endEncountered ( ) )
93
93
case - 1 :
94
94
debug ( " Output stream delegate encountered error writing to stream: \( outputStream. streamError!) . " )
95
- performAction ( self . state. errorOccurred ( outputStream. streamError!) )
95
+ performAction ( state. errorOccurred ( outputStream. streamError!) )
96
96
case let written where written > 0 :
97
97
debug ( " Output stream delegate wrote \( written) bytes to stream. " )
98
98
performAction (
99
- self . state. wroteBytes (
100
- numBytesWritten: written,
101
- streamStillHasSpaceAvailable: outputStream. hasSpaceAvailable
102
- )
99
+ state. wroteBytes ( numBytesWritten: written, streamStillHasSpaceAvailable: outputStream. hasSpaceAvailable)
103
100
)
104
101
default : preconditionFailure ( " OutputStream.write(_:maxLength:) returned undocumented value " )
105
102
}
@@ -115,9 +112,9 @@ final class HTTPBodyOutputStreamBridge: NSObject, StreamDelegate {
115
112
return
116
113
}
117
114
startWriterTask ( )
118
- case . hasSpaceAvailable: performAction ( self . state. spaceBecameAvailable ( ) )
119
- case . errorOccurred: performAction ( self . state. errorOccurred ( stream. streamError!) )
120
- case . endEncountered: performAction ( self . state. endEncountered ( ) )
115
+ case . hasSpaceAvailable: performAction ( state. spaceBecameAvailable ( ) )
116
+ case . errorOccurred: performAction ( state. errorOccurred ( stream. streamError!) )
117
+ case . endEncountered: performAction ( state. endEncountered ( ) )
121
118
default :
122
119
debug ( " Output stream ignoring event: \( event) . " )
123
120
break
0 commit comments