Skip to content

Commit

Permalink
don't override Content-Type header if already set in Resource headers (
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoimer authored Jan 16, 2023
1 parent d0ae25a commit cf977d1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/Fetch/Network/Resource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ open class Resource<T: Decodable>: CacheableResource {
if let body = body {
let (data, contentType) = try encode(body: body)
urlRequest.httpBody = data
if let contentType = contentType {
urlRequest.addValue(contentType.description, forHTTPHeaderField: "Content-Type")

if headers["Content-Type"] == nil,
let contentType = contentType {
urlRequest.addValue(contentType.description, forHTTPHeaderField: "Content-Type")
}
}

Expand Down

0 comments on commit cf977d1

Please sign in to comment.