-
Notifications
You must be signed in to change notification settings - Fork 1.9k
http_client: omit default port in Host header for HTTP/80 #11380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
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>
📝 WalkthroughWalkthroughUpdates 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
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
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this 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_headerexpects"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_hostexpects the initial Host header to be"127.0.0.1:80"but will now receive"127.0.0.1"immediately (before callingflb_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>
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.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
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
Tests
✏️ Tip: You can customize this high-level summary in your review settings.