• 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

61.76
/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
  ) {
28✔
31
    self.url = url
28✔
32
    self.method = method
28✔
33
    self.query = query
28✔
34
    self.headers = headers
28✔
35
    self.body = body
28✔
36
    self.timeoutInterval = timeoutInterval
28✔
37
  }
28✔
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 {
28✔
54
    var urlRequest = URLRequest(
28✔
55
      url: query.isEmpty ? url : url.appendingQueryItems(query), timeoutInterval: timeoutInterval)
28✔
56
    urlRequest.httpMethod = method.rawValue
28✔
57
    urlRequest.allHTTPHeaderFields = .init(headers.map { ($0.name.rawName, $0.value) }) { $1 }
68✔
58
    urlRequest.httpBody = body
28✔
59

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

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

68
extension [URLQueryItem] {
UNCOV
69
  package mutating func appendOrUpdate(_ queryItem: URLQueryItem) {
×
UNCOV
70
    if let index = firstIndex(where: { $0.name == queryItem.name }) {
×
71
      self[index] = queryItem
×
UNCOV
72
    } else {
×
UNCOV
73
      self.append(queryItem)
×
UNCOV
74
    }
×
UNCOV
75
  }
×
76
}
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