From 43230971237024806f2f71e13f6cd9f1395e0ad5 Mon Sep 17 00:00:00 2001 From: Sichan Yoo Date: Mon, 18 Sep 2023 11:11:27 -0700 Subject: [PATCH 1/3] Add toBuilder() to SdkHttpRequest. --- .../Networking/Http/SdkHttpRequest.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift b/Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift index 83de78b85..699d5c0de 100644 --- a/Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift +++ b/Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift @@ -25,6 +25,18 @@ public class SdkHttpRequest { self.endpoint = endpoint self.body = body } + + public func toBuilder() -> SdkHttpRequestBuilder { + return SdkHttpRequestBuilder() + .withBody(self.body) + .withMethod(self.method) + .withHeaders(self.headers) + .withPath(self.path) + .withHost(self.host) + .withQueryItems(self.queryItems ?? []) + .withPort(self.endpoint.port) + .withProtocol(self.endpoint.protocolType ?? .https) + } } extension SdkHttpRequest { From 7832636d365b72d08c78bb9fe0c7b48b0054ed21 Mon Sep 17 00:00:00 2001 From: Sichan Yoo Date: Mon, 18 Sep 2023 14:51:04 -0700 Subject: [PATCH 2/3] Change nil query items handling. --- Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift b/Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift index 699d5c0de..428adc1f6 100644 --- a/Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift +++ b/Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift @@ -27,15 +27,18 @@ public class SdkHttpRequest { } public func toBuilder() -> SdkHttpRequestBuilder { - return SdkHttpRequestBuilder() + let builder = SdkHttpRequestBuilder() .withBody(self.body) .withMethod(self.method) .withHeaders(self.headers) .withPath(self.path) .withHost(self.host) - .withQueryItems(self.queryItems ?? []) .withPort(self.endpoint.port) .withProtocol(self.endpoint.protocolType ?? .https) + if let qItems = self.queryItems { + builder.withQueryItems(qItems) + } + return builder } } From c03b52e381c90bc5292de02182d756228ce0d94f Mon Sep 17 00:00:00 2001 From: Sichan Yoo Date: Wed, 20 Sep 2023 14:22:06 -0700 Subject: [PATCH 3/3] Fix swiftlint. --- Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift b/Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift index 428adc1f6..f37e32c27 100644 --- a/Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift +++ b/Sources/ClientRuntime/Networking/Http/SdkHttpRequest.swift @@ -25,7 +25,7 @@ public class SdkHttpRequest { self.endpoint = endpoint self.body = body } - + public func toBuilder() -> SdkHttpRequestBuilder { let builder = SdkHttpRequestBuilder() .withBody(self.body)