From b32c447578767476b0906a199a753d5df00f8b74 Mon Sep 17 00:00:00 2001 From: Ellen Shapiro Date: Tue, 2 Feb 2021 18:01:06 -0600 Subject: [PATCH] Don't send a `Content-Type` header when sending a GET request, which has no body. --- Sources/Apollo/JSONRequest.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/Apollo/JSONRequest.swift b/Sources/Apollo/JSONRequest.swift index 311bda10bf..6e0b9f08bd 100644 --- a/Sources/Apollo/JSONRequest.swift +++ b/Sources/Apollo/JSONRequest.swift @@ -100,6 +100,9 @@ open class JSONRequest: HTTPRequest { if let urlForGet = transformer.createGetURL() { request.url = urlForGet request.httpMethod = GraphQLHTTPMethod.GET.rawValue + + // GET requests shouldn't have a content-type since they do not provide actual content. + request.allHTTPHeaderFields?.removeValue(forKey: "Content-Type") } else { throw GraphQLHTTPRequestError.serializedQueryParamsMessageError }