Skip to content

Commit 0bb4f4c

Browse files
committed
Rename Context to ConnectionContext
1 parent bcab257 commit 0bb4f4c

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Sources/HTTPServer/NIOHTTPServer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ public struct NIOHTTPServer: HTTPServerProtocol {
8888
/// Task-local storage for connection-specific information accessible from request handlers.
8989
///
9090
/// Use this to access data such as the peer's validated certificate chain.
91-
@TaskLocal public static var context: Context = Context()
91+
@TaskLocal public static var connectionContext = ConnectionContext()
9292

9393
/// Connection-specific information available during request handling.
9494
///
9595
/// Provides access to data such as the peer's validated certificate chain.
96-
public struct Context: Sendable {
96+
public struct ConnectionContext: Sendable {
9797
var peerCertificateChainFuture: EventLoopFuture<NIOSSL.ValidatedCertificateChain?>?
9898

9999
init(_ peerCertificateChainFuture: EventLoopFuture<NIOSSL.ValidatedCertificateChain?>? = nil) {
@@ -375,7 +375,7 @@ public struct NIOHTTPServer: HTTPServerProtocol {
375375
switch try await upgradeResult.get() {
376376
case .http1_1(let http1Channel):
377377
let chainFuture = http1Channel.channel.nioSSL_peerValidatedCertificateChain()
378-
Self.$context.withValue(Context(chainFuture)) {
378+
Self.$connectionContext.withValue(ConnectionContext(chainFuture)) {
379379
connectionGroup.addTask {
380380
try await self.handleRequestChannel(
381381
channel: http1Channel,
@@ -387,7 +387,7 @@ public struct NIOHTTPServer: HTTPServerProtocol {
387387
do {
388388
let chainFuture = http2Connection.nioSSL_peerValidatedCertificateChain()
389389
for try await http2StreamChannel in http2Multiplexer.inbound {
390-
Self.$context.withValue(Context(chainFuture)) {
390+
Self.$connectionContext.withValue(ConnectionContext(chainFuture)) {
391391
connectionGroup.addTask {
392392
try await self.handleRequestChannel(
393393
channel: http2StreamChannel,

Tests/HTTPServerTests/NIOHTTPServerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ struct NIOHTTPServerTests {
160160
#expect(request.path == "/")
161161

162162
do {
163-
let peerChain = try #require(try await NIOHTTPServer.context.peerCertificateChain)
163+
let peerChain = try #require(try await NIOHTTPServer.connectionContext.peerCertificateChain)
164164
#expect(Array(peerChain) == [clientChain.leaf])
165165
} catch {
166166
Issue.record("Could not obtain the peer's certificate chain: \(error)")

Tests/HTTPServerTests/Utilities/Certificates.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct TestCA {
3939
}
4040
)
4141
}
42-
42+
4343
static func makeCertificate(
4444
issuerName: DistinguishedName,
4545
issuerKey: Certificate.PrivateKey,
@@ -61,4 +61,3 @@ struct TestCA {
6161
)
6262
}
6363
}
64-

Tests/HTTPServerTests/Utilities/Client.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@testable import HTTPServer
21
import NIOCore
32
import NIOHTTPTypes
43
import NIOHTTPTypesHTTP1
@@ -7,6 +6,8 @@ import NIOPosix
76
import NIOSSL
87
import X509
98

9+
@testable import HTTPServer
10+
1011
typealias ClientChannel = NIOAsyncChannel<HTTPResponsePart, HTTPRequestPart>
1112

1213
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *)
@@ -70,7 +71,7 @@ func setUpClientWithMTLS(
7071
case .http2(let http2Channel):
7172
precondition(applicationProtocol == "h2", "Unexpectedly established a HTTP 2 channel")
7273
return try await http2Channel.openStream { channel in
73-
channel.eventLoop.makeCompletedFuture() {
74+
channel.eventLoop.makeCompletedFuture {
7475
try channel.pipeline.syncOperations.addHandler(HTTP2FramePayloadToHTTPClientCodec())
7576
return try ClientChannel(wrappingChannelSynchronously: channel, configuration: .init())
7677
}

0 commit comments

Comments
 (0)