gsa: disregard keepalive

This commit is contained in:
Kabir Oberai
2026-09-08 20:57:07 -04:00
Unverified
parent 76b005f6d8
commit 86e47f1127
4 changed files with 53 additions and 13 deletions
@@ -18,6 +18,10 @@ public protocol HTTPClientProtocol: Sendable {
var asOpenAPITransport: ClientTransport { get }
func makeWebSocket(url: URL) async throws -> WebSocketSession
func withEphemeralClient<T>(
perform: (any HTTPClientProtocol) async throws -> T
) async throws -> T
}
extension HTTPClientProtocol {
@@ -41,12 +45,12 @@ extension HTTPClientProtocol {
public func makeRequest(
_ request: HTTPRequest,
body: Data? = nil,
requireHTTPSuccess: Bool = true,
throwOnServerError: Bool = true,
onProgress: @isolated(any) (Double?) -> Void = { _ in }
) async throws -> (response: HTTPResponse, body: Data) {
await onProgress(0)
let (response, responseBody) = try await send(request, body: body.map { HTTPBody($0) })
guard !requireHTTPSuccess || response.status.kind == .successful else {
guard !throwOnServerError || response.status.kind != .serverError else {
let errorBody = (try? await responseBody.collect()) ?? Data()
throw HTTPResponseError(
method: request.method,
@@ -128,6 +132,12 @@ private struct UnimplementedHTTPClient: HTTPClientProtocol, ClientTransport {
return try closure()
}
func withEphemeralClient<T>(
perform: (any HTTPClientProtocol) async throws -> T
) async throws -> T {
try await perform(self)
}
public func makeWebSocket(url: URL) async throws -> any WebSocketSession {
let closure: (URL) async throws -> any WebSocketSession = unimplemented()
return try await closure(url)