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

supabase / supabase-swift / 17305938011

28 Aug 2025 07:29PM UTC coverage: 67.525% (-9.9%) from 77.386%
17305938011

Pull #781

github

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

992 of 1136 new or added lines in 27 files covered. (87.32%)

731 existing lines in 19 files now uncovered.

4483 of 6639 relevant lines covered (67.53%)

25.74 hits per line

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

0.0
/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
UNCOV
30
  ) {
×
UNCOV
31
    self.url = url
×
UNCOV
32
    self.method = method
×
UNCOV
33
    self.query = query
×
UNCOV
34
    self.headers = headers
×
UNCOV
35
    self.body = body
×
UNCOV
36
    self.timeoutInterval = timeoutInterval
×
UNCOV
37
  }
×
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

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

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

×
UNCOV
64
    return urlRequest
×
UNCOV
65
  }
×
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

© 2026 Coveralls, Inc