问题
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