diff --git a/Src/Recombee.ApiClient/RecombeeClient.cs b/Src/Recombee.ApiClient/RecombeeClient.cs
index 5746e6e..6e86d4b 100644
--- a/Src/Recombee.ApiClient/RecombeeClient.cs
+++ b/Src/Recombee.ApiClient/RecombeeClient.cs
@@ -19,6 +19,7 @@ public partial class RecombeeClient
readonly byte[] secretTokenBytes;
readonly bool useHttpsAsDefault;
+ private readonly HttpMessageHandler handler;
readonly string hostUri = "rapi.recombee.com";
@@ -31,11 +32,13 @@ public partial class RecombeeClient
/// ID of the database.
/// Corresponding secret token.
/// If true, all requests are sent using HTTPS
- public RecombeeClient(string databaseId, string secretToken, bool useHttpsAsDefault = true)
+ /// Optional message handler for the http client
+ public RecombeeClient(string databaseId, string secretToken, bool useHttpsAsDefault = true, HttpMessageHandler handler = null)
{
this.databaseId = databaseId;
this.secretTokenBytes = Encoding.ASCII.GetBytes(secretToken);
this.useHttpsAsDefault = useHttpsAsDefault;
+ this.handler = handler;
this.httpClient = createHttpClient();
var envHostUri = Environment.GetEnvironmentVariable("RAPI_URI");
@@ -45,7 +48,7 @@ public RecombeeClient(string databaseId, string secretToken, bool useHttpsAsDefa
private HttpClient createHttpClient()
{
- var httpClient = new HttpClient();
+ var httpClient = handler == null ? new HttpClient() : new HttpClient(handler);
httpClient.DefaultRequestHeaders.Add("User-Agent", "recombee-.net-api-client/2.4.1");
return httpClient;
}