From cbb2c06610b439cbdc524d894c8d462bc6df6cb4 Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Tue, 1 Oct 2024 17:30:10 +0300 Subject: [PATCH] Set "Accept : application/json" header (#442) --- .../Gravatar/Network/Services/URLSessionHTTPClient.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sources/Gravatar/Network/Services/URLSessionHTTPClient.swift b/Sources/Gravatar/Network/Services/URLSessionHTTPClient.swift index 8b92954f..05f67f8d 100644 --- a/Sources/Gravatar/Network/Services/URLSessionHTTPClient.swift +++ b/Sources/Gravatar/Network/Services/URLSessionHTTPClient.swift @@ -10,8 +10,12 @@ enum HTTPClientError: Error { struct URLSessionHTTPClient: HTTPClient { private let urlSession: URLSessionProtocol - init(urlSession: URLSessionProtocol = URLSession(configuration: .default)) { - self.urlSession = urlSession + init(urlSession: URLSessionProtocol? = nil) { + let configuration = URLSessionConfiguration.default + configuration.httpAdditionalHeaders = [ + "Accept": "application/json", + ] + self.urlSession = urlSession ?? URLSession(configuration: configuration) } func fetchData(with request: URLRequest) async throws -> (Data, HTTPURLResponse) {