Skip to content

Commit 69849f7

Browse files
authored
Prefer H2 over H1 when negotiating (#16)
1 parent a714c49 commit 69849f7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Sources/HTTPServer/HTTPServer.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,16 @@ public final class Server<RequestHandler: HTTPServerRequestHandler> {
236236
)
237237
)
238238

239+
var tlsConfiguration: TLSConfiguration = .makeServerConfiguration(
240+
certificateChain: certificateChain,
241+
privateKey: privateKey
242+
)
243+
tlsConfiguration.applicationProtocols = ["h2", "http/1.1"]
244+
239245
try channel.pipeline.syncOperations
240246
.addHandler(
241247
NIOSSLServerHandler(
242-
context: .init(
243-
configuration: .makeServerConfiguration(
244-
certificateChain: certificateChain,
245-
privateKey: privateKey
246-
)
247-
)
248+
context: .init(configuration: tlsConfiguration)
248249
)
249250
)
250251
}.flatMap {

0 commit comments

Comments
 (0)