diff --git a/HelloDotNet/Hello.cs b/HelloDotNet/Hello.cs
index aa34268..1ec15b4 100644
--- a/HelloDotNet/Hello.cs
+++ b/HelloDotNet/Hello.cs
@@ -1,10 +1,31 @@
using System;
+using System.Net;
+using System.Net.Http;
+using System.Threading;
using System.Threading.Tasks;
using LaunchDarkly.Sdk;
using LaunchDarkly.Sdk.Server;
+using LaunchDarkly.Sdk.Server.Integrations;
namespace HelloDotNet
{
+ ///
+ /// A delegating handler that sets the HTTP version to 2.0 on all outgoing requests.
+ /// This can be used with the LaunchDarkly SDK's HttpConfigurationBuilder.MessageHandler()
+ /// to force all SDK HTTP traffic to use HTTP/2.
+ ///
+ class Http2Handler : DelegatingHandler
+ {
+ public Http2Handler(HttpMessageHandler innerHandler) : base(innerHandler) { }
+
+ protected override Task SendAsync(
+ HttpRequestMessage request, CancellationToken cancellationToken)
+ {
+ request.Version = HttpVersion.Version20;
+ return base.SendAsync(request, cancellationToken);
+ }
+ }
+
class Hello
{
public static void ShowBanner(){
@@ -36,7 +57,16 @@ static void Main(string[] args)
Environment.Exit(1);
}
- var ldConfig = Configuration.Default(SdkKey);
+ // Configure the SDK to use HTTP/2 by providing a custom message handler
+ // that sets the HTTP version on every outgoing request.
+ var handler = new Http2Handler(new SocketsHttpHandler());
+
+ var ldConfig = Configuration.Builder(SdkKey)
+ .Http(
+ Components.HttpConfiguration()
+ .MessageHandler(handler)
+ )
+ .Build();
var client = new LdClient(ldConfig);