mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-09 00:28:53 +01:00
Fix concurrency warnings in Transport.
This commit is contained in:
parent
6053c58334
commit
46645f700a
@ -123,19 +123,19 @@ public protocol Transport: Sendable {
|
||||
@discardableResult
|
||||
func send(request: URLRequest) async throws -> (HTTPURLResponse, Data?)
|
||||
|
||||
func send(request: URLRequest, completion: @escaping (Result<(HTTPURLResponse, Data?), Error>) -> Void)
|
||||
|
||||
func send(request: URLRequest, completion: @escaping @Sendable (Result<(HTTPURLResponse, Data?), Error>) -> Void)
|
||||
|
||||
/// Sends URLRequest that doesn't require any result information.
|
||||
func send(request: URLRequest, method: String) async throws
|
||||
|
||||
func send(request: URLRequest, method: String, completion: @escaping (Result<Void, Error>) -> Void)
|
||||
|
||||
func send(request: URLRequest, method: String, completion: @escaping @Sendable (Result<Void, Error>) -> Void)
|
||||
|
||||
/// Sends URLRequest with a data payload and returns the HTTP headers and the data payload.
|
||||
@discardableResult
|
||||
func send(request: URLRequest, method: String, payload: Data) async throws -> (HTTPURLResponse, Data?)
|
||||
|
||||
func send(request: URLRequest, method: String, payload: Data, completion: @escaping (Result<(HTTPURLResponse, Data?), Error>) -> Void)
|
||||
|
||||
func send(request: URLRequest, method: String, payload: Data, completion: @escaping @Sendable (Result<(HTTPURLResponse, Data?), Error>) -> Void)
|
||||
|
||||
}
|
||||
|
||||
extension URLSession: Transport {
|
||||
@ -162,7 +162,7 @@ extension URLSession: Transport {
|
||||
}
|
||||
}
|
||||
|
||||
public func send(request: URLRequest, completion: @escaping (Result<(HTTPURLResponse, Data?), Error>) -> Void) {
|
||||
public func send(request: URLRequest, completion: @escaping @Sendable (Result<(HTTPURLResponse, Data?), Error>) -> Void) {
|
||||
let task = self.dataTask(with: request) { (data, response, error) in
|
||||
DispatchQueue.main.async {
|
||||
if let error = error {
|
||||
@ -198,8 +198,8 @@ extension URLSession: Transport {
|
||||
}
|
||||
}
|
||||
|
||||
public func send(request: URLRequest, method: String, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
|
||||
public func send(request: URLRequest, method: String, completion: @escaping @Sendable (Result<Void, Error>) -> Void) {
|
||||
|
||||
var sendRequest = request
|
||||
sendRequest.httpMethod = method
|
||||
|
||||
@ -238,7 +238,7 @@ extension URLSession: Transport {
|
||||
}
|
||||
}
|
||||
|
||||
public func send(request: URLRequest, method: String, payload: Data, completion: @escaping (Result<(HTTPURLResponse, Data?), Error>) -> Void) {
|
||||
public func send(request: URLRequest, method: String, payload: Data, completion: @escaping @Sendable (Result<(HTTPURLResponse, Data?), Error>) -> Void) {
|
||||
|
||||
var sendRequest = request
|
||||
sendRequest.httpMethod = method
|
||||
|
@ -10,7 +10,7 @@ import Foundation
|
||||
|
||||
extension Transport {
|
||||
|
||||
public func send<R: Decodable>(request: URLRequest, resultType: R.Type, dateDecoding: JSONDecoder.DateDecodingStrategy = .iso8601, keyDecoding: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys) async throws -> (HTTPURLResponse, R?) {
|
||||
public func send<R: Decodable & Sendable>(request: URLRequest, resultType: R.Type, dateDecoding: JSONDecoder.DateDecodingStrategy = .iso8601, keyDecoding: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys) async throws -> (HTTPURLResponse, R?) {
|
||||
|
||||
try await withCheckedThrowingContinuation { continuation in
|
||||
self.send(request: request, resultType: resultType, dateDecoding: dateDecoding, keyDecoding: keyDecoding) { result in
|
||||
@ -27,8 +27,8 @@ extension Transport {
|
||||
/**
|
||||
Sends an HTTP get and returns JSON object(s)
|
||||
*/
|
||||
public func send<R: Decodable>(request: URLRequest, resultType: R.Type, dateDecoding: JSONDecoder.DateDecodingStrategy = .iso8601, keyDecoding: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys, completion: @escaping (Result<(HTTPURLResponse, R?), Error>) -> Void) {
|
||||
|
||||
public func send<R: Decodable & Sendable>(request: URLRequest, resultType: R.Type, dateDecoding: JSONDecoder.DateDecodingStrategy = .iso8601, keyDecoding: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys, completion: @escaping @Sendable (Result<(HTTPURLResponse, R?), Error>) -> Void) {
|
||||
|
||||
send(request: request) { result in
|
||||
DispatchQueue.main.async {
|
||||
|
||||
@ -69,8 +69,8 @@ extension Transport {
|
||||
/**
|
||||
Sends the specified HTTP method with a JSON payload.
|
||||
*/
|
||||
public func send<P: Encodable>(request: URLRequest, method: String, payload: P, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
|
||||
public func send<P: Encodable>(request: URLRequest, method: String, payload: P, completion: @escaping @Sendable (Result<Void, Error>) -> Void) {
|
||||
|
||||
var postRequest = request
|
||||
postRequest.addValue("application/json; charset=utf-8", forHTTPHeaderField: HTTPRequestHeader.contentType)
|
||||
|
||||
@ -97,7 +97,7 @@ extension Transport {
|
||||
/**
|
||||
Sends the specified HTTP method with a JSON payload and returns JSON object(s).
|
||||
*/
|
||||
public func send<P: Encodable, R: Decodable>(request: URLRequest, method: String, payload: P, resultType: R.Type, dateDecoding: JSONDecoder.DateDecodingStrategy = .iso8601, keyDecoding: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys, completion: @escaping (Result<(HTTPURLResponse, R?), Error>) -> Void) {
|
||||
public func send<P: Encodable, R: Decodable>(request: URLRequest, method: String, payload: P, resultType: R.Type, dateDecoding: JSONDecoder.DateDecodingStrategy = .iso8601, keyDecoding: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys, completion: @escaping @Sendable (Result<(HTTPURLResponse, R?), Error>) -> Void) {
|
||||
|
||||
var postRequest = request
|
||||
postRequest.addValue("application/json; charset=utf-8", forHTTPHeaderField: HTTPRequestHeader.contentType)
|
||||
@ -154,7 +154,7 @@ extension Transport {
|
||||
/**
|
||||
Sends the specified HTTP method with a Raw payload and returns JSON object(s).
|
||||
*/
|
||||
public func send<R: Decodable>(request: URLRequest, method: String, data: Data, resultType: R.Type, dateDecoding: JSONDecoder.DateDecodingStrategy = .iso8601, keyDecoding: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys, completion: @escaping (Result<(HTTPURLResponse, R?), Error>) -> Void) {
|
||||
public func send<R: Decodable>(request: URLRequest, method: String, data: Data, resultType: R.Type, dateDecoding: JSONDecoder.DateDecodingStrategy = .iso8601, keyDecoding: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys, completion: @escaping @Sendable (Result<(HTTPURLResponse, R?), Error>) -> Void) {
|
||||
|
||||
send(request: request, method: method, payload: data) { result in
|
||||
DispatchQueue.main.async {
|
||||
|
Loading…
x
Reference in New Issue
Block a user