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

supabase / supabase-swift / 17238365990

26 Aug 2025 12:38PM UTC coverage: 48.936% (-28.5%) from 77.386%
17238365990

Pull #781

github

web-flow
Merge 95ac7642e into e4d8c3718
Pull Request #781: RFC: Migrate HTTP networking from URLSession to Alamofire

287 of 986 new or added lines in 26 files covered. (29.11%)

1397 existing lines in 30 files now uncovered.

3448 of 7046 relevant lines covered (48.94%)

5.24 hits per line

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

78.0
/Sources/Helpers/HTTP/HTTPFields.swift
1
import Alamofire
2
import HTTPTypes
3

4
extension HTTPFields {
5
  package init(_ dictionary: [String: String]) {
46✔
6
    self.init(dictionary.map { .init(name: .init($0.key)!, value: $0.value) })
74✔
7
  }
46✔
8

9
  package var dictionary: [String: String] {
17✔
10
    let keyValues = self.map {
96✔
11
      ($0.name.rawName, $0.value)
96✔
12
    }
96✔
13

17✔
14
    return .init(keyValues, uniquingKeysWith: { $1 })
17✔
15
  }
17✔
16

17
  package mutating func merge(with other: Self) {
1✔
18
    for field in other {
6✔
19
      self[field.name] = field.value
6✔
20
    }
6✔
21
  }
1✔
22

23
  package func merging(with other: Self) -> Self {
35✔
24
    var copy = self
35✔
25

35✔
26
    for field in other {
35✔
27
      copy[field.name] = field.value
20✔
28
    }
35✔
29

35✔
30
    return copy
35✔
31
  }
35✔
32

33
}
34

35
extension HTTPField.Name {
36
  package static let xClientInfo = HTTPField.Name("X-Client-Info")!
37
  package static let xRegion = HTTPField.Name("x-region")!
38
  package static let xRelayError = HTTPField.Name("x-relay-error")!
39
}
40

41
extension HTTPHeaders {
NEW
42
  package func merging(with other: Self) -> Self {
×
NEW
43
    var copy = self
×
NEW
44

×
NEW
45
    for field in other {
×
NEW
46
      copy[field.name] = field.value
×
NEW
47
    }
×
NEW
48

×
NEW
49
    return copy
×
NEW
50
  }
×
51

52
  /// Append or update a value in header.
53
  ///
54
  /// Example:
55
  /// ```swift
56
  /// var headers: HTTPHeaders = [
57
  ///   "Prefer": "count=exact,return=representation"
58
  /// ]
59
  ///
60
  /// headers.appendOrUpdate("Prefer", value: "return=minimal")
61
  /// #expect(headers == ["Prefer": "count=exact,return=minimal"]
62
  /// ```
63
  package mutating func appendOrUpdate(
64
    _ name: String,
65
    value: String,
66
    separator: String = ","
67
  ) {
3✔
68
    if let currentValue = self[name] {
3✔
69
      var components = currentValue.components(separatedBy: separator)
1✔
70

1✔
71
      if let key = value.split(separator: "=").first,
1✔
72
        let index = components.firstIndex(where: { $0.hasPrefix("\(key)=") })
1✔
73
      {
1✔
74
        components[index] = value
1✔
75
      } else {
1✔
76
        components.append(value)
×
77
      }
×
78

1✔
79
      self[name] = components.joined(separator: separator)
1✔
80
    } else {
2✔
81
      self[name] = value
2✔
82
    }
2✔
83
  }
3✔
84
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc