Http/2 HttpClient and HPACK For APNs

故事扮演 提交于 2020-08-24 10:18:12

问题


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()))
{

}

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


回答1:


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



来源:https://stackoverflow.com/questions/45895845/http-2-httpclient-and-hpack-for-apns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!