Skip to content

Conversation

@katrielt
Copy link

@katrielt katrielt commented Jan 20, 2026

This patch modifies the HTTP client to omit the port number from the
Host header when using standard HTTP (port 80), similar to how HTTPS
(port 443) is already handled. This ensures compatibility with servers
that reject Host headers containing the default port, such as the
GCP Metadata Server concealment proxy in certain environments (e.g.
Cloud Run).

Addresses #11323


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • [N/A] Example configuration file for the change

  • [N/A] Debug log output from testing the change

  • [N/A] Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A ] Run local packaging test showing all targets (including any new ones) build.
  • [N/A ] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • [N/A ] Documentation required for this feature

Backporting

  • [N/A] Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • Bug Fixes

    • Host header formatting updated to omit default ports for both HTTP (80) and HTTPS (443), including proper IPv6 bracket handling.
  • Tests

    • Added and updated tests to cover Host header behavior for standard (no-port) and non-standard ports (e.g., 8080).

✏️ Tip: You can customize this high-level summary in your review settings.

  This patch modifies the HTTP client to omit the port number from the
  Host header when using standard HTTP (port 80), similar to how HTTPS
  (port 443) is already handled. This ensures compatibility with servers
  that reject Host headers containing the default port, such as the
  GCP Metadata Server concealment proxy in certain environments (e.g.
  Cloud Run).

Signed-off-by: Katriel Traum <katriel@google.com>
Implement tests to check new use cases

Signed-off-by: Katriel Traum <katriel@google.com>
@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

Updates Host header logic to treat HTTP default port 80 like HTTPS default port 443 (omit the port in Host when using the default). Adds a flag to detect HTTP default port and adjusts IPv6 bracket and port-inclusion formatting; tests updated/added accordingly.

Changes

Cohort / File(s) Summary
HTTP Client Core Logic
src/flb_http_client.c
Added is_http_default_port flag. Updated Host header construction to omit port when using default HTTP (80) or HTTPS (443). Adjusted IPv6 bracket handling and conditional port formatting.
HTTP Client Tests
tests/internal/http_client.c
Modified tests to default to port 8080 in some cases, updated expectation for port-80 omission, added test_http_non_standard_port_host_header() to assert :8080 inclusion, and registered the new test in TEST_LIST.

Sequence Diagram(s)

(omitted — changes are localized header-format logic and tests, not cross-component control-flow requiring a sequence diagram)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • edsiper
  • cosmo0920

Poem

🐰 I nibbled bytes and found a lore,
Port eighty now hops out the door,
Brackets snug for IPv6 delight,
Host looks tidy, port-less and light,
Hooray — the headers are just right! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: omitting default port 80 from Host headers in HTTP client, which is the primary purpose of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/flb_http_client.c (1)

631-668: Update tests to reflect that default HTTP/HTTPS ports are now omitted from Host headers.

The code change omits the default port (80 for HTTP, 443 for HTTPS) from the Host header. However, test_http_add_get_header expects "127.0.0.1:80" but will now receive "127.0.0.1" since the client is created with port 80 and no TLS. Similarly, test_http_strip_port_from_host expects the initial Host header to be "127.0.0.1:80" but will now receive "127.0.0.1" immediately (before calling flb_http_strip_port_from_host). Update these tests to either expect the omitted port or use a non-default port to retain the existing test logic.

Fix additional tests affected by fix: test_http_add_get_header and test_http_strip_port_from_host

Signed-off-by: Katriel Traum <katriel@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant