Skip to content

Commit 9d9f883

Browse files
committed
use AppOptions.HttpClientFactory throughout api
1 parent 2fad40f commit 9d9f883

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

FirebaseAdmin/FirebaseAdmin/AppOptions.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ namespace FirebaseAdmin
2626
/// </summary>
2727
public sealed class AppOptions
2828
{
29+
private HttpClientFactory httpClientFactory;
30+
2931
/// <summary>
3032
/// Initializes a new instance of the <see cref="AppOptions"/> class.
3133
/// </summary>
@@ -36,7 +38,7 @@ internal AppOptions(AppOptions options)
3638
this.Credential = options.Credential;
3739
this.ProjectId = options.ProjectId;
3840
this.ServiceAccountId = options.ServiceAccountId;
39-
this.ClientFactory = options.ClientFactory;
41+
this.HttpClientFactory = options.HttpClientFactory;
4042
}
4143

4244
/// <summary>
@@ -62,8 +64,26 @@ internal AppOptions(AppOptions options)
6264
public string ServiceAccountId { get; set; }
6365

6466
/// <summary>
65-
/// Gets or sets the HttpClientFactory to use when making Firebase requirests.
67+
/// Gets or sets the HttpClientFactory to use when making Firebase requests.
6668
/// </summary>
67-
public HttpClientFactory ClientFactory { get; set; } = new HttpClientFactory();
69+
public HttpClientFactory HttpClientFactory
70+
{
71+
get
72+
{
73+
if (this.httpClientFactory != null)
74+
{
75+
return this.httpClientFactory;
76+
}
77+
else
78+
{
79+
return new HttpClientFactory();
80+
}
81+
}
82+
83+
set
84+
{
85+
this.httpClientFactory = value;
86+
}
87+
}
6888
}
6989
}

FirebaseAdmin/FirebaseAdmin/Auth/FirebaseTokenFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ public static FirebaseTokenFactory Create(FirebaseApp app)
8585
{
8686
// If no service account ID is specified, attempt to discover one and invoke the
8787
// IAM service with it.
88-
signer = new IAMSigner(new HttpClientFactory(), app.Options.Credential);
88+
signer = new IAMSigner(app.Options.HttpClientFactory, app.Options.Credential);
8989
}
9090
else
9191
{
9292
// If a service account ID is specified, invoke the IAM service with it.
9393
signer = new FixedAccountIAMSigner(
94-
new HttpClientFactory(), app.Options.Credential, app.Options.ServiceAccountId);
94+
app.Options.HttpClientFactory, app.Options.Credential, app.Options.ServiceAccountId);
9595
}
9696

9797
return new FirebaseTokenFactory(signer, SystemClock.Default);

FirebaseAdmin/FirebaseAdmin/Auth/FirebaseTokenVerifier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ internal static FirebaseTokenVerifier CreateIDTokenVerifier(FirebaseApp app)
8585
}
8686

8787
var keySource = new HttpPublicKeySource(
88-
IdTokenCertUrl, SystemClock.Default, new HttpClientFactory());
88+
IdTokenCertUrl, SystemClock.Default, app.Options.HttpClientFactory);
8989
var args = new FirebaseTokenVerifierArgs()
9090
{
9191
ProjectId = projectId,

FirebaseAdmin/FirebaseAdmin/Auth/FirebaseUserManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019, Google Inc. All rights reserved.
1+
// Copyright 2019, Google Inc. All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@ public static FirebaseUserManager Create(FirebaseApp app)
5252
{
5353
var args = new FirebaseUserManagerArgs
5454
{
55-
ClientFactory = new HttpClientFactory(),
55+
ClientFactory = app.Options.HttpClientFactory,
5656
Credential = app.Options.Credential,
5757
ProjectId = app.GetProjectId(),
5858
};

FirebaseAdmin/FirebaseAdmin/Messaging/FirebaseMessaging.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public sealed class FirebaseMessaging : IFirebaseService
3030
private FirebaseMessaging(FirebaseApp app)
3131
{
3232
this.messagingClient = new FirebaseMessagingClient(
33-
app.Options.ClientFactory, app.Options.Credential, app.GetProjectId());
33+
app.Options.HttpClientFactory, app.Options.Credential, app.GetProjectId());
3434
}
3535

3636
/// <summary>

0 commit comments

Comments
 (0)