diff --git a/src/LaunchDarkly/Impl/Util.php b/src/LaunchDarkly/Impl/Util.php index 05649307..0cfcefa0 100644 --- a/src/LaunchDarkly/Impl/Util.php +++ b/src/LaunchDarkly/Impl/Util.php @@ -138,7 +138,7 @@ public static function defaultHeaders(string $sdkKey, array $options): array public static function eventHeaders(string $sdkKey, array $options): array { $headers = Util::defaultHeaders($sdkKey, $options); - $headers['X-LaunchDarkly-Event-Schema'] = EventPublisher::CURRENT_SCHEMA_VERSION; + $headers['X-LaunchDarkly-Event-Schema'] = (string) EventPublisher::CURRENT_SCHEMA_VERSION; // Only the presence of this header is important. We encode a string // value of 'true' to ensure it isn't dropped along the way. $headers['X-LaunchDarkly-Unsummarized'] = 'true'; diff --git a/tests/Impl/UtilTest.php b/tests/Impl/UtilTest.php index dd671246..640b0aa6 100644 --- a/tests/Impl/UtilTest.php +++ b/tests/Impl/UtilTest.php @@ -26,4 +26,16 @@ public function testNonTrivialSamplingRatio(): void $this->assertEquals(504, $counts); } + + public function testEventHeaderValuesAreStrings(): void + { + // guzzlehttp/guzzle 7.11+ deprecates non-string header values and + // guzzle 8.0 will reject them, so every event header value must be a + // string. See https://github.com/launchdarkly/php-server-sdk/issues/246 + $headers = Util::eventHeaders('sdk-key', []); + + foreach ($headers as $name => $value) { + $this->assertIsString($value, "header '$name' should be a string"); + } + } }