本文介绍了适用于APN的Http/2 HttpClient和HPACK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写代码以将通知发送到Apple推送通知服务器(APN).它在文档中说它需要HTTP/HPACK标头压缩.我发现以下代码将HTTP/2与C#httpclient结合使用:

I am writing code to send notifications to the Apple push notification servers (APNs). It says in the documents that it requires HTTP/ HPACK header compression. I found the following code to use HTTP/2 with C# httpclient:

public class Http2CustomHandler : WinHttpHandler
{
    protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
    {
        request.Version = new Version("2.0");
        return base.SendAsync(request, cancellationToken);
    }
}

using (var httpClient = new HttpClient(new Http2CustomHandler()))
{

}

是压缩我将自动添加到HttpClient的标头,还是应该以其他方式添加标头数据?

Does that compress the headers that I will add to the HttpClient automatically or should I add the header data some other way?

推荐答案

是的,它确实压缩了标头.您无需执行任何其他操作.

Yes it does compress the headers. You don't have to do anything extra.

这篇关于适用于APN的Http/2 HttpClient和HPACK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 17:37