Skip to content

Commit

Permalink
Explicitly setting content header to avoid issues with some GraphQL s…
Browse files Browse the repository at this point in the history
…ervers. (#595)

* Explicitly setting content header to avoid issues with some GraphQL servers. For instance synthetic GraphQL generated out of Azure APIM.
  • Loading branch information
Vivek4Int authored Sep 29, 2023
1 parent 5436fac commit d422bfd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/GraphQL.Client/GraphQLHttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public virtual HttpRequestMessage ToHttpRequestMessage(GraphQLHttpClientOptions
};
message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/graphql-response+json"));
message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
message.Headers.AcceptCharset.Add(new StringWithQualityHeaderValue("utf-8"));
message.Headers.AcceptCharset.Add(new StringWithQualityHeaderValue("utf-8"));

// Explicitly setting content header to avoid issues with some GrahQL servers
message.Content.Headers.ContentType = new MediaTypeHeaderValue(options.MediaType);

if (options.DefaultUserAgentRequestHeader != null)
message.Headers.UserAgent.Add(options.DefaultUserAgentRequestHeader);
Expand Down

0 comments on commit d422bfd

Please sign in to comment.