Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Sources/LiveKit/Core/Room.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ public class Room: NSObject, @unchecked Sendable, ObservableObject, Loggable {
connectOptions: ConnectOptions? = nil,
roomOptions: RoomOptions? = nil)
{
_ = LKNet.bootstrap
// Ensure manager shared objects are instantiated
#if !LK_BENCHMARK
DeviceManager.prepare()
Expand Down
1 change: 1 addition & 0 deletions Sources/LiveKit/LiveKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class LiveKitSDK: NSObject, Loggable {
public static func prepare() {
// TODO: Add RTC related initializations
DeviceManager.prepare()
_ = LKNet.bootstrap
}
}

Expand Down
68 changes: 68 additions & 0 deletions Sources/LiveKit/Net/LKNetHTTPClient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright 2026 LiveKit (Apache-2.0)
import Foundation
internal import LiveKitUniFFI

/// Live HTTP transport backing `livekit-net`, over `URLSession`. Byte-faithful:
/// returns raw response bytes; never decodes to string/JSON.
final class LKNetHTTPClientLive: HttpClient, @unchecked Sendable {

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, tvOS Simulator,name=Apple TV 4K (3rd generation),OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, visionOS Simulator,name=Apple Vision Pro,OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, iOS Simulator,name=iPhone 17 Pro,OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, visionOS Simulator,name=Apple Vision Pro,OS=26.5)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, tvOS Simulator,name=Apple TV,OS=26.5)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, iOS Simulator,name=iPhone 16 Pro,OS=18.5)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, tvOS Simulator,name=Apple TV,OS=18.5)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 7 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS)

cannot find type 'HttpClient' in scope
private let session: URLSession

init(session: URLSession = URLSession(configuration: .default)) {
self.session = session
}

func request(method: HttpMethod, url: String, headers: [Header], body: Data?) async throws -> HttpResponse {

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Lint

Function should have complexity 10 or less; currently complexity is 13 (cyclomatic_complexity)

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, tvOS Simulator,name=Apple TV 4K (3rd generation),OS=27.0)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, tvOS Simulator,name=Apple TV 4K (3rd generation),OS=27.0)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, tvOS Simulator,name=Apple TV 4K (3rd generation),OS=27.0)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, visionOS Simulator,name=Apple Vision Pro,OS=27.0)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, visionOS Simulator,name=Apple Vision Pro,OS=27.0)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, visionOS Simulator,name=Apple Vision Pro,OS=27.0)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, iOS Simulator,name=iPhone 17 Pro,OS=27.0)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, iOS Simulator,name=iPhone 17 Pro,OS=27.0)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, iOS Simulator,name=iPhone 17 Pro,OS=27.0)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS,variant=Mac Catalyst)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS,variant=Mac Catalyst)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS,variant=Mac Catalyst)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, visionOS Simulator,name=Apple Vision Pro,OS=26.5)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, visionOS Simulator,name=Apple Vision Pro,OS=26.5)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, visionOS Simulator,name=Apple Vision Pro,OS=26.5)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, tvOS Simulator,name=Apple TV,OS=26.5)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, tvOS Simulator,name=Apple TV,OS=26.5)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, tvOS Simulator,name=Apple TV,OS=26.5)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS,variant=Mac Catalyst)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS,variant=Mac Catalyst)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS,variant=Mac Catalyst)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS,variant=Mac Catalyst)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS,variant=Mac Catalyst)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS,variant=Mac Catalyst)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, iOS Simulator,name=iPhone 16 Pro,OS=18.5)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, iOS Simulator,name=iPhone 16 Pro,OS=18.5)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, iOS Simulator,name=iPhone 16 Pro,OS=18.5)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, tvOS Simulator,name=Apple TV,OS=18.5)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, tvOS Simulator,name=Apple TV,OS=18.5)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, tvOS Simulator,name=Apple TV,OS=18.5)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpResponse' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS)

cannot find type 'Header' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS)

cannot find type 'HttpMethod' in scope

Check failure on line 14 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS)

cannot find type 'HttpResponse' in scope
guard let u = URL(string: url) else { throw TransportError.Connection("invalid url: \(url)") }
var req = URLRequest(url: u)
req.httpMethod = method == .get ? "GET" : "POST"
for h in headers { req.addValue(h.value, forHTTPHeaderField: h.name) }
if let body { req.httpBody = body }

do {
let (data, response): (Data, URLResponse) = try await withCheckedThrowingContinuation { cont in
let task = session.dataTask(with: req) { data, response, error in
if let error { cont.resume(throwing: error) }

Check failure on line 24 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Lint

Else and catch should be on the same line, one space after the previous declaration (statement_position)
else if let data, let response { cont.resume(returning: (data, response)) }

Check failure on line 25 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Lint

Else and catch should be on the same line, one space after the previous declaration (statement_position)
else { cont.resume(throwing: URLError(.badServerResponse)) }
}
task.resume()
}
guard let http = response as? HTTPURLResponse else {
throw TransportError.Other("non-HTTP response")
}
let respHeaders: [Header] = http.allHeaderFields.compactMap { key, value in
guard let name = key as? String else { return nil }
return Header(name: name, value: "\(value)")
}
return HttpResponse(status: UInt16(clamping: http.statusCode), headers: respHeaders, body: data)
} catch let t as TransportError {
throw t
} catch let e as URLError {
switch e.code {
case .timedOut: throw TransportError.Timeout
case .cancelled: throw TransportError.Closed
default: throw TransportError.Connection(e.localizedDescription)
}
} catch {
throw TransportError.Connection("\(error)")
}
}
}

/// Forwarding HTTP client registered with `livekit-net`. Production forwards to
/// `LKNetHTTPClientLive`; `#if DEBUG` tests swap the delegate to a dummy.
final class LKNetHTTPClient: HttpClient, @unchecked Sendable {

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, tvOS Simulator,name=Apple TV 4K (3rd generation),OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, visionOS Simulator,name=Apple Vision Pro,OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, iOS Simulator,name=iPhone 17 Pro,OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, visionOS Simulator,name=Apple Vision Pro,OS=26.5)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, tvOS Simulator,name=Apple TV,OS=26.5)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, iOS Simulator,name=iPhone 16 Pro,OS=18.5)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, tvOS Simulator,name=Apple TV,OS=18.5)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 54 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS)

cannot find type 'HttpClient' in scope
private let delegate: StateSync<any HttpClient>

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, tvOS Simulator,name=Apple TV 4K (3rd generation),OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, visionOS Simulator,name=Apple Vision Pro,OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, iOS Simulator,name=iPhone 17 Pro,OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, visionOS Simulator,name=Apple Vision Pro,OS=26.5)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, tvOS Simulator,name=Apple TV,OS=26.5)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, iOS Simulator,name=iPhone 16 Pro,OS=18.5)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, tvOS Simulator,name=Apple TV,OS=18.5)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 55 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS)

cannot find type 'HttpClient' in scope

init(_ initial: any HttpClient = LKNetHTTPClientLive()) {

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, tvOS Simulator,name=Apple TV 4K (3rd generation),OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, visionOS Simulator,name=Apple Vision Pro,OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, iOS Simulator,name=iPhone 17 Pro,OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, visionOS Simulator,name=Apple Vision Pro,OS=26.5)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, tvOS Simulator,name=Apple TV,OS=26.5)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, iOS Simulator,name=iPhone 16 Pro,OS=18.5)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, tvOS Simulator,name=Apple TV,OS=18.5)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 57 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS)

cannot find type 'HttpClient' in scope
delegate = StateSync(initial)
}

#if DEBUG
func setDelegate(_ d: any HttpClient) { delegate.mutate { $0 = d } }

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, tvOS Simulator,name=Apple TV 4K (3rd generation),OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, visionOS Simulator,name=Apple Vision Pro,OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, iOS Simulator,name=iPhone 17 Pro,OS=27.0)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, visionOS Simulator,name=Apple Vision Pro,OS=26.5)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, tvOS Simulator,name=Apple TV,OS=26.5)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS,variant=Mac Catalyst)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, iOS Simulator,name=iPhone 16 Pro,OS=18.5)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, tvOS Simulator,name=Apple TV,OS=18.5)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpClient' in scope

Check failure on line 62 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS)

cannot find type 'HttpClient' in scope
#endif

func request(method: HttpMethod, url: String, headers: [Header], body: Data?) async throws -> HttpResponse {

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, tvOS Simulator,name=Apple TV 4K (3rd generation),OS=27.0)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, tvOS Simulator,name=Apple TV 4K (3rd generation),OS=27.0)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, visionOS Simulator,name=Apple Vision Pro,OS=27.0)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, visionOS Simulator,name=Apple Vision Pro,OS=27.0)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, iOS Simulator,name=iPhone 17 Pro,OS=27.0)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, iOS Simulator,name=iPhone 17 Pro,OS=27.0)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS,variant=Mac Catalyst)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS,variant=Mac Catalyst)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, visionOS Simulator,name=Apple Vision Pro,OS=26.5)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, visionOS Simulator,name=Apple Vision Pro,OS=26.5)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, tvOS Simulator,name=Apple TV,OS=26.5)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, tvOS Simulator,name=Apple TV,OS=26.5)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (xcode-27, latest, macOS)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS,variant=Mac Catalyst)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS,variant=Mac Catalyst)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS,variant=Mac Catalyst)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS,variant=Mac Catalyst)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, iOS Simulator,name=iPhone 16 Pro,OS=18.5)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, iOS Simulator,name=iPhone 16 Pro,OS=18.5)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, tvOS Simulator,name=Apple TV,OS=18.5)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, tvOS Simulator,name=Apple TV,OS=18.5)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, iOS Simulator,name=iPhone 17 Pro,OS=26.5, true)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, 26.6, macOS, true)

cannot find type 'HttpResponse' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS)

cannot find type 'HttpMethod' in scope

Check failure on line 65 in Sources/LiveKit/Net/LKNetHTTPClient.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-15, 16.4, macOS)

cannot find type 'HttpResponse' in scope
try await delegate.read { $0 }.request(method: method, url: url, headers: headers, body: body)
}
}
133 changes: 133 additions & 0 deletions Sources/LiveKit/Net/LKNetWSClient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// Copyright 2026 LiveKit (Apache-2.0)
import Foundation
internal import LiveKitUniFFI

/// Live WebSocket transport backing `livekit-net`, over `URLSessionWebSocketTask`.
final class LKNetWSClientLive: WsClient, @unchecked Sendable {
func connect(url: String, headers: [Header], timeoutMs: UInt64) async throws -> WsConnectResult {
guard let u = URL(string: url) else { throw TransportError.Connection("invalid url: \(url)") }
let conn = try await LKNetWSConnection(url: u, headers: headers, timeoutMs: timeoutMs)
return WsConnectResult(connection: conn)
}
}

/// Forwarding WS client registered with `livekit-net`. Production forwards to
/// `LKNetWSClientLive`; `#if DEBUG` tests swap the delegate to a dummy.
final class LKNetWSClient: WsClient, @unchecked Sendable {
private let delegate: StateSync<any WsClient>

init(_ initial: any WsClient = LKNetWSClientLive()) {
delegate = StateSync(initial)
}

#if DEBUG
func setDelegate(_ d: any WsClient) { delegate.mutate { $0 = d } }
#endif

func connect(url: String, headers: [Header], timeoutMs: UInt64) async throws -> WsConnectResult {
try await delegate.read { $0 }.connect(url: url, headers: headers, timeoutMs: timeoutMs)
}
}

/// One open WebSocket for `livekit-net`. Binary frames only; string frames are
/// decoded as UTF-8 bytes at the boundary (Swift does not interpret content).
final class LKNetWSConnection: WsConnection, @unchecked Sendable {
private let session: URLSession
private let task: URLSessionWebSocketTask
private let connectDelegate: WSConnectDelegate

init(url: URL, headers: [Header], timeoutMs: UInt64) async throws {
var req = URLRequest(url: url, cachePolicy: .useProtocolCachePolicy,
timeoutInterval: TimeInterval(timeoutMs) / 1000.0)
for h in headers { req.addValue(h.value, forHTTPHeaderField: h.name) }

connectDelegate = WSConnectDelegate()
session = URLSession(configuration: .default, delegate: connectDelegate, delegateQueue: nil)
task = session.webSocketTask(with: req)

do {
try await withCheckedThrowingContinuation { (cont: CheckedContinuation<Void, Error>) in
connectDelegate.setConnectContinuation(cont)
task.resume()
}
} catch {
session.invalidateAndCancel()
throw Self.map(error)
}
}

deinit {
task.cancel(with: .normalClosure, reason: nil)
session.invalidateAndCancel()
}

func send(frame: Data) async throws {
do {
try await withCheckedThrowingContinuation { (cont: CheckedContinuation<Void, Error>) in
task.send(.data(frame)) { error in
if let error { cont.resume(throwing: error) } else { cont.resume() }
}
}
} catch {
throw Self.map(error)
}
}

func recv() async throws -> Data? {
guard task.closeCode == .invalid else { return nil }
do {
let message: URLSessionWebSocketTask.Message = try await withCheckedThrowingContinuation { cont in
task.receive { cont.resume(with: $0) }
}
return Self.decode(message)
} catch {
if task.closeCode != .invalid { return nil }
throw Self.map(error)
}
}
Comment on lines +76 to +87

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Cancelled websocket operations never finish, keeping the socket and its session alive

The websocket receive and connect steps wait on a callback with no cancellation path (withCheckedThrowingContinuation at Sources/LiveKit/Net/LKNetWSClient.swift:79-81), so when the caller cancels, the wait never ends on an idle socket and the connection is held open forever.
Impact: Cancelled network work can hang indefinitely and leak the underlying socket and session for the lifetime of the app.

Missing cooperative cancellation compared to the existing WebSocket implementation

Sources/LiveKit/Support/Network/WebSocket.swift:57-64 wraps the connect continuation in withTaskCancellationHandler and also has Delegate.cancelConnection() (Sources/LiveKit/Support/Network/WebSocket.swift:71-74,122-127) so a cancelled connect resumes the continuation; WebSocket.AsyncIterator.next() (Sources/LiveKit/Support/Network/WebSocket.swift:83-101) wraps task.receive in withTaskCancellationHandler and returns nil when Task.isCancelled.

The new LKNetWSConnection.init (Sources/LiveKit/Net/LKNetWSClient.swift:48-56) and recv() have neither: on cancellation the continuation stays suspended until the underlying URLSession callback eventually fires. For recv() on an idle, healthy socket no callback ever fires, so the suspended async frame keeps self (and thus the URLSessionWebSocketTask and the URLSession created with a delegate) alive indefinitely, and deinit's cleanup never runs. The same lack of cancellation applies to LKNetHTTPClientLive.request (Sources/LiveKit/Net/LKNetHTTPClient.swift:22-29), where the data task is not cancelled when the awaiting task is cancelled.

AGENTS.md: "Long-running Task requires cooperative cancellation to avoid memory leaks".

Prompt for agents
LKNetWSConnection.recv() and LKNetWSConnection.init(), plus LKNetHTTPClientLive.request(), await callback-based URLSession APIs via withCheckedThrowingContinuation without any cancellation handling. Mirror the pattern already used in Sources/LiveKit/Support/Network/WebSocket.swift: wrap the continuations in withTaskCancellationHandler, cancel/close the underlying task (or resume a stored connect continuation via a cancelConnection()-style method on WSConnectDelegate) from the onCancel closure, and treat cancellation in recv() as end-of-stream (return nil) as the existing AsyncIterator does. For the HTTP client, cancel the URLSessionDataTask in onCancel so the continuation is always resumed.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


func close() async {
task.cancel(with: .normalClosure, reason: nil)
session.finishTasksAndInvalidate()
}

static func decode(_ message: URLSessionWebSocketTask.Message) -> Data {
switch message {
case let .data(d): return d
case let .string(s): return Data(s.utf8)
@unknown default: return Data()
}
}

private static func map(_ error: Error) -> TransportError {
if let u = error as? URLError {
switch u.code {
case .timedOut: return .Timeout
case .cancelled: return .Closed
default: return .Connection(u.localizedDescription)
}
}
return .Connection("\(error)")
}
}

/// Bridges `URLSessionWebSocketDelegate` open/close callbacks to a continuation.
/// Mirrors `Support/Network/WebSocket.swift`'s `Delegate`.
private final class WSConnectDelegate: NSObject, URLSessionWebSocketDelegate {
private let continuation = StateSync<CheckedContinuation<Void, Error>?>(nil)

func setConnectContinuation(_ c: CheckedContinuation<Void, Error>) {
continuation.mutate { $0 = c }
}

func urlSession(_: URLSession, webSocketTask _: URLSessionWebSocketTask, didOpenWithProtocol _: String?) {
continuation.mutate { $0?.resume(); $0 = nil }
}

func urlSession(_: URLSession, task _: URLSessionTask, didCompleteWithError error: Error?) {
continuation.mutate {
if let error { $0?.resume(throwing: error) } else { $0?.resume() }
$0 = nil
}
}
}
23 changes: 23 additions & 0 deletions Sources/LiveKit/Net/NetBootstrap.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2026 LiveKit (Apache-2.0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 New source and test files are missing the required license header

The newly added files start with a one-line copyright comment instead of the mandated Apache header block (// Copyright 2026 LiveKit (Apache-2.0) at Sources/LiveKit/Net/NetBootstrap.swift:1), so the repository's formatting check will rewrite/fail on them.
Impact: The formatting/lint gate flags these files, blocking a clean build of the change.

Header enforced by .swiftformat

.swiftformat declares --header "/*\n * Copyright {year} LiveKit\n * ... Apache License ... */", and every existing source file (e.g. Sources/LiveKit/Support/Network/WebSocket.swift:1-16) carries that block. All six new files use the abbreviated one-liner instead: Sources/LiveKit/Net/NetBootstrap.swift:1, Sources/LiveKit/Net/LKNetHTTPClient.swift:1, Sources/LiveKit/Net/LKNetWSClient.swift:1, Tests/LiveKitCoreTests/Net/LKNetHTTPClientLiveTests.swift:1, Tests/LiveKitCoreTests/Net/LKNetWSConnectionTests.swift:1, Tests/LiveKitCoreTests/Net/NetBootstrapTests.swift:1, Tests/LiveKitCoreTests/Net/NetFFIRoundTripTests.swift:1.

Suggested change
// Copyright 2026 LiveKit (Apache-2.0)
/*
* Copyright 2026 LiveKit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

internal import LiveKitUniFFI

/// One-time registration of the SDK's transports with `livekit-net`.
/// `setHttpClient`/`setWsClient` are first-registration-wins; a Swift `static let`
/// guarantees this runs exactly once, thread-safe, before the first connection.
enum LKNet {
#if DEBUG
// Swappable forwarding wrappers so FFI-demo tests can inject dummies.
static let httpClient = LKNetHTTPClient()
static let wsClient = LKNetWSClient()
#endif

static let bootstrap: Void = {
#if DEBUG
setHttpClient(c: httpClient)
setWsClient(c: wsClient)
#else
setHttpClient(c: LKNetHTTPClientLive())
setWsClient(c: LKNetWSClientLive())
#endif
}()
}
113 changes: 113 additions & 0 deletions Tests/LiveKitCoreTests/Net/LKNetHTTPClientLiveTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// Copyright 2026 LiveKit (Apache-2.0)
import Foundation
import Testing
@testable import LiveKit
import LiveKitUniFFI

// Uses a dedicated, file-private URLProtocol (not the shared LiveKitTestSupport
// `MockURLProtocol`) so this suite's process-global mock state cannot be reset by
// another suite that also uses `MockURLProtocol` (e.g. `RegionManagerTests`) when
// Swift Testing runs suites in parallel. `.serialized` keeps this suite's own tests
// from racing each other on that state.
@Suite(.serialized)
struct LKNetHTTPClientLiveTests {
private func mockSession() -> URLSession {
let config = URLSessionConfiguration.ephemeral
config.protocolClasses = [LKNetMockURLProtocol.self]
return URLSession(configuration: config)
}

@Test func getMapsResponse() async throws {
LKNetMockURLProtocol.reset()
defer { LKNetMockURLProtocol.reset() }
LKNetMockURLProtocol.setRequestHandler { req in
#expect(req.httpMethod == "GET")
#expect(req.value(forHTTPHeaderField: "x-req") == "1")
return .init(statusCode: 201, headers: ["x-test": "yes"], body: Data("hi".utf8))
}
let client = LKNetHTTPClientLive(session: mockSession())
let resp = try await client.request(method: .get, url: "https://example.test/status",
headers: [Header(name: "x-req", value: "1")], body: nil)
#expect(resp.status == 201)
#expect(resp.body == Data("hi".utf8))
#expect(resp.headers.contains { $0.name.lowercased() == "x-test" && $0.value == "yes" })
}

@Test func timeoutMapsToTransportTimeout() async throws {
LKNetMockURLProtocol.reset()
defer { LKNetMockURLProtocol.reset() }
LKNetMockURLProtocol.setRequestHandler { _ in throw URLError(.timedOut) }
let client = LKNetHTTPClientLive(session: mockSession())
await #expect(throws: TransportError.self) {
_ = try await client.request(method: .get, url: "https://example.test/slow", headers: [], body: nil)
}
}

@Test func forwardingDelegatesToInner() async throws {
LKNetMockURLProtocol.reset()
defer { LKNetMockURLProtocol.reset() }
LKNetMockURLProtocol.setRequestHandler { _ in .init(statusCode: 200, headers: [:], body: Data()) }
let fwd = LKNetHTTPClient(LKNetHTTPClientLive(session: mockSession()))
let resp = try await fwd.request(method: .get, url: "https://example.test/f", headers: [], body: nil)
#expect(resp.status == 200)
}
}

/// Isolated `URLProtocol` for `LKNetHTTPClientLiveTests` only. Its state is process
/// global (as all `URLProtocol` state must be), but no other suite references this
/// class, so it cannot be reset mid-request by a parallel suite. Attached solely via
/// the ephemeral session's `protocolClasses`, so it never intercepts other traffic.
private final class LKNetMockURLProtocol: URLProtocol {
struct Response: Sendable {
let statusCode: Int
let headers: [String: String]
let body: Data
}

private struct State {
var requestHandler: (@Sendable (URLRequest) throws -> Response)?
}

private static let _state = StateSync(State())

static func setRequestHandler(_ handler: (@Sendable (URLRequest) throws -> Response)?) {
_state.mutate { $0.requestHandler = handler }
}

static func reset() {
_state.mutate { $0.requestHandler = nil }
}

override class func canInit(with _: URLRequest) -> Bool { true }

Check failure on line 81 in Tests/LiveKitCoreTests/Net/LKNetHTTPClientLiveTests.swift

View workflow job for this annotation

GitHub Actions / Lint

Prefer `static` over `class` in a final class (static_over_final_class)

override class func canonicalRequest(for request: URLRequest) -> URLRequest { request }

Check failure on line 83 in Tests/LiveKitCoreTests/Net/LKNetHTTPClientLiveTests.swift

View workflow job for this annotation

GitHub Actions / Lint

Prefer `static` over `class` in a final class (static_over_final_class)

override func startLoading() {
guard let handler = Self._state.read({ $0.requestHandler }) else {
client?.urlProtocol(self, didFailWithError: URLError(.badServerResponse))
return
}
guard let url = request.url else {
client?.urlProtocol(self, didFailWithError: URLError(.badURL))
return
}
do {
let mock = try handler(request)
guard let response = HTTPURLResponse(url: url,
statusCode: mock.statusCode,
httpVersion: "HTTP/1.1",
headerFields: mock.headers)
else {
client?.urlProtocol(self, didFailWithError: URLError(.badServerResponse))
return
}
client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed)
client?.urlProtocol(self, didLoad: mock.body)
client?.urlProtocolDidFinishLoading(self)
} catch {
client?.urlProtocol(self, didFailWithError: error)
}
}

override func stopLoading() {}
}
15 changes: 15 additions & 0 deletions Tests/LiveKitCoreTests/Net/LKNetWSConnectionTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2026 LiveKit (Apache-2.0)

Check warning on line 1 in Tests/LiveKitCoreTests/Net/LKNetWSConnectionTests.swift

View workflow job for this annotation

GitHub Actions / Lint

Use specified source file header template for all files. (fileHeader)
import Foundation
import Testing

Check warning on line 3 in Tests/LiveKitCoreTests/Net/LKNetWSConnectionTests.swift

View workflow job for this annotation

GitHub Actions / Lint

Sort and group import statements. (sortImports)
@testable import LiveKit

Check warning on line 4 in Tests/LiveKitCoreTests/Net/LKNetWSConnectionTests.swift

View workflow job for this annotation

GitHub Actions / Lint

Sort and group import statements. (sortImports)

struct LKNetWSConnectionTests {
@Test func decodeDataFrame() {
let d = Data([0x01, 0x02, 0x03])
#expect(LKNetWSConnection.decode(.data(d)) == d)
}

@Test func decodeStringFrameIsUTF8() {
#expect(LKNetWSConnection.decode(.string("hi")) == Data("hi".utf8))
}
}
12 changes: 12 additions & 0 deletions Tests/LiveKitCoreTests/Net/NetBootstrapTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2026 LiveKit (Apache-2.0)

Check warning on line 1 in Tests/LiveKitCoreTests/Net/NetBootstrapTests.swift

View workflow job for this annotation

GitHub Actions / Lint

Use specified source file header template for all files. (fileHeader)
import Testing

Check warning on line 2 in Tests/LiveKitCoreTests/Net/NetBootstrapTests.swift

View workflow job for this annotation

GitHub Actions / Lint

Sort and group import statements. (sortImports)
@testable import LiveKit

Check warning on line 3 in Tests/LiveKitCoreTests/Net/NetBootstrapTests.swift

View workflow job for this annotation

GitHub Actions / Lint

Sort and group import statements. (sortImports)
import LiveKitUniFFI

Check warning on line 4 in Tests/LiveKitCoreTests/Net/NetBootstrapTests.swift

View workflow job for this annotation

GitHub Actions / Lint

Sort and group import statements. (sortImports)

Check warning on line 4 in Tests/LiveKitCoreTests/Net/NetBootstrapTests.swift

View workflow job for this annotation

GitHub Actions / Lint

Insert blank line after import statements. (blankLineAfterImports)

struct NetBootstrapTests {
@Test func bootstrapRegistersTransports() {
_ = LKNet.bootstrap
#expect(hasHttpClient())
#expect(hasWsClient())
}
}
Loading
Loading