Skip to content

Commit

Permalink
Set "Accept : application/json" header (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
pinarol authored Oct 1, 2024
1 parent 2cf737b commit cbb2c06
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Sources/Gravatar/Network/Services/URLSessionHTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit cbb2c06

Please sign in to comment.