• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / supabase-swift / 23863966727

01 Apr 2026 06:19PM UTC coverage: 78.695% (-1.6%) from 80.282%
23863966727

Pull #917

github

web-flow
feat(helpers): add _HTTPClient (#942)

* feat(helpers): add _HTTPClient with RequestBody and separate query/body params

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(helpers): add TokenProvider support to _HTTPClient

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(helpers): stream UInt8 bytes instead of single-byte Data chunks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(helpers): add FoundationNetworking import for Linux and Sendable conformance to RequestBody

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(helpers): guard fetchStream behind canImport(Darwin) — URLSession.bytes unavailable on Linux

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(helpers): use @autoclosure @Sendable for RequestBody to satisfy Sendable without @unchecked

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(tests): resolve Sendable and actor-isolation errors in PostgREST and Storage tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Pull Request #917: feat!: v3

101 of 286 new or added lines in 25 files covered. (35.31%)

4 existing lines in 2 files now uncovered.

6379 of 8106 relevant lines covered (78.69%)

27.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.41
/Sources/Helpers/HTTP/HTTPRequest.swift
1
//
2
//  HTTPRequest.swift
3
//
4
//
5
//  Created by Guilherme Souza on 23/04/24.
6
//
7

8
import Foundation
9
import HTTPTypes
10

11
#if canImport(FoundationNetworking)
12
  import FoundationNetworking
13
#endif
14

15
package struct HTTPRequest: Sendable {
16
  package var url: URL
17
  package var method: HTTPTypes.HTTPRequest.Method
18
  package var query: [URLQueryItem]
19
  package var headers: HTTPFields
20
  package var body: Data?
21
  package var timeoutInterval: TimeInterval
22

23
  package init(
24
    url: URL,
25
    method: HTTPTypes.HTTPRequest.Method,
26
    query: [URLQueryItem] = [],
27
    headers: HTTPFields = [:],
28
    body: Data? = nil,
29
    timeoutInterval: TimeInterval = 60
30
  ) {
296✔
31
    self.url = url
296✔
32
    self.method = method
296✔
33
    self.query = query
296✔
34
    self.headers = headers
296✔
35
    self.body = body
296✔
36
    self.timeoutInterval = timeoutInterval
296✔
37
  }
296✔
38

39
  package init?(
40
    urlString: String,
41
    method: HTTPTypes.HTTPRequest.Method,
42
    query: [URLQueryItem] = [],
43
    headers: HTTPFields = [:],
44
    body: Data? = nil,
45
    timeoutInterval: TimeInterval = 60
46
  ) {
×
47
    guard let url = URL(string: urlString) else { return nil }
×
NEW
48
    self.init(
×
NEW
49
      url: url, method: method, query: query, headers: headers, body: body,
×
NEW
50
      timeoutInterval: timeoutInterval)
×
UNCOV
51
  }
×
52

53
  package var urlRequest: URLRequest {
294✔
54
    var urlRequest = URLRequest(
294✔
55
      url: query.isEmpty ? url : url.appendingQueryItems(query), timeoutInterval: timeoutInterval)
294✔
56
    urlRequest.httpMethod = method.rawValue
294✔
57
    urlRequest.allHTTPHeaderFields = .init(headers.map { ($0.name.rawName, $0.value) }) { $1 }
963✔
58
    urlRequest.httpBody = body
294✔
59

294✔
60
    if urlRequest.httpBody != nil, urlRequest.value(forHTTPHeaderField: "Content-Type") == nil {
294✔
61
      urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
81✔
62
    }
81✔
63

294✔
64
    return urlRequest
294✔
65
  }
294✔
66
}
67

68
extension [URLQueryItem] {
69
  package mutating func appendOrUpdate(_ queryItem: URLQueryItem) {
94✔
70
    if let index = firstIndex(where: { $0.name == queryItem.name }) {
94✔
71
      self[index] = queryItem
×
72
    } else {
94✔
73
      self.append(queryItem)
94✔
74
    }
94✔
75
  }
94✔
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc