1818using System . IO ;
1919using System . Linq ;
2020using System . Net ;
21+ using System . Net . Http ;
2122using System . Threading ;
2223using System . Threading . Tasks ;
2324using Serilog . Core ;
@@ -73,7 +74,7 @@ public EventCollectorSink(
7374 formatProvider ,
7475 renderTemplate )
7576 {
76- }
77+ }
7778
7879 /// <summary>
7980 /// Creates a new instance of the sink
@@ -89,6 +90,7 @@ public EventCollectorSink(
8990 /// <param name="source">The source of the event</param>
9091 /// <param name="sourceType">The source type of the event</param>
9192 /// <param name="host">The host of the event</param>
93+ /// <param name="messageHandler">The handler used to send HTTP requests</param>
9294 public EventCollectorSink (
9395 string splunkHost ,
9496 string eventCollectorToken ,
@@ -100,7 +102,8 @@ public EventCollectorSink(
100102 int batchIntervalInSeconds ,
101103 int batchSizeLimit ,
102104 IFormatProvider formatProvider = null ,
103- bool renderTemplate = true )
105+ bool renderTemplate = true ,
106+ HttpMessageHandler messageHandler = null )
104107 {
105108 _uriPath = uriPath ;
106109 _splunkHost = splunkHost ;
@@ -109,7 +112,9 @@ public EventCollectorSink(
109112 _batchSizeLimitLimit = batchSizeLimit ;
110113
111114 var batchInterval = TimeSpan . FromSeconds ( batchIntervalInSeconds ) ;
112- _httpClient = new EventCollectorClient ( eventCollectorToken ) ;
115+ _httpClient = messageHandler != null
116+ ? new EventCollectorClient ( eventCollectorToken , messageHandler )
117+ : new EventCollectorClient ( eventCollectorToken ) ;
113118
114119 var cancellationToken = new CancellationToken ( ) ;
115120
0 commit comments