小编Rob*_*t M的帖子

在.Net中将HTTP 2与HttpClient一起使用

我正在尝试通过HTTP 2.0请求数据。我正在使用.Net Core 2.2中的HttpClient。我使用Windows 10,但将在生产环境中的Linux上运行。问题在于响应上的版本似乎总是“ 1.1”。我做错了什么?

using (var client = new HttpClient())
{
    using (var request = new HttpRequestMessage(new HttpMethod("GET"),
    "https://duckduckgo.com/"
    ))
    {
        request.Version = new Version(2, 0);
        var response = await client.SendAsync(request);

        Console.WriteLine(response.Version);
    }
}
Run Code Online (Sandbox Code Playgroud)

http dotnet-httpclient http2 .net-core asp.net-core

5
推荐指数
2
解决办法
4763
查看次数

标签 统计

.net-core ×1

asp.net-core ×1

dotnet-httpclient ×1

http ×1

http2 ×1