-
-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default http request version and policy (#6641)
- Loading branch information
1 parent
e92bc8d
commit 6a3893e
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/HotChocolate/AspNetCore/test/Transport.Http.Tests/GraphQLHttpClientConfigurationTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Net; | ||
using static HotChocolate.AspNetCore.Tests.Utilities.TestServerExtensions; | ||
|
||
namespace HotChocolate.Transport.Http.Tests; | ||
|
||
public class GraphQLHttpClientConfigurationTests | ||
{ | ||
[Fact] | ||
public async Task DefaultRequestVersion() | ||
{ | ||
var httpClient = new HttpClient(new TestHttpMessageHandler( | ||
request => | ||
{ | ||
Assert.Equal(HttpVersion.Version20, request.Version); | ||
Assert.Equal(HttpVersionPolicy.RequestVersionOrHigher, request.VersionPolicy); | ||
return new(); | ||
} | ||
)) | ||
{ | ||
DefaultRequestVersion = HttpVersion.Version20, | ||
DefaultVersionPolicy = HttpVersionPolicy.RequestVersionOrHigher, | ||
}; | ||
|
||
var client = GraphQLHttpClient.Create(httpClient, true); | ||
await client.SendAsync(new("{ __typename }", new(CreateUrl(default))), default); | ||
} | ||
|
||
class TestHttpMessageHandler(Func<HttpRequestMessage, HttpResponseMessage> sender) : HttpMessageHandler | ||
{ | ||
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | ||
{ | ||
return Task.FromResult(sender.Invoke(request)); | ||
} | ||
} | ||
} |