Skip to content

Commit 0181228

Browse files
committed
update swift-nio to 2.79.0
1 parent 91c979b commit 0181228

File tree

4 files changed

+70
-92
lines changed

4 files changed

+70
-92
lines changed

Sources/HTTPClient/HTTP1/HTTP.Client1.swift

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,17 @@ extension HTTP.Client1
3434
{
3535
(channel:any Channel) in
3636

37-
guard
38-
let niossl:NIOSSLContext
39-
else
37+
channel.eventLoop.makeCompletedFuture
4038
{
41-
return channel.pipeline.addHTTPClientHandlers()
42-
.flatMap
39+
if let niossl:NIOSSLContext
4340
{
44-
channel.pipeline.addHandler(InterfaceHandler.init())
41+
let tlsHandler:NIOSSLClientHandler = try .init(context: niossl,
42+
serverHostname: remote)
43+
try channel.pipeline.syncOperations.addHandler(tlsHandler)
4544
}
46-
}
47-
48-
do
49-
{
50-
let tls:NIOSSLClientHandler = try .init(context: niossl,
51-
serverHostname: remote)
5245

53-
return channel.pipeline.addHandler(tls)
54-
.flatMap
55-
{
56-
channel.pipeline.addHTTPClientHandlers()
57-
.flatMap
58-
{
59-
channel.pipeline.addHandler(InterfaceHandler.init())
60-
}
61-
}
62-
}
63-
catch let error
64-
{
65-
return channel.eventLoop.makeFailedFuture(error)
46+
try channel.pipeline.syncOperations.addHTTPClientHandlers()
47+
try channel.pipeline.syncOperations.addHandler(InterfaceHandler.init())
6648
}
6749
}
6850

Sources/HTTPClient/HTTP2/HTTP.Client2.InterfaceHandler.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ extension HTTP.Client2.InterfaceHandler:ChannelOutboundHandler
6565
{
6666
self.multiplexer.createStreamChannel
6767
{
68-
$0.pipeline.addHandler(HTTP.Client2.StreamHandler.init(owner: owner))
68+
(channel:any Channel) in channel.eventLoop.makeCompletedFuture
69+
{
70+
try channel.pipeline.syncOperations.addHandler(
71+
HTTP.Client2.StreamHandler.init(owner: owner))
72+
}
6973
}
7074
.whenComplete
7175
{

Sources/HTTPClient/HTTP2/HTTP.Client2.swift

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,36 +35,30 @@ extension HTTP.Client2
3535
.connectTimeout(.seconds(3))
3636
.channelInitializer
3737
{
38-
(channel:any Channel) in
39-
40-
do
38+
(channel:any Channel) in channel.eventLoop.makeCompletedFuture
4139
{
42-
let tls:NIOSSLClientHandler = try .init(context: niossl,
40+
let tlsHandler:NIOSSLClientHandler = try .init(context: niossl,
4341
serverHostname: remote)
42+
let multiplexer:NIOHTTP2Handler.StreamMultiplexer
43+
44+
try channel.pipeline.syncOperations.addHandler(tlsHandler)
4445

45-
return channel.pipeline.addHandler(tls)
46-
.flatMap
46+
multiplexer = try channel.pipeline.syncOperations.configureHTTP2Pipeline(
47+
mode: .client,
48+
connectionConfiguration: .init(),
49+
streamConfiguration: .init())
4750
{
48-
channel.configureHTTP2Pipeline(mode: .client,
49-
connectionConfiguration: .init(),
50-
streamConfiguration: .init())
51+
(channel:any Channel) in channel.eventLoop.makeCompletedFuture
5152
{
5253
// With no owner, the stream is unsolicited and will drop any
5354
// responses it receives.
54-
$0.pipeline.addHandler(StreamHandler.init(owner: nil))
55-
}
56-
.flatMap
57-
{
58-
(multiplexer:NIOHTTP2Handler.StreamMultiplexer) in
59-
60-
channel.pipeline.addHandler(InterfaceHandler.init(
61-
multiplexer: multiplexer))
55+
try channel.pipeline.syncOperations.addHandler(StreamHandler.init(
56+
owner: nil))
6257
}
6358
}
64-
}
65-
catch let error
66-
{
67-
return channel.eventLoop.makeFailedFuture(error)
59+
60+
try channel.pipeline.syncOperations.addHandler(InterfaceHandler.init(
61+
multiplexer: multiplexer))
6862
}
6963
}
7064

Sources/HTTPServer/HTTP.Server.swift

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -88,61 +88,59 @@ extension HTTP.Server
8888
{
8989
(channel:any Channel) in
9090

91-
let encryptionHandlers:[any ChannelHandler]
92-
93-
switch encryption
91+
if case .local(let context) = encryption
9492
{
95-
case .local(let context):
96-
encryptionHandlers = [NIOSSLServerHandler.init(context: context)]
97-
98-
case .proxy:
99-
encryptionHandlers = []
93+
let encryptionHandler:NIOSSLServerHandler = .init(context: context)
94+
do
95+
{
96+
try channel.pipeline.syncOperations.addHandler(encryptionHandler)
97+
}
98+
catch let error
99+
{
100+
return channel.eventLoop.makeFailedFuture(error)
101+
}
100102
}
101103

102-
return channel.pipeline.addHandlers(encryptionHandlers)
103-
.flatMap
104+
return channel.configureAsyncHTTPServerPipeline
104105
{
105-
channel.configureAsyncHTTPServerPipeline
106-
{
107-
(connection:any Channel) in
106+
(connection:any Channel) in
108107

109-
connection.eventLoop.makeCompletedFuture
110-
{
111-
try connection.pipeline.syncOperations.addHandler(
112-
HTTP.OutboundShimHandler.init())
113-
114-
return try NIOAsyncChannel<
115-
HTTPPart<HTTPRequestHead, ByteBuffer>,
116-
HTTPPart<HTTPResponseHead, ByteBuffer>>.init(
117-
wrappingChannelSynchronously: connection,
118-
configuration: .init())
119-
}
120-
}
121-
http2ConnectionInitializer:
108+
connection.eventLoop.makeCompletedFuture
122109
{
123-
(connection:any Channel) in
124-
125-
connection.eventLoop.makeCompletedFuture { connection }
110+
try connection.pipeline.syncOperations.addHandler(
111+
HTTP.OutboundShimHandler.init())
112+
113+
return try NIOAsyncChannel<
114+
HTTPPart<HTTPRequestHead, ByteBuffer>,
115+
HTTPPart<HTTPResponseHead, ByteBuffer>>.init(
116+
wrappingChannelSynchronously: connection,
117+
configuration: .init())
126118
}
127-
http2StreamInitializer:
128-
{
129-
(stream:any Channel) in
119+
}
120+
http2ConnectionInitializer:
121+
{
122+
(connection:any Channel) in
130123

131-
stream.eventLoop.makeCompletedFuture
132-
{
133-
guard
134-
let id:HTTP2StreamID = try stream.syncOptions?.getOption(
135-
HTTP2StreamChannelOptions.streamID)
136-
else
137-
{
138-
throw HTTP.StreamIdentifierError.missing
139-
}
124+
connection.eventLoop.makeCompletedFuture { connection }
125+
}
126+
http2StreamInitializer:
127+
{
128+
(stream:any Channel) in
140129

141-
return .init(frames: try .init(
142-
wrappingChannelSynchronously: stream,
143-
configuration: .init()),
144-
id: id)
130+
stream.eventLoop.makeCompletedFuture
131+
{
132+
guard
133+
let id:HTTP2StreamID = try stream.syncOptions?.getOption(
134+
HTTP2StreamChannelOptions.streamID)
135+
else
136+
{
137+
throw HTTP.StreamIdentifierError.missing
145138
}
139+
140+
return .init(frames: try .init(
141+
wrappingChannelSynchronously: stream,
142+
configuration: .init()),
143+
id: id)
146144
}
147145
}
148146
}

0 commit comments

Comments
 (0)