Skip to content
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

[2201.7.x] Update Host header only when the user intentionally provide a value #1894

Merged
merged 7 commits into from
Mar 13, 2024

Conversation

TharmiganK
Copy link
Contributor

@TharmiganK TharmiganK commented Mar 13, 2024

Purpose

Related to: ballerina-platform/ballerina-library#6149

With this improvement we only overwrite the Host header when the user intentionally provide a value for that. Otherwise the Host header will be inferred from the client URL

Examples

final http:Client clientEP = check new("localhost:9091");

service /api on new http:Listener(9090) {

     resource function get test1(http:Request req) returns http:Response|error {
          // Here the `Host` header will be overwritten by the clientEP URL
          return clientEP->execute("get", "api/test", req);
     }

     resource function get test2(http:Request req) returns http:Response|error {
          // Header is intentionally overwritten by the user
          req.setHeader("Host", check req.getHeader("Host"));
          // The `Host` header will not be overwritten by the clientEP
          return clientEP->execute("get", "api/test", req);
     }
}

Checklist

  • Linked to an issue
  • Updated the changelog
  • Added tests
  • Updated the spec
  • Checked native-image compatibility
  • Checked the impact on OpenAPI generation

Copy link

sonarcloud bot commented Mar 13, 2024

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

codecov bot commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 81.65%. Comparing base (b95f9d1) to head (972a7de).
Report is 1 commits behind head on 2201.7.x.

Files Patch % Lines
...lerina/stdlib/http/api/client/actions/Forward.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##             2201.7.x    #1894      +/-   ##
==============================================
+ Coverage       81.55%   81.65%   +0.09%     
  Complexity        577      577              
==============================================
  Files             393      393              
  Lines           21409    21413       +4     
  Branches         4799     4800       +1     
==============================================
+ Hits            17461    17484      +23     
+ Misses           2951     2931      -20     
- Partials          997      998       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TharmiganK TharmiganK merged commit 5b0c332 into 2201.7.x Mar 13, 2024
9 checks passed
@TharmiganK TharmiganK deleted the host-fix-passthrough-2201.7.x branch March 13, 2024 10:30
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