File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 146146 'http_debug_log_channel ' => env ('FIREBASE_HTTP_DEBUG_LOG_CHANNEL ' , null ),
147147 ],
148148
149+ /**
150+ * ------------------------------------------------------------------------
151+ * HTTP Client Options
152+ * ------------------------------------------------------------------------
153+ *
154+ * Behavior of the HTTP Client performing the API requests
155+ */
156+ 'http_client_options ' => [
157+
158+ /**
159+ * Use a proxy that all API requests should be passed through.
160+ * (default: none)
161+ */
162+ 'proxy ' => env ('FIREBASE_HTTP_CLIENT_PROXY ' , null ),
163+
164+ /**
165+ * Set the maximum amount of seconds (float) that can pass before
166+ * a request is considered timed out
167+ * (default: indefinitely)
168+ */
169+ 'timeout ' => env ('FIREBASE_HTTP_CLIENT_TIMEOUT ' , null ),
170+ ],
171+
149172 /**
150173 * ------------------------------------------------------------------------
151174 * Debug (deprecated)
Original file line number Diff line number Diff line change 77use Illuminate \Contracts \Container \Container ;
88use Kreait \Firebase \Exception \InvalidArgumentException ;
99use Kreait \Firebase \Factory ;
10+ use Kreait \Firebase \Http \HttpClientOptions ;
1011
1112class FirebaseProjectManager
1213{
@@ -101,6 +102,18 @@ protected function configure(string $name): FirebaseProject
101102 );
102103 }
103104
105+ $ options = HttpClientOptions::default ();
106+
107+ if ($ proxy = $ config ['http_client_options ' ]['proxy ' ] ?? null ) {
108+ $ options = $ options ->withProxy ($ proxy );
109+ }
110+
111+ if ($ timeout = $ config ['http_client_options ' ]['timeout ' ] ?? null ) {
112+ $ options = $ options ->withTimeOut ((float ) $ timeout );
113+ }
114+
115+ $ factory = $ factory ->withHttpClientOptions ($ options );
116+
104117 return new FirebaseProject ($ factory , $ config );
105118 }
106119
Original file line number Diff line number Diff line change @@ -280,6 +280,27 @@ public function debug_logging_can_be_configured(): void
280280 $ this ->assertNotNull ($ property ->getValue ($ factory ));
281281 }
282282
283+ /**
284+ * @test
285+ */
286+ public function http_client_options_can_be_configured (): void
287+ {
288+ $ projectName = $ this ->app ->config ->get ('firebase.default ' );
289+ $ this ->app ->config ->set ('firebase.projects. ' .$ projectName .'.http_client_options.proxy ' , 'proxy.domain.tld ' );
290+ $ this ->app ->config ->set ('firebase.projects. ' .$ projectName .'.http_client_options.timeout ' , 1.23 );
291+
292+ $ factory = $ this ->factoryForProject ($ projectName );
293+
294+ $ property = ReflectionObject::createFromInstance ($ factory )->getProperty ('httpClientOptions ' );
295+ $ property ->setVisibility (\ReflectionProperty::IS_PUBLIC );
296+
297+ /** @var Firebase\Http\HttpClientOptions $httpClientOptions */
298+ $ httpClientOptions = $ property ->getValue ($ factory );
299+
300+ $ this ->assertSame ('proxy.domain.tld ' , $ httpClientOptions ->proxy ());
301+ $ this ->assertSame (1.23 , $ httpClientOptions ->timeout ());
302+ }
303+
283304 /**
284305 * @test
285306 */
You can’t perform that action at this time.
0 commit comments