Skip to content

Optimized the type of Content-Type to string from int for Hyperf\Tracer\Adapter\Reporter\HttpClientFactory. - #7791

Merged
limingxinleo merged 6 commits into
hyperf:3.1from
fly777777:patch-1
Aug 7, 2026
Merged

limingxinleo merged 6 commits into
hyperf:3.1from
fly777777:patch-1

Conversation

@fly777777

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Guzzle 7.11 deprecates non-string request header values, and Guzzle 8 requires header values to be strings or non-empty arrays. The Zipkin HTTP reporter currently assigns the integer returned by strlen($payload) to Content-Length.

In coroutine workloads, this deprecation may be captured by another active error handler and surface as an unrelated stream read failure.

What is changed and how does it work?

Cast the payload length to a string before passing the headers to Guzzle:

'Content-Length' => (string) strlen($payload),

Tests

Added HttpClientFactoryTest::testContentLengthHeaderIsString to verify the reporter sends Content-Length as a string.

  • Before the fix: Failed asserting that 7 is identical to '7'.
  • After the fix: tracer test suite passes with 5 tests and 5 assertions on PHP 8.2.28 with Swoole.
  • PHPStan reports no errors.
  • PHP CS Fixer reports no required changes.

fly777777 and others added 5 commits July 31, 2026 11:51
Cast Content-Length to string for Guzzle 7.11+ compatibility.
Verify the Zipkin reporter sends Content-Length as a string.
@limingxinleo limingxinleo changed the title Fixed tracer Content-Length header type Optimized the type of Content-Type to string from int for Hyperf\Tracer\Adapter\Reporter\HttpClientFactory. Aug 7, 2026
@limingxinleo
limingxinleo merged commit 1c94523 into hyperf:3.1 Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants