Skip to content

Commit e551fd6

Browse files
authored
fix!: Represent TCP port as UInt16 (#924)
1 parent 495e755 commit e551fd6

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

Diff for: Sources/ClientRuntime/Networking/Http/CRT/CRTClientEngine.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class CRTClientEngine: HTTPClient {
4343
private struct ConnectionPoolID: Hashable {
4444
private let protocolType: URIScheme?
4545
private let host: String
46-
private let port: Int16
46+
private let port: UInt16
4747

4848
init(endpoint: Endpoint) {
4949
self.protocolType = endpoint.uri.scheme

Diff for: Sources/Smithy/URI.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public struct URI: Hashable {
1111
public let scheme: URIScheme
1212
public let path: String
1313
public let host: String
14-
public let port: Int16?
15-
public var defaultPort: Int16 {
16-
Int16(scheme.port)
14+
public let port: UInt16?
15+
public var defaultPort: UInt16 {
16+
UInt16(scheme.port)
1717
}
1818
public let queryItems: [URIQueryItem]
1919
public let username: String?
@@ -29,7 +29,7 @@ public struct URI: Hashable {
2929
fileprivate init(scheme: URIScheme,
3030
path: String,
3131
host: String,
32-
port: Int16?,
32+
port: UInt16?,
3333
queryItems: [URIQueryItem],
3434
username: String? = nil,
3535
password: String? = nil,
@@ -122,7 +122,7 @@ public final class URIBuilder {
122122
}
123123

124124
@discardableResult
125-
public func withPort(_ value: Int16?) -> URIBuilder {
125+
public func withPort(_ value: UInt16?) -> URIBuilder {
126126
self.urlComponents.port = value.map { Int($0) }
127127
return self
128128
}
@@ -209,7 +209,7 @@ public final class URIBuilder {
209209
return URI(scheme: URIScheme(rawValue: self.urlComponents.scheme!)!,
210210
path: self.urlComponents.percentEncodedPath,
211211
host: self.urlComponents.percentEncodedHost!,
212-
port: self.urlComponents.port.map { Int16($0) },
212+
port: self.urlComponents.port.map { UInt16($0) },
213213
queryItems: self.urlComponents.percentEncodedQueryItems?.map {
214214
URIQueryItem(name: $0.name, value: $0.value)
215215
} ?? [],

Diff for: Sources/SmithyHTTPAPI/Endpoint.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public struct Endpoint: Hashable {
1515
public var queryItems: [URIQueryItem] { uri.queryItems }
1616
public var path: String { uri.path }
1717
public var host: String { uri.host }
18-
public var port: Int16? { uri.port }
18+
public var port: UInt16? { uri.port }
1919
public var url: URL? { uri.url }
2020
private let properties: [String: AnyHashable]
2121

@@ -54,7 +54,7 @@ public struct Endpoint: Hashable {
5454

5555
public init(host: String,
5656
path: String = "/",
57-
port: Int16 = 443,
57+
port: UInt16 = 443,
5858
queryItems: [URIQueryItem]? = nil,
5959
headers: Headers = Headers(),
6060
protocolType: URIScheme? = .https) {

Diff for: Sources/SmithyHTTPAPI/HTTPRequest.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public final class HTTPRequestBuilder: RequestMessageBuilder {
152152
public private(set) var path: String = "/"
153153
public private(set) var body: ByteStream = .noStream
154154
public private(set) var queryItems = [URIQueryItem]()
155-
public private(set) var port: Int16?
155+
public private(set) var port: UInt16?
156156
public private(set) var protocolType: URIScheme = .https
157157
public private(set) var trailingHeaders: Headers = Headers()
158158

@@ -242,7 +242,7 @@ public final class HTTPRequestBuilder: RequestMessageBuilder {
242242
}
243243

244244
@discardableResult
245-
public func withPort(_ value: Int16?) -> HTTPRequestBuilder {
245+
public func withPort(_ value: UInt16?) -> HTTPRequestBuilder {
246246
self.port = value
247247
return self
248248
}

Diff for: Sources/SmithyTestUtil/RequestTestUtil/ExpectedSdkHttpRequest.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class ExpectedSdkHttpRequestBuilder {
5353
var queryItems = [URIQueryItem]()
5454
var forbiddenQueryItems = [URIQueryItem]()
5555
var requiredQueryItems = [URIQueryItem]()
56-
var port: Int16 = 443
56+
var port: UInt16 = 443
5757
var protocolType: URIScheme = .https
5858

5959
// We follow the convention of returning the builder object
@@ -127,7 +127,7 @@ public class ExpectedSdkHttpRequestBuilder {
127127
}
128128

129129
@discardableResult
130-
public func withPort(_ value: Int16) -> ExpectedSdkHttpRequestBuilder {
130+
public func withPort(_ value: UInt16) -> ExpectedSdkHttpRequestBuilder {
131131
self.port = value
132132
return self
133133
}

0 commit comments

Comments
 (0)