fix: send auth token with sentence boundary API requests

This commit is contained in:
2026-09-01 08:41:52 +08:00
parent 09fbe8a2de
commit 1adba4d227
5 changed files with 17 additions and 3 deletions

View File

@@ -25,14 +25,17 @@ enum HTTPClient {
_ type: T.Type,
baseURL: String,
path: String,
timeout: TimeInterval
timeout: TimeInterval,
additionalHeaders: [String: String] = [:]
) async throws -> (value: T, effectiveBaseURL: String) {
var headers = ["Accept": "application/json"]
headers.merge(additionalHeaders) { _, new in new }
let result = try await execute(
baseURL: baseURL,
path: path,
method: "GET",
timeout: timeout,
headers: ["Accept": "application/json"]
headers: headers
)
guard (200...299).contains(result.statusCode) else {
let body = String(data: result.body, encoding: .utf8) ?? ""